wget https://nginx.org/download/nginx-1.18.0.tar.gz
tar zxf nginx-1.18.0.tar.gz
cd nginx-1.18.0
./configure --with-http_stub_status_module
make&&makeinstall
3.启动nginx服务
/usr/local/nginx/sbin/nginx
4.安装mysql和PHP相关服务
yum -y install php php-fpm mysql mysql-server php-mysql
5.修改nginx配置文件,nginx和PHP进行整合
vim /usr/local/nginx/conf/nginx.conf
location / {
root html;
index index.php index.html index.htm;#在该位置添加index.php}
location ~ \.php$ {
root html;#对应的网页目录
fastcgi_pass 127.0.0.1:9000;#php-fpm请求的地址、端口
fastcgi_index index.php;#设置默认首页#设置php脚本文件请求路径
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#修改为 $document_root#引入fastcgi的配置文件
include fastcgi_params;}
6.重新加载nginx服务
/usr/local/nginx/sbin/nginx -s reload
7.启动php-fpm
systemctl start php-fpm
8.书写PHP测试页
cd /usr/local/nginx/html/
vim index.php.bak
<?php
phpinfo();
?>