搭建lnmp环境-nginx关联php-fpm (第三步)

发布时间 2023-12-19 18:51:13作者: 猫猫客服

 

永久关闭防火墙
sudo systemctl stop firewalld
sudo systemctl disable firewall

 

安装php扩展 php-fpm

yum -y install php-fpm

 

systemctl start php-fpm.service
systemctl enable php-fpm.service

 

 

修改php-fpm用户

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

新增用户:www(useradd www)

查看www用户组,没有的话再创建并加入,(groups www)

systemctl restart php-fpm.service
 


需要关闭防火墙!才能访问,或者开放端口。
server {
    listen 8080;
    server_name  192.168.2.128;

    root   /usr/share/nginx/html/test1;
   
    location / {        
        index index.php index.html index.htm;
        if (!-e $request_filename) {
          rewrite  ^(.*)$  /index.php?s=/$1  last;
          break;
        }
    }
   
    location ~ \.(php|phar)(/.*)?$ {
      fastcgi_split_path_info  ^(.+\.(?:php|phar))(/.*)$;
      fastcgi_intercept_errors on;
      fastcgi_index index.php;
      include   fastcgi_params;
      fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      fastcgi_param PATH_INFO $fastcgi_path_info;
      fastcgi_pass  127.0.0.1:9000;
    }
}

 

systemctl restart nginx.service