centos7安裝「php-fpm」的方法:先透過yum安裝「php-fpm」相關元件;然後在「default.conf」中修改內容用以支援php;最後重啟nginx服務即可。
推薦:《centos入門教學》
#CentOS7用yum方式安裝Nginx php-fpm
環境
[root@localhost html]# cat /etc/centos-release CentOS Linux release 7.1.1503 (Core) [root@localhost sbin]# /usr/sbin/nginx -v nginx version: nginx/1.14.0 [root@localhost /]# php-fpm -v PHP 5.4.16 (fpm-fcgi) (built: Apr 12 2018 19:03:25) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
1.安裝nginx
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm yum install -y nginx systemctl start nginx systemctl status nginx systemctl stop nginx systemctl enable nginx
用瀏覽器開啟以下位址能訪問就說明配置成功了
http://192.168.0.61/
2.yum安裝php-fpm相關元件
yum -y install php php-fpm php-gd php-mysql php-common php-pear php-mbstring php-mcrypt systemctl status php-fpm systemctl start php-fpm systemctl enable php-fpm
3.編輯/etc/nginx/conf.d/default.conf並新增以下內容以支援php
vim /etc/nginx/conf.d/default.conf
# location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
修改完設定以後需要重新啟動nginx服務
4.建立index.php檔案並測試
vim /usr/share/nginx/html/index.php
<?php phpinfo(); ?>
以上是centos7如何安裝php-fpm的詳細內容。更多資訊請關注PHP中文網其他相關文章!