Nginx Series-8. Configuration nginx+apache for dynamic and static separation

Source: Internet
Author: User
Tags nginx reverse proxy

Nginx Series-8. Configure Nginx+apache to achieve static and dynamic separation directory-Nginx series

Nginx Series -1.linux Installation Nginx
Nginx Series-2. Configuring the Lnmp (Linux, Nginx, MySQL, PHP) architecture
Nginx Series-3. Configuring Nginx Virtual Host
Nginx Series -4.nginx log configuration and log cutting
Nginx Series-5. Configure the Nginx anti-theft chain
Nginx Series-6. Configuring Nginx HTTPS
Nginx Series-7. Configuring Nginx using UWSGI support web.py framework
Nginx Series-8. Configuration nginx+apache for dynamic and static separation
Nginx Series-9. Configuring NFS for static and dynamic separation of Nginx
Nginx Series-10. Using Nginx to build forward proxy service
Nginx Series-11. Configuring Nginx Reverse proxy and load balancing

Experimental Environment
Two minimized CentOS 7.3 virtual machines
server1-ip:192.168.204.133
server2-ip:192.168.204.134

Experimental topology

First, Server1 installation configuration Nginx
    1. Install nginx

       yum install-y epel-*yum install-y nginx vim
             

    2. Establish nginx home directory and home page

       mkdir/var/ Wwwrootcd/var/wwwrootecho-e "Nginx" >> nginx.html  

    3. Configure nginx configuration file

       vim/etc/nginx/nginx.conf  


      Modify the default server block as follows

       server {listen 80;server_name _;location/{root/var/wwwroot; Index index.html index.htm;} Location ~ \.php$ {proxy_pass http://[apache ' s IP address]; #修改为Apache的IP地址 proxy_set_header host $host;}}  

    4. Restart nginx service

       systemctl restart Nginx  

    5. Close firewall
       setenforce 0systemctl stop Firewalldsystemctl Disable FIREWALLD  

Second, server2 installation configuration Apache and PHP
    1. Installation Apache andPHP

      yum install -y httpd php

    2. ApacheCreate a PHP file in the Web root directory ( /var/www/html )

      cd /var/www/htmlecho -e "<?php phpinfo(); ?>" >> info.php

    3. Restart Apache Service

      systemctl restart httpd

    4. Shutting down the firewall
      setenforce 0systemctl stop firewalldsystemctl disable firewalld

Three, the test static and dynamic separation, host access server1
    1. Access http://192.168.204.133/nginx.html
      Returned is the server1 resource on the

    2. Visit PHP page http://192.168.204.133/info.php
      Returned is the server2 resource on the

Nginx Series-8. Configuration nginx+apache for dynamic and static separation

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.