"Linux" Nginx service configuration

Source: Internet
Author: User
Tags pkill

I. Deployment of the LNMP environment
    准备工作   Linux系统准备                 设置IP                 关闭防火墙              yum源配置    安装: 传输软件包    1. tar -zxvf  lnmp1.2-full.tar.gz        cd  lnmp1.2-full       ./install.sh  
Two. Experiment with 1 virtual hosts
    www.sina.com www.sohu.com 1. Domain Name resolution (file parsing) 2. Planning the Site Directory Mkdir/home/wwwroot/sina/mkdir/home/wwwroot/soh U/vim/home/wwwroot/sina/index.html vim/home/wwwroot/sohu/index.html 3. Modify the configuration file vim/usr/local/nginx/conf/    nginx.conf Listen 80;      4. Establish the virtual host file v.conf vim/usr/local/nginx/conf/vhost/v.conf 1 server {2 Listen 80;      3 server_name www.sina.com;      4 index index.html index.htm index.php;      5 Root/home/wwwroot/sina;      6 7 include enable-php.conf;     8 9} Ten server {listen 80;     server_name www.sohu.com;     Index index.html index.htm index.php;     Root/home/wwwroot/sohu;     Include enable-php.conf; 18 19} 5. Restart service Test pkill-hup nginx Test www.sina.com www.sohu.com Experiment 2 rewrite rewrite/redirect domain jump Www.sina . com, www.sohu.com vim/usr/local/nginx/Conf/vhost/v.conf 1 server {2 Listen 80;      3 server_name www.sina.com;      4 index index.html index.htm index.php;      5 Root/home/wwwroot/sina;      6 7 include enable-php.conf;      8 location/nginx_status{9 stub_status on;      Ten Access_log off; One} if ($http _host = www.sina.com) {rewrite (. *) http://www.so      Hu.com permanent;    14} 15} Restart service pkill-hup nginx test www.sina.com-www.sohu.com Web file jump      1. Modify the configuration file vim/usr/local/nginx/conf/vhost/v.conf 1 server {2 Listen 80;      3 server_name www.sina.com;      4 index index.html index.htm index.php;      5 Root/home/wwwroot/sina;      6 7 include enable-php.conf;      8 location/nginx_status{9 stub_status on;    Ten Access_log off;  Rewrite index (\d+). Html/index.php?id=$1 last;     14} 2. Create a index.php file vim/home/wwwroot/sina/index.php <?php echo "Sina rewrite!"?> 3. Restart the service test                  Pkill-hup nginx Test www.sina.com/index3.html Experiment 3 Agent Load balancer (reverse proxy) Preparation: Nginx S 192.168.183.251 Apache S1 192.168.183.123 Apache S2 192.168.183.103 Build Step 1. Modify the S Nginx configuration file vim/usr/                Local/nginx/conf/nginx.conf upstream Myweb1 {192.168.183.123:80;                192.168.183.103:80 server;                The server {Listen 80;                server_name www.sohu.com;                Location/{Proxy_pass http://myweb1; Proxy_next_upstream http_500 http_502 http_503 Error TimeoutInvalid_header;                Proxy_set_header Host $host;                Proxy_set_header x-forwarded-for $remote _addr;             78} 79} 2. Configure S1 Apache 192.168.183.123 normal access login to S1 close AutoIndex vhosts feature              vim/usr/local/apache2/htdocs/index.html S1111111111111 Test 192.168.183.123 3. Configure S2 Apache 192.168.183.103 normal access login to S1 close autoindex vhosts function vim/usr/local/apache2/ htdocs/index.html S22222222222222 Test 192.168.183.103 4. Restart S Nginx service test P  Kill-hup nginx Test www.sohu.com

"Linux" nginx service configuration

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.