Linux install nginx
1 installation
1.1Nginx website
nginx.org/
1.2 Online Download
Select the file path to download
Command download:
Wget HTTP: / / http://nginx.org/download/nginx-1.19.10.tar.gzCopy the code
1.3 Decompressing Files
The tar - XVF nginx - 1.19.10. Tar. GzCopy the code
1.4 Changing the file name
Nginx-source file is the source file directory, not the working directory, is used to install the main nginx service.
The mv nginx - 1.19.10 nginx - sourceCopy the code
1.5 Run the./configure command to verify the program
./configure
Copy the code
1.6 Instruction: make compiles the program
make
Copy the code
1.7 Make Install Install the Nginx server
make install
Copy the code
1.8 Checking the nginx directory
whereis ngins
Copy the code
The 1.9 Linux Nginx start
Requirements:
cd /usr/local/nginx/sbin
Copy the code
Linux starts the nginx command
./nginx
Copy the code
restart
./nginx -s reload
Copy the code
Shut down
./nginx -s stop
Copy the code
Windows starts the nginx command
start nginx
Copy the code
restart
nginx -s reload
Copy the code
Shut down
nginx -s stop
Copy the code
2 the deployment
2.1 Front-end Deployment
Upload the vUE compiled dist directory to /usr/local/nginx on Linux
cd /usr/local/nginx
Copy the code
2.2 Configuring the Nginx Front-end Reverse Proxy
Enter the nginx conf file
cd /usr/local/nginx/conf
Copy the code
Nginx. conf is a configuration file. Configure information in the configuration file. Description of reverse proxy: Domain name: web.jt.com Proxy is a directory dist (HTML/CSS /js) domain name: manage.jt.com proxy is a cluster 8091/8092 domain name: Image.jt.com proxies the /usr/local/src/images directory to modify the nginx.conf configuration file
vim nginx.conf
Copy the code
Server {listen 80; server_name web.jt.com; location / { root dist; index index.html; Upstream tomcats {server 192.168.126.122:8091; Server 192.168.126.129:8092; } server { listen 80; server_name manage.jt.com; Location / {proxy_pass http://tomcats; }} # listen server {listen 80; server_name image.jt.com; location / { root /usr/local/src/images; }}Copy the code
2.3 Modifying windos HOSTS files
Address in C: \ Windows \ System32 \ drivers \ etc \ hosts
Host file contents #IP domain name mapping # Image server domain name #127.0.0.1 image.jt.com 192.168.126.129 Image.jt.com # Background server domain name #127.0.0.1 manage.jt.com 192.168.126.129 manage.jt.com #127.0.0.1 manage.jt.com #127.0.0.1 localhostCopy the code
The hosts file is used to change the access address to the corresponding IP address on Windows