Nginx
Table of Contents
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
Load balancing
Dynamic and static separation
Nginx install
Upload the required files linux Under the /opt/nginx-tool Next
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)
Nginx Installation directory
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
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
2、 modify windows Systematic hosts file
Add a line to the file :192.168.6.99 www.123.com
3、 modify nginx The configuration file completes the implementation 、 No input 8080 Port number , Direct access through domain name
4、 Restart nginx
Shut down first nginx
perhaps
Again
./nginx
test
The execution process of entering the domain name by the browser
Configure reverse proxy -2
analysis
1、 Prepare two tomcat, The port numbers are 8080、8081, Respectively in tomcat Under the webapps Create directories and pages under
2、 stay nginx Configure the reverse proxy in the configuration file
nginx Configuration file for :/usr/local/nginx/conf Under the nginx.conf
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
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
test
Configure dynamic and static separation
test
summary :
Read more here: Source link