linux使用yum安裝php的方法:1、執(zhí)行“mkdir /usr/local/php”命令;2、下載yum源的更新安裝包;3、安裝相關(guān)yum源安裝包;4、通過“yum install”命令安裝php即可。
本教程操作環(huán)境:centos7系統(tǒng)、PHP5.6版、DELL G3電腦
linux怎么使用yum安裝php?
Linux虛擬機(jī)采用yum安裝php方法(自我安裝詳細(xì)步驟記錄)
PHP 服務(wù)器 安裝分兩種 一種YUM 安裝 一種編譯安裝 。
(由于linux機(jī)制,每個(gè)文件夾都有他指定的含義,不可隨意使用,編譯安裝需要了解,文件夾分類信息,YUM 安裝則不需要去考慮,
因?yàn)樗呀?jīng)幫你固定安裝好了目錄,這就是網(wǎng)上為什么 推薦yum的原因)
一、yum安裝php
1、mkdir /usr/local/php
2、cd /usr/local/php
3、下載yum源的更新安裝包
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、安裝相關(guān)yum源安裝包(這里以centOS 7.x的為例)
rpm -Uvh epel-release-latest-7.noarch.rpm rpm -Uvh webtatic-release.rpm
5、查看該源對應(yīng)的php安裝包命令(以PHP 為例)
yum list --enablerepo=webtatic | grep php
6、查找php 5.6版本的安裝包
yum search php56w
7、安裝Apache
yum install httpd httpd-devel
8、關(guān)閉firewalld防火墻
systemctl stop firewalld.service systemctl disable firewalld.service systemctl status firewalld
9、啟動apache
/bin/systemctl start httpd.service
此時(shí)用瀏覽器訪問你服務(wù)器IP地址 應(yīng)該是Testing 123文件頁面。
10、安裝mysql【這里因?yàn)橹笆褂胻ar包安裝了mysql,所以不安裝】
11、啟動mysql
systetcl start mysql
***如果啟動mysql時(shí)報(bào)錯(cuò)
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并啟動,添加到開機(jī)自啟動
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的簡單使用
進(jìn)入目錄/var/www/html
vi index.php(必須是index.php【主頁】才會在瀏覽器顯示)
內(nèi)容如下:
<!DOCTYPE html> <html> <body> <?php echo "Hello World!"; ?> </body> </html>
推薦學(xué)習(xí):《PHP視頻教程》