Nginx file path: /usr/local/nginx

Have no legal power into the folder operation can get super authority: execute the command sudo su nginx nginx configuration file. The conf path: / usr/local/nginx/conf/nginx. Conf by vim editor to edit the configuration file: Vim nginx.conf:

server { listen 9080; Server_name localhost; Localhost #root /home/flatform/dist/; // you can omit #index index.html index.htm; // you can omit #charset koi8-r; #access_log logs/host.access.log main; /home/flatform/dist; // The root /home/flatform/dist file is displayed in /home/flatform/dist. index index.html index.htm; try_files $uri $uri/ /index.html; // The history route must be added with the add_header access-control-allow-origin *; } location/API / {// Same as the local project code configuration, use/API/to proxy cross-domain proxy_pass http://10.10.208.83:8093; Rewrite/API (.*) $1 break; }}Copy the code

Check whether the port number is occupied after the configuration:

Sudo netstat anp | grep port numberCopy the code

Check whether nginx configuration is normal and whether nginx is running successfully:

Go to the nginx directory CD /usr/local/nginx/sbin and run./nginx -tCopy the code

Run nginx successfully if OK and SUCCESS are present. Nginx start:

Go to the nginx directory CD /usr/local/nginx/sbin and run start nginxCopy the code

Restart the nginx:

Go to the nginx directory CD /usr/local/nginx/sbin and run./ NGNX -s reloadCopy the code

After configuring the nginx.conf configuration file, check that there are no problems and start or restart nginx to access the project.

If restarting Nginx does not enable normal access to your project, you can restart Nginx by killing the process that occupies your port number. Here are the issues AND solutions I encountered while deploying the project:

1, Linux restart failure message:

[alert] kill(12034, 1) failed (3: No such process)  
Copy the code

Restart Linux by entering either of the following commands:

Method 1: / usr/local/nginx/sbin/nginx - c/usr/local/nginx/conf/nginx. Conf method 2: / usr/local/nginx/sbin/nginx -s reloadCopy the code

2. Linux looks for processes that occupy a port and kills them

You can run the following command to view the processes that occupy a port

Lsof -i:XXXX(port number)Copy the code

You can kill a process by using the following command

Kill -9 XXXX (Process ID)Copy the code