NGINX+PHP-FPM deployment of Standalone nodes WordPress notes

Source: Internet
Author: User

Previously, the LNMP environment was installed with LNMP one-click.

Today, the classmate said he separate deployment nginx+php-fpm appeared a problem, always reported 502, just I did not test, so I also did it again, also encountered some problems, write down to use later.


node1:192.168.2.11 Nginx+mysql

node2:192.168.2.12 PHP-FPM

which Node1 and the Node2 the pre-installation is Lnmp One-click installation package.

Therefore, the installation process is not described.

To start modifying parameters directly, proceed as follows.

Node1 on the MySQL the configuration:

The installation process is skipped, the authorization configuration

>create database wp;>grant all on wp.* to ' WP ' @ ' 192.168.2.% ' identified by ' 123456 '; >flush privileges;

node1 nginx

Server    {        listen 80 default_ server;        server_name 192.168.2.11;         index index.html index.htm index.php;         root /home/wwwroot/default;          #error _page  404   /404.html;        location  ~\.php$ {           root /home/wwwroot/ default;           fastcgi_pass 192.168.2.12:9000;            fastcgi_index index.php;            includefastcgi.conf;    Note I'm not using fastcgi_ here. params, because there's a missing line in Fastcgi_params.File        }         location  ~.*\. (gif|jpg|jpeg|png|bmp|swf) $        {             expires      30d;         }         location ~ .*\. (JS|CSS)?$        {             expires      12h;         }         location ~ /\.         {            deny  all;        }          access_log /home/wwwlogs/access.log  access;    } 

In addition, fastcgi.conf The contents are as follows:

fastcgi_param script_filename    $document _root$fastcgi_script_name;    attention to this line, Fastcgi_param than fastcgi.conf is missing this line fastcgi_param  query_string         $query _string;fastcgi_param  request_method      $request _method; fastcgi_param  content_type        $content _type;fastcgi_param   CONTENT_LENGTH      $content _length; fastcgi_param  script_ name         $fastcgi _script_name;fastcgi_param  request_uri          $request _uri;fastcgi_param  document_uri         $document _uri;fastcgi_param  document_root        $document _root;fastcgi_param  server_protocol     $server _protocol; Fastcgi_param  https               $https  if_not_empty;  fastcgi_param  gateway_interface  cgi/1.1;fastcgi_param  server_software     nginx/$nginx _version; fastcgi_param  remote_addr          $remote _addr;fastcgi_param  remote_port          $remote _port;fastcgi_param  server_addr          $server _addr;fastcgi_param  server_port         $server _port;fastcgi_param  server_name         $server _name; # php only, required if php was built with -- enable-force-cgi-redirectfastcgi_param  redirect_status    200;

Node2 on the PHP-FPM the configuration file is as follows:

[global]pid=/usr/local/php/var/run/php-fpm.piderror_log=/usr/local/php/var/log/php-fpm.loglog_level= notice [www   ]listen = 192.168.2.12:9000listen.backlog= -1listen.allowed_clients = 192.168.2.11 If commented out this line means allow all IP connections to php-fpmlisten.owner= wwwlisten.group= wwwlisten.mode= 0666user= wwwgroup= wwwpm= dynamicpm.max_ children= 10pm.start_servers= 2pm.min_spare_servers= 1pm.max_spare_servers= 6pm.max_requests = 1000 This parameter setting is too small and may cause Intermittent 502 Error request_terminate_timeout= 100request_slowlog_timeout= 0slowlog= var/log/slow.log

Friend website newspaper 502, is because the above listen.allowed_clients parameter was he set to any (by the online a pit father's tutorial harm)

In addition, you will have to Node1 and the Node2 The same Web site source files on the deployment.

in the Node2 on the pass SCP will be Node1 on the WordPress Copy the website files.

# SCP [email protected]:/home/wwwroot/default/home/wwwroot/default# chown Www.www/home/wwwroot/default


It is important to note that: Node1 the running Nginx of users ID in the Node2 to exist, and ID also have the same, otherwise may be accessed when the error.

in the Node1 Start Nginx , in Node2 on Start PHP-FPM .


in browser access http://192.168.2.11 can enter WordPress the installation interface. Enter information about the database to




The file is not considered here ( and pictures ) storage, in a real-world production environment, you should use shared storage NFS or distributed storage.


NGINX+PHP-FPM deployment of Standalone nodes WordPress notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.