14_ LNMP deployment environment, build platforms LNMP, address rewriting

10.10.11.10 Proxy
Client 10.10.11.11
web1 10.10.11.12
web2 10.10.11.13
 
1. deployment environment LNMP
1.1 deployment Nginx (previously deployed)
1.2 deployment MariaDB
Proxy] -Y # yum the install MariaDB MariaDB MariaDB-devel-Server
Proxy] # Start MariaDB systemctl
Proxy] # systemctl enable MariaDB
Proxy] # MySQL
1.3 deployment PHP
] -Y # yum the install MySQL PHP PHP-PHP-FPM
] systemctl Start # PHP-FPM
] # PHP-FPM systemctl Status
] # PHP-FPM enable systemctl
 
2. Construction LNMP platform
2.1 viewing php-fpm configuration file (experiments do not need to modify the file)
Proxy] # vim /etc/php-fpm.d/www.conf
[the WWW]
the listen = 127.0.0.1:9000 // PHP port number
pm.max_children = 32 // maximum number of processes
pm.start_servers = 15 // minimum number of processes
pm.min_spare_servers = 5 // need at least a few of the idle process
pm.max_spare_servers = 32 // Maximum number of idle processes
2.2 modify the php page Nginx configuration file support, and start service
Proxy] # Vim /etc/nginx/conf.d/default.conf
LOCATION / {
        the root / usr / Share / Nginx / HTML;
        index the index.php index.html index.htm;
    }
...
LOCATION ~ \. $ {PHP
        root / usr / report this content share / nginx / HTML; # absolute path
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $ DOCUMENT_ROOT $ fastcgi_script_name;
        the include fastcgi_params;
    }
] # nginx -s reload

2.3 Creating PHP test page , and then query the database MariaDB
Proxy] # vim /usr/share/nginx/html/test.php
<PHP?
    ; phpinfo ()
?>

Client test:
Client] # http://10.10.11.10/test.php Firefox
 
3. Address Rewriting (proxy )
3.1 modify the configuration file (a.html redirects access to b.html)
] # Vim /etc/nginx/conf.d/default.conf
...
server_name www.a.com;
  the rewrite /a.html / B. HTML;
...
] # nginx -s reload
] # echo "aaa"> /usr/share/nginx/html/a.html
] # echo "bbb"> /usr/share/nginx/html/b.html
Client test:
] # Firefox 10.10.11.10/a.html
] # 10.10.11.10/b.html Firefox

3.2 access a.html redirected to b.html (jump address bar)
] # vim /etc/nginx/conf.d /default.conf
...
server_name www.a.com;
   /a.html /b.html the redirect the rewrite;
...
] # -s reload Nginx
Client Test:
] # 10.10.11.10/a.html Firefox

3.3 modify the configuration file (10.10.11.10 redirect requests to access www.baidu .com)
] # Vim /etc/nginx/conf.d/default.conf
...
server_name www.a.com;
  the rewrite ^ / http://www.baidu.com/;
...
] -s # Nginx reload

Client test:
] # 10.10.11.10 Firefox

3.4 modify the configuration file (access 192.168.4.5/ the following sub-pages, redirects to www.baidu.com/ the same page)
] # vim /etc/nginx/conf.d/ default.conf
...
server_name www.a.com;
  rewrite ^ / $ http://www.baidu.com/$1; (*.)
...
] # nginx -s reload

lient test:
] # Firefox 10.10. 11.10 / a.html

3.5 modify the configuration file (and Firefox to access the page curl to achieve the same return link different)
] # Echo "the I AM Page Normal"> /usr/share/nginx/html/test.html
] # mkdir -p / usr / Share / Nginx / HTML / Firefox /
] # echo "Firefox Page"> / usr / Share /nginx/html/firefox/test.html
] # Vim /etc/nginx/conf.d/default.conf
...
LOCATION / {
   the root HTML;
   index the index.php index.html index.htm;
    }
 
IF ($ HTTP_USER_AGENT Firefox * ~) {
             
    . the rewrite ^ (*) $ / Firefox / $. 1;
    }
...
] # -s reload Nginx

Client test:
] Firefox http://10.10.11.10/test.html #
] # curl HTTP: / /10.10.11.10/test.html
**********************
address rewrite format [summary]
rewrite the old address of the new address [options];
Last no longer read other rewrite
BREAK no longer read other statements, the end of the request
redirect temporary redirect
permament permanent redirects
**********************

Guess you like

Origin www.cnblogs.com/luwei0915/p/12152707.html
Recommended