Install Nginx and Apache on a single machine
In/etc/hosts
192.168.200.156 www.a.com #本机ip
127.0.0.1 www.shenge1.com
Nginx Domain Name: www.a.com (port default 80)
Apache Domain name: www.shenge1.com (the default port of 80 is 8080)
In the Nginx configuration file
http{
...
Upstream backend{#这里配置上游服务器的地址 (This example refers to the Apache server)
Server www.shenge1.com:8080;
...
}
server{
Listen 80;
server_name www.a.com;
Location/{
root/www/www.a.com;
Index index.html;
}
...
Location ~\.php$ {#匹配. php file, which is based on the/etc/httpd/conf/httpd.conf configuration file
#DocumentRoot "/var/www/html" to/var/www/html as an Apache resource
#跟目录, PHP and other files placed in this directory is good.
Proxy_pass Http://backend; #这里设置上游服务器 (actually backend refers to a bunch of server addresses)
}
}
..
}
Apache/etc/httpd/conf/httpd.conf
Listen 8080
The index.html content under the/www/www.a.com/(Nginx server Resource) is
Nginx
/var/www/html/(Resources of Apache server) the index.php content is
<?php>
Phpinfo ()
<?>
Open Nginx
Nginx
Open Apache
Service httpd Start
The individual nginx can only parse the static interface (that is, HTML files), and Apache has a PHP module to
Parse PHP file, genetic a lot of static HTML interface, then return to Nginx, and then return to the client browser
First access in the browser www.a.com appears the interface display Nginx Normal startup
Then www.a.com/index.php, if only the individual nginx is unable to display
Out, if according to our configuration will nginx as a reverse proxy through Apache can parse, at this time
If it can resolve, the reverse proxy is not a problem.
This article is from the "12208412" blog, please be sure to keep this source http://12218412.blog.51cto.com/12208412/1866825
Nginx reverse proxy and load balancer