linux使用yum安裝php的方法:1、執行“mkdir /usr/local/php”命令;2、下載yum源的更新安裝包;3、安裝相關yum源安裝包;4、通過“yum install”命令安裝php即可。
一、yum安裝php
1、mkdir /usr/local/php
2、cd /usr/local/php
3、下載yum源的更新安裝包
立即學習“PHP免費學習筆記(深入)”;
centOS 6.x源
wget?https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm wget?https://mirror.webtatic.com/yum/el6/latest.rpm
centOS 7.x源
wget?https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm wget?https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
4、安裝相關yum源安裝包(這里以centOS 7.x的為例)
rpm?-Uvh?epel-release-latest-7.noarch.rpm rpm?-Uvh?webtatic-release.rpm
5、查看該源對應的php安裝包命令(以PHP 為例)
yum?list?--enablerepo=webtatic?|?grep?php
6、查找php 5.6版本的安裝包
yum?search?php56w
7、安裝Apache
yum?install?httpd?httpd-devel
8、關閉firewalld防火墻
systemctl?stop?firewalld.service? systemctl?disable?firewalld.service? systemctl?status?firewalld
9、啟動apache
/bin/systemctl?start?httpd.service
此時用瀏覽器訪問你服務器IP地址 ?應該是Testing 123文件頁面。
10、安裝mysql【這里因為之前使用tar包安裝了mysql,所以不安裝】
11、啟動mysql
systetcl?start?mysql
***如果啟動mysql時報錯
Failed?to?start?mysql.service:?Unit?mysql.service?failed?to?load:?No?such?file?or?directory.
或者
Failed?to?start?mysqld.service:?Unit?not?found
則需要安裝mariadb-server并啟動,添加到開機自啟動
yum?install?-y?mariadb-server systemctl?start?mariadb.service systemctl?enable?mariadb.service
12、安裝PHP
yum?install?php56w
13、重啟apache使php生效
/bin/systemctl?restart?httpd.service
14、查看PHP的版本
php?-v
15、php的簡單使用
進入目錄/var/www/html
vi index.php(必須是index.php【主頁】才會在瀏覽器顯示)
內容如下:
nbsp;html> <?php echo "Hello World!"; ?>
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END
喜歡就支持一下吧
相關推薦