Nginx

Nginx summary

Nginx It’s a High performance The reverse proxy server for .
And tomcat similar , But it’s more powerful 、 Higher performance .
Powerful concurrency 、50000 Number of concurrent connections .
I won’t support it java , Use java Programs can only be done with tomcat coordination .

Nginx Characteristics

Reverse proxy
Load balancing
Dynamic and static separation

Reverse proxy

 Insert picture description here
 Insert picture description here

Load balancing

 Insert picture description here

Dynamic and static separation

 Insert picture description here

Nginx install

Upload the required files linux Under the /opt/nginx-tool Next  Insert picture description here

install gcc gc++ Environmental Science

  • yum install gcc
  • yum install gc++( If it fails, execute the following command , Successfully skipped )
  • yum install gcc-c++ -y

install pcre Depend on the environment

Enter into /opt/nginx-tool/ Under the table of contents

tar -zxvf pcre-8.37.tar.gz
Go to the unzip Directory
cd pcre-8.37
Executable files
./configure
stay pcer Directory execution
make && make install

openssl Environmental Science 、nginx Installation and above pcre It’s the same as the installation of , however openssl The executive file for is config
Nginx Fixed installation directory of /usr/local/nginx

Turn off firewall

Temporarily Closed
systemctl stop firewalld
Permanent ban
systemctl disable firewalld

Nginx Start of

Enter into nginx Installation directory sbin Under the table of contents

cd /usr/local/nginx/sbin

perform ./nginx

./nginx

You can enter the virtual machine in the local browser ip add :80 Test for successful startup (nginx The default port number for is 80)
 Insert picture description here

Nginx Installation directory

 Insert picture description here
1、sbin: operation nginx Command file
2、conf: nginx The configuration file nginx.conf
3、html: visit nginx Page display content
4、logs: nginx Related content of

Nginx Configuration file for

Three components
 Insert picture description here

Configure reverse proxy -1

Realization : Use nginx Reverse proxy , visit www.123.com Jump directly to 127.0.0.1:8080

Premise :jdk Environmental Science

1、 Enter into linux in tomcat Under the installation directory of bin Directory execution

./startup.sh

 Insert picture description here
2、 modify windows Systematic hosts file

Add a line to the file :192.168.6.99 www.123.com
 Insert picture description here
 Insert picture description here

3、 modify nginx The configuration file completes the implementation 、 No input 8080 Port number , Direct access through domain name

 Insert picture description here  Insert picture description here
4、 Restart nginx

Shut down first nginx
 Insert picture description here
perhaps
 Insert picture description here

Again

./nginx

test
 Insert picture description here

The execution process of entering the domain name by the browser

 Insert picture description here

Configure reverse proxy -2

analysis
 Insert picture description here

1、 Prepare two tomcat, The port numbers are 8080、8081, Respectively in tomcat Under the webapps Create directories and pages under
 Insert picture description here
 Insert picture description here
2、 stay nginx Configure the reverse proxy in the configuration file

nginx Configuration file for :/usr/local/nginx/conf Under the nginx.conf
 Insert picture description here
Be careful : Don’t forget to restart nginx service , There are two tomcat And don’t forget to start

First in /usr/local/nginx/sbin perform ./nginx -s stop And then execute ./nginx

test
 Insert picture description here
 Insert picture description here

 Insert picture description here

Configure load balancing

1、 Prepare two tomcat, All in tomcat The next webapps Create under directory edu/index.html
2、 modify nginx The configuration file
 Insert picture description here
test
 Insert picture description here
 Insert picture description here

Configure dynamic and static separation

 Insert picture description here

test
 Insert picture description here

 Insert picture description here
summary :
 Insert picture description here

Read more here: Source link