centos7+安裝nginx+php7

banma_work發表於2018-03-30

yum localinstall -y http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

yum install -y nginx

systemctl status nginx.service

systemctl start nginx

systemctl status nginx.service

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

yum install -y php70w  php70w-mysql.x86_64   php70w-gd.x86_64   php70w-ldap.x86_64   php70w-mbstring.x86_64  php70w-mcrypt.x86_6 php70w-fpm

vim /etc/nginx/nginx.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;
}

vim /usr/share/nginx/html/phpinfo.php

新增

<?php
echo phpinfo();
?>

vim /etc/php-fpm.d/www.conf

修改

user = nginx
group = nginx

netstat -antp

php-cgi -b 127.0.0.1:9000 &

systemctl restart nginx

相關文章