openresty PHP WordPress Build blog site (openresty and PHP on both machines)

Source: Internet
Author: User
Tags lua

First, understand Openresty

  a Full function WEB Application Server, it hits the the standard Nginx core is covered , many of the commonly used third-party modules, and most of their dependencies. Openresty through the aggregation of a variety of well-designed nginx modules, thus effectively turning Nginx into a powerful Web application server, so that Web developers can use the Lua scripting language to mobilize nginx support of various C and Lua modules, quickly constructed enough to be competent for 1 0k+ Ultra-high-performance Web application system with concurrent connection response. The goal of Openresty is to let your Web service run directly inside the Nginx service, taking full advantage of Nginx's nonblocking I/O model, not just for HTTP client requests, but even for remote backend such as MySQL, Postgresql,~memcaches and ~redis are consistently high-performance responses.

Second, download, installation preparation Openresty

: http://openresty.org/download/ngx_openresty-1.7.7.1.tar.gz

Download: wget ' "http://openresty.org/download/ngx_openresty-1.7.7.1.tar.gz"

Install dependency Package: Perl 5.6.1+ libreadline Libpcre Libssl

Fedora, Redhat, Centos:readline-devel pcre-devel openssl-devel

Third, installation Openresty

1.tar XZVF ngx_openresty-1.7.7.1.tar.gz

2.CD NGX_OPENRESTY-1.7.7.1/

3../configure

you can set the parameters:./configure--prefix= /opt/openresty --with-luajit--without-http_redis2_module--with-http_iconv_module--with-http_postgres_module

4.make

5.make Install

Problems that may occur:

./configure:error:ngx_postgres addon was unable to detect version of the LIBPQ library.
Error:failed to run command:sh./configure--prefix=/opt/openresty/nginx \ ...

Installation: PostgreSQL (a free object-relational database server (database management system)) Postgresql-devel

Yum Install PostgreSQL Postgresql-devel

Iv. Configuration Openresty

Configuration file Location: vim/opt/openresty/nginx/conf/nginx.conf

Modified: server_name localhost-to server_name 192.168.0.167 (native IP address)

Start:/opt/openresty/nginx/sbin/nginx (stop at the back plus-s stop)

In order to facilitate later operation can:

To add a startup script: Vim/etc/init.d/nginx

Modified: Nginx pidfile nginx_conf_file for the installation path of its own files

nginx= "/opt/openresty/nginx/sbin/nginx"

Pidfile= "/opt/openresty/nginx/logs/nginx.pid"
Nginx_conf_file= "/opt/openresty/nginx/conf/nginx.conf"

Soft-Connect profile: Ln-s/opt/openresty/nginx/conf/nginx.conf/etc/nginx.conf

Five, Test openresty

In the browser input: 192.168.0.167 display below indicates success

  

  Reference Document: Http://www.openresty.org/cn/index.html

Vi. PHP (yum installation)

Yum Install PHP php-fpm

Seven, configuration openresty support PHP

Edit Profile: vim/opt/openresty/nginx/conf/nginx.conf

#location ~ \.php$ {
# root HTML;
# Fastcgi_pass 127.0.0.1:9000; The request is forwarded to this IP address for processing. Mine is 192.168.0.162:9000.
# Fastcgi_index index.php;
# Fastcgi_param Script_filename /scripts$fastcgi _script_name; The red section indicates where the request file was changed to the directory where the PHP file was located in the same location as the PHP host. Mine is/var/www/html.
# include fastcgi_params;
        #}

Remove the # from the previous section in the configuration file

PS: Restart nginx online server preferably with reload

  Modify the configuration file of the host where PHP is located, accept 192.168.0.167 Request

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

Listen.allowed_clients = 192.168.0.167

                          PS: Restart PHP-FPM

Eight, testing

Notice the firewall: No, it's off, otherwise notice if the port used by the firewall allows communication

Write the test file under the PHP Host: vim/var/www/html/index.php

Content: <?php phpinfo ();?>

Nine, WordPress application

1. Download the latest WordPress compression Pack Eg:wordpress-4.0.1.zip

2. Upload the directory where WordPress is located under the/opt/openresty/nginx/html/file directory of the Openresty host and the php file of the PHP host eg:/var/www/html

3. Unzip unzip Wordpress-4.0.1.zip respectively

4. Configure Openresty Support:

location/{
             root   html/wordpress;
       }

location ~ \.php$ {
          root           html;
         fastcgi_pass      192.168.0.162:9000; The request is forwarded to this IP address for processing. My 192.168.0.162:9000
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_  filename  /var/www/html $fastcgi _script_name; The red part indicates the directory where PHP is located in the host where the requested file is changed to the extracted WordPress file. My for/var/www/html/wordpress
         include         Fastcgi_params;
       }

                                      PS: Restart Nginx application

Ten, testing

The browser input 192.168.0.167/index.php displays as follows to indicate success

  

openresty PHP WordPress Build blog site (openresty and PHP on both machines)

Related Article

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.