1. 安装nginx
yum install nginx
nginx -v
nginx version: nginx/1.20.1
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.33
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