centos7 安裝php 與nginx環(huán)境簡(jiǎn)便方法(全程yum)

安裝nginx:

1.yum -y install epel-release

2.rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm? ? ?##更新安裝包

3.yum -y install nginx??##安裝nginx

4.?systemctl start nginx? ?## 啟動(dòng) nginx

????systemctl stop nginx? ? ? ?## 關(guān)閉 nginx

????systemctl restart nginx? ? ## 重啟 nginx

5.?systemctl enable nginx.service##設(shè)置 nginx 服務(wù)開(kāi)機(jī)自啟動(dòng)

安裝php:

1.yum -y install epel-release

2.rpm -Uvhhttps://mirror.webtatic.com/yum/el7/webtatic-release.rpm##更新安裝包

3.yum list php*##查看php版本

4.yum install php71w##安裝php71(請(qǐng)根據(jù)上一步查看到的php實(shí)際情況選擇名稱(chēng) ,我的是 php71w)

5.yum list php71w-fpm##安裝php-fpm

6.systemctl start php-fpm##之后?systemctl enable php-fpm 將php服務(wù)設(shè)置為啟動(dòng)

7.yum install php71w-cli##安裝php客戶(hù)端,支持控制臺(tái)php命令

centos7及其以上系統(tǒng)。

##安裝vimplus(建議在普通用戶(hù)下安裝)強(qiáng)大的vim編輯器

git clone https://github.com/chxuan/vimplus.git ~/.vimplus##復(fù)制文件包

cd ~/.vimplus? ? ?##進(jìn)入安裝目錄

./install.sh? ??##安裝vimplus

nginx 與php關(guān)聯(lián):

1.nginx -t?##查看nginx配置文件路徑

在nginx配置文件中http模塊中添加配置:

server {

listen 80;

server_namewww.nginx.com;

root /usr/share/nginx/html;

location / {

index index.html index.htm index.php;

}

location ~ \.php(.*)$ {

# # With php-fpm (or other unix sockets):

# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;

# # With php-cgi (or other tcp sockets):

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

include fastcgi_params;

}

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀(guān)點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容