fpm+MySQL分离部署详解

1 service php-fpm start

四、整合nginx与PHP

  1.nginx服务器建立网页文件存放目录/www,并修改其权限:

1 mkdir /www 2 chown -R nginx:nginx /www

  2.修改nginx配置文件:

1 vim /etc/nginx/nginx.conf 2 -------------------------------------- 3 location / { 4 root /www; 5 index index.php index.html index.htm; 6 } 7 8 location ~ \.php$ { 9 root /www; 10 fastcgi_pass 192.168.19.92:9000; 11 fastcgi_index index.php; 12 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 13 include fastcgi_params; 14 }

 

  3.修改fastcgi_params文件为:

1 fastcgi_param GATEWAY_INTERFACE CGI/1.1; 2 fastcgi_param SERVER_SOFTWARE nginx; 3 fastcgi_param QUERY_STRING $query_string; 4 fastcgi_param REQUEST_METHOD $request_method; 5 fastcgi_param CONTENT_TYPE $content_type; 6 fastcgi_param CONTENT_LENGTH $content_length; 7 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 8 fastcgi_param SCRIPT_NAME $fastcgi_script_name; 9 fastcgi_param REQUEST_URI $request_uri; 10 fastcgi_param DOCUMENT_URI $document_uri; 11 fastcgi_param DOCUMENT_ROOT $document_root; 12 fastcgi_param SERVER_PROTOCOL $server_protocol; 13 fastcgi_param REMOTE_ADDR $remote_addr; 14 fastcgi_param REMOTE_PORT $remote_port; 15 fastcgi_param SERVER_ADDR $server_addr; 16 fastcgi_param SERVER_PORT $server_port; 17 fastcgi_param SERVER_NAME $server_name;

  4.在PHP服务器上,建立nginx用户,要保证和nginx服务器上的nginx用户id号、组id号一致:

  5.修改php-fpm配置文件,并重启:

1 vim /usr/local/php/etc/php-fpm.conf 2 --------------------------------------------- 3 listen = 192.168.19.92:9000     //监听物理网卡地址,供其它机器调用 4 user = nginx //php-fpm以nginx用户运行 5 group = nginx 6 --------------------------------------------- 7 service php-fpm restart

  6.在PHP服务器上创建/www目录,并开启nfs服务:

1 mkdir /www 2 chown -R nginx:nginx /www 3 vim /etc/exports 4 --------------------------------------------- 5 /www 192.168.19.0/24(rw,no_root_squash) 6 --------------------------------------------- 7 service nfs start

  7.nginx服务器挂载nfs文件,并测试php,测试成功后删除index.php:

1 mount -t nfs 192.168.19.92:/www /www 2 vim /www/index.php 3 --------------------------------------- 4 <?php 5 phpinfo(); 6 ?> 7 -------------------------------------- 8 service nginx restart

fpm+MySQL分离部署详解

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/3d748d00fea15c203fa3f0701c59f85f.html