CentOS 7.4 nginx 1.12.2 PHP 7.0.25 Mysql 使用阿里云RDS
1. 安装nginx
yum install nginx
nginx -v
nginx version: nginx/1.12.2
vi /etc/nginx/nginx.conf
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log main;
server
root /usr/share/nginx/html;
ps -ef | grep nginx 可以看到nginx的进程
这时可以web访问网站了,但不支持php文件。
2. 安装PHP7.0
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 php70w
yum install php70w-fpm
修改nginx.conf 增加:
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
这样就可以访问php文件了。
======================================
以下为开机启动设置:
php-fpm 要写开机启动脚本 放到/etc/init.d目录下 然后
chkconfig --add php-fpm
chkconfig php-fpm on
chkconfig nginx on
chkconfig mysqld on