Nginx is separated from PHP

nginx andphpseparate building

nginx configuration

server {

< p style="margin:0in;font-size:10.5pt"> listen 80; Define port< /span>

server_name www.a.org; Define the domain name

location / {

root root /www/a.org; Definition php web page file path

index index.php index.html index .htm; Define the recognized file types

}

location ~ \.php$ {

Root root /www/a.org; Define the web file path of the php server

fastcgi_pass 192.168 .2.129:9000; Define the path of the php server

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

include fastcgi_params;

}

2. Edit/etc/nginx/fastcgi_params, change its content to the following:

fastcgi_param GATEWAY_INTERFACE CGI/1.1;

fastcgi_param SERVER_SOFTWARE nginx;

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_FILENAME $document_root $fastcgi_script_name;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;

fastcgi_param REQUEST_URI $request_uri;

fastcgi_param DOCUMENT_URI $document_uri;< /p>

fastcgi_param DOCUMENT_ROOT $document_root;

fastcgi_param SERVER_PROTOCOL $server_protocol;

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 configuration

1, createnginx User

2,< /span>.Modifyphp -fpmConfiguration file/usr/local/php/etc/php-fpm.conf

listen = 172.16.1.2:9000 #Listen to the physical network card address for other machines to call p>

user = nginx ##php-fpm以nginxUser run

group = nginx

restart php-fpm

#service php-fpm restart

Turn off the firewall of the two servers!

Five. Install xcache, which isphpAcceleration:

1, installation

# tar xf xcache-2.0.0.tar.gz

# cd xcache-2.0.0

# /usr/local/php/bin/phpize

# ./configure –enable-xcache –with-php-config=/usr/local/php /bin/php-config

# make && make install

At the end of the installation, a line similar to the following will appear:

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/< /p>

2. Editphp.ini, integrate /span>phpandxcache :

p>

First import the sample configuration provided by xcachephp.ini

# mkdir /etc/php.d

# cp xcache.ini /etc/php.d

Note: The xcache.ini file is inxcache in the source code directory.

Next edit /etc/php.d/xcache.ini and findzend_extension The line at the beginning of is modified as follows:

zend_extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so

Note: If there are multiple entries in the php.ini file< /span>zend_extensioncommand line, make sure this new line is ranked first.

3. Restartphp-fpm

# service php-fpm restart

VI. Supplementary description

If you want to use it in SSLphp, need to be inphp< Add this option in span style="font-family:calibri">location:

fastcgi_param HTTPS on;

nginx and< span style="font-weight:bold;font-family:calibri">phpseparate building

nginx configuration

server {

listen listen 80; define port

server_name www.a.org; Define the domain name

location / {

root /www/a.org; Define the php web page file path

index index index.php index.html index.htm; Define the document type that can be recognized

}

location ~ \.php$ {

root root /www/a.org; Define the web file path of the php server

fastcgi_pass 192.168.2.129:9000; Define the path of the php server

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

include fastcgi_params;

}

2. Edit/etc/nginx/fastcgi_params, change its content to the following:

fastcgi_param GATEWAY_INTERFACE CGI/1.1;

fastcgi_pa ram SERVER_SOFTWARE nginx;

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_FILENAME $document_root$fastcgi_script_name;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;

p>

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 REMOTE_ADDR $remote_addr;

fastcgi_param REMOTE_PORT $remote_port;

fastcgi_param SERVER_ADDR $server_addr;

p>

fastcgi_param SERVER_PORT $server_port;

fastcgi_param SERVER_NAME $server_name;

php configuration

1, create

span>nginxUser

2,.Editphp-fpmConfiguration file/usr/ local/php/etc/php-fpm.conf

listen = 172.16.1.2:9000 # Monitor the physical network card address for other machines to call

user = nginx ##php-fpm Run as nginxuser

group = nginx

restart php- fpm

#service php-fpm restart

Turn off the firewalls of the two servers!

Five. Install xcache, which isphpAcceleration:

1, installation

# tar xf xcache-2.0.0.tar.gz

# cd xcache-2.0.0

# /usr/local/php/bin/phpize

# ./configure –enable-xcache –with-php-config=/usr/local/php /bin/php-config

# make && make install

At the end of the installation, a line similar to the following will appear:

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

< p style="margin:0in;font-family:Calibri;font-size:10.5pt">

2. Editphp.ini, integrate< span style="font-family:calibri">phpandxcache :

First import the sample configuration provided by xcachephp.ini

# mkdir /etc/php.d

# cp xcache.ini /etc/php.d

Note: The xcache.ini file is in xcache source code directory.

Next edit /etc/php.d/xcache.ini and findzend_extension The line at the beginning of is modified as follows:

zend_extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so

Note: If there are multiple entries in the php.ini file< /span>zend_extensioncommand line, make sure this new line is ranked first.

3. Restartphp-fpm

# service php-fpm restart

VI. Supplementary description

If you want to use it in SSLphp, need to be inphp< Add this option in span style="font-family:calibri">location:

fastcgi_param HTTPS on;

nginx andphpseparate building

nginx configuration

server {

listen listen 80; define port< /p>

server_name www .a.org; Define domain name

location / {

root root /www/a.org; Define php web page file path

index index.php index.html index.htm; Define the file types that can be recognized

}

location ~ \.php$ {

root root /www/a.org; Define the web file path of the php server

Fastcgi_pass 192.168.2.129:9000; Define the path of the php server

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name ;

include fastcgi_params;

}

2. Edit< span style="font-family:calibri">/etc/nginx/fastcgi_params, change its content to the following:

fastcgi_param GATEWAY_INTERFACE CGI/1.1;

fastcgi_param SERVER_SOFTWARE nginx;

fastcgi_param QUE RY_STRING $query_string;

fastcgi_param REQUEST_METHOD $request_method;

fastcgi_param CONTENT_TYPE $content_type;

fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;

fastcgi_param REQUEST_URI $request_uri;

p>

fastcgi_param DOCUMENT_URI $document_uri;

fastcgi_param DOCUMENT_ROOT $document_root;

fastcgi_param SERVER_PROTOCOL $server_protocol;

fastcgi_param REMOTE_ADDR $remote_addr;< /p>

fastcgi_param REMOTE_PORT $remote_port;

fastcgi_param SERVER_ADDR $server_addr;

fastcgi_param SERVER_PORT $server_port;

< p style="margin:0in;font-family:Calibri;font-size:10.5pt">fastcgi_param SERVER_NAME $server_name;

php configuration

1. Createnginxuser

2,.Editphp-fpmConfiguration file/usr/local/php/etc/ php-fpm.conf

listen = 172.16.1.2:9000 #Listen to the physical network card address for Call from other machines

user = nginx ##php-fpm以< span style="font-family:calibri">nginxUser run

group = nginx

restart php-fpm

< p style="margin:0in;font-family:Calibri;font-size:10.5pt">#service php-fpm restart

Turn off the firewall of the two servers!

Five. Install xcache, which isphpAcceleration:

1, installation

# tar xf xcache-2.0.0.tar.gz

# cd xcache-2.0.0

# /usr/local/php/bin/phpize

# ./configure –enable-xcache –with-php-config=/usr/local/php /bin/php-config

# make && make install

At the end of the installation, a line similar to the following will appear:

Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

2 , Editphp.ini, integratephpandxcache:

First import the sample configuration provided by xcachephp.ini< /span>

# mkdir /etc/php.d

# cp x cache.ini /etc/php.d

 

说明:xcache.ini文件在xcache的源码目录中。

 

接下来编辑/etc/php.d/xcache.ini,找到zend_extension开头的行,修改为如下行:

zend_extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so

 

注意:如果php.ini文件中有多条zend_extension指令行,要确保此新增的行排在第一位。

 

3、重新启动php-fpm

# service php-fpm restart

 

 

六、补充说明

 

如果要在SSL中使用php,需要在phplocation中添加此选项:

 

fastcgi_param HTTPS on;

nginx与php分离搭建

nginx配置

server {

        listen       80;      定义端口

        server_name  www.a.org;    定义域名

  location / {

            root    /www/a.org;      定义php网页面文件路径

            index  index.php  index.html index.htm;    定义能够识别的文件类型

        }

 

  location ~ \.php$ {

            root        /www/a.org;      定义php服务器的网页文件路径

            fastcgi_pass   192.168.2.129:9000;      定义php服务器的路径

            fastcgi_index  index.php;    

            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

            include        fastcgi_params;

        }

2、编辑/etc/nginx/fastcgi_params,将其内容更改为如下内容:

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;

fastcgi_param  SERVER_SOFTWARE    nginx;

fastcgi_param  QUERY_STRING       $query_string;

fastcgi_param  REQ UEST_METHOD     $request_method;

fastcgi_param  CONTENT_TYPE       $content_type;

fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;

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  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配置

1、创建nginx用户

2、.修改php- fpm配置文件 /usr/local/php/etc/php-fpm.conf

listen = 172.16.1.2:9000  #监听物理网卡地址,供其它机器调用

user = nginx      ##php-fpm以nginx用户运行

group = nginx

重启php-fpm

#service php-fpm restart

 

关掉两台服务器的防火墙!

 

 

五、安装xcache,为php加速:

 

1、安装

# tar xf xcache-2.0.0.tar.gz

# cd xcache-2.0.0

# /usr/local/php/bin/phpize

# ./configure –enable-xcache –with-php-config=/usr/local/php/bin/php-config

# make && make install

 

安装结束时,会出现类似如下行:

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

 

2、编辑php.ini,整合phpxcache

 

首先将xcache提供的样例配置导入php.ini

# mkdir /etc/php.d

# cp xcache.ini /etc/php. d

 

说明:xcache.ini文件在xcache的源码目录中。

 

接下来编辑/etc/php.d/xcache.ini,找到zend_extension开头的行,修改为如下行:

zend_extension = /usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so

 

注意:如果php.ini文件中有多条zend_extension指令行,要确保此新增的行排在第一位。

 

3、重新启动php-fpm

# service php-fpm restart

 

 

六、补充说明

 

如果要在SSL中使用php,需要在phplocation中添加此选项:

 

fastcgi_param HTTPS on;

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4626 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.