Setup the Nginx server

[root@localhost opt]# tar -xf lnmp_soft.tar.gz

// Release the source package

[root@localhost opt]# yum -y install gcc pcre-devel openssl-devel

// GCC is a dependency package of nginx; Pcre-devel allows nginx to support regex; Openssl-devel can support secure encrypted websites

[root @ localhost nginx - 1.12.2] #. / configure -- with - http_ssl_module

// Add security modules at compile time

[root@localhost nginx-1.12.2]# make && make install

/ / installation

[root@localhost nginx]# sbin/nginx

// Start the service

[root@localhost nginx]# ss -ntulp |grep nginx tcp LISTEN 0 128 *:80 *:* users:(("nginx",pid=3953,fd=6),("nginx",pid=3952,fd=6))

// Check whether the port is successfully enabled

test

[root@localhost nginx]# systemctl stop firewalld

// Close the protective wall

// Enter the local IP address in the browser, you can see the test page of nginx, which is successful


Install database and PHP services

[root@localhost nginx]# yum -y install mariadb mariadb-server mariadb-devel

// Install the database service

[root@localhost nginx]# yum -y install php php-mysql php-fpm

// Install the PHP service

[root@localhost nginx]# vim conf/nginx.conf

// Modify the configuration file to enable dynamic page parsing

65 location ~ \.php$ { 66 root html; 67 fastcgi_pass 127.0.0.1:9000; 68 fastcgi_index index.php; 69 # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; 70 include fastcgi.cof; 71}

[root@localhost nginx]# systemctl restart mariadb

// Start the Mariadb service

[root@localhost nginx]# ss -ntulp | grep :3306 tcp LISTEN 0 50 *:3306 *:* users:(("mysqld",pid=4815,fd=14))

// Check whether the port is enabled properly

// Enable the php-fpm service

[root @ localhost nginx] # ss - ntulp | grep PHP - FPM TCP LISTEN 0 128 127.0.0.1: : 9000 * * users:(("php-fpm",pid=4864,fd=0),("php-fpm",pid=4863,fd=0),("php-fpm",pid=4862,fd=0),("php-fpm",pid=4861,fd=0),("php-fpm ",pid=4860,fd=0),("php-fpm",pid=4858,fd=6))

// Check whether the port is enabled properly

[root@localhost nginx]# sbin/nginx -s reload

// Reload the configuration file

After the configuration is complete, perform the page test

You can copy the dynamic page to the/HTML directory and enter the address in the browser to access the PHP page


Application of database

Create a DC user and refresh the page

[root@localhost nginx]# mysql // enter the MariaDB monitor. or \g. Your MariaDB connection id is 2 Server version: 5.5.56-MariaDB MariaDB Server Copyright (C) 2000, 2017, Oracle, MariaDB Corporation Ab and Others. Type 'help; ' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> create user dc@localhost identified by '123'; Query OK, 0 rows affected (0.00 SEC)Copy the code

Implement address rewriting in Nginx
[root@localhost nginx]# vim conf/nginx.conf // Modify configuration filesCopy the code
35 server { 36 listen 80; 37 server_name localhost; 38. Rewrite /a.html /b.html // this means that a user can jump to B.HTML from any url that contains a.HTMLCopy the code
Realize users in different environments to access different pages of the jump function
35 server { 36 listen 80; 37 server_name localhost; 38 # rewrite /a.html /b.html redirect 39 # rewrite ^/(.*)$ http://www.test.com/$1; Rewrite ^(.*)$/firefox/$1 42}. * indicates case insensitive; Everything in the parentheses indicates that the following jump page should be executed when the user is found to be using FirefoxCopy the code