Application scenarios

The Linux server that the company needs to deploy cannot connect to the Internet, and nginx needs to be installed. In the LAN of the company, the local computer (Mac) can connect to the Linux server remotely. You need to download the nginx installation package from the local computer and upload it to the server to install it. Some packages may be missing during the installation process.

Download the nginx offline package

Nginx-9.9.tar. gz Mac Upload the offline compressed package to the Linux server. Run the SCP command to upload the package, as shown in the following example

SSH root@ip // Enter the password and press Enter to log in to the remote server successfully. Use SCP to upload the compressed package to the Linux server. SCP/directory /client.zip root@ip:/home/xx directory // Enter the password, press Enter, and wait... Uploaded successfullyCopy the code

The Linux server decompresses the file

Gz => tar -xvf zlib-1.2.11.tar.gz

Initialization and installation

Switch to the installation package path and run the./configure command to initialize the installation. After the command is successfully executed, run make && make install.

Note ⚠ ️ : As it is an Intranet, some packages may be missing after executing the./configure command. As prompted, we download the compressed package from the local PC, upload it to the Intranet server, decompress, initialize and install it, and the initialization is successful only after executing the./configure command without any error. Then run make && make install.

Configuring environment Variables

Check whether the installation is successful

Start the Nginx: / usr/local/Nginx/sbin/Nginx to quote the following error:

1. An error prompt/usr/local/nginx/sbin/nginx: error while loading Shared libraries: libpcre. So. 0: always open a Shared object file: No such file or directory

Input LDD * * (which/usr/local/nginx/sbin/nginx) ∗ ∗ LDD of illness (which/usr/local/nginx/sbin/nginx) * * LDD screen (which/usr/local/nginx/sbin/nginx) ∗ ∗ LDD of illness (which/usr/local/nginx/sbin/nginx)

Prompt missing:

Solutions:

To create a soft connection, run the following command for /lib64/* 64-bit systems: Ln -s/usr/local/lib/libpcre. So. 0 / lib64 build soft after the connection is successful, continue to enter/usr/local/nginx/sbin/nginx test, enter said there is no error after successful installationCopy the code

Enter the server IP address in the address box of the browser. If the following dialog box is displayed, the installation is successful.

The configuration file

Go to CD /usr/local/nginx/conf,

Vim nginx.conf For example: Nginx deployvue project

server { listen 8000; location /{ autoindex on; root /home/project/client; index index.html; try_files $uri $uri/ @router /index.html; add_header Cache-Control "no-cache"; add_header X-Frame-Options SAMEORIGIN; } location @router { rewrite ^.*$ /index.html last; } location /prod-api/{ rewrite ^/prod-api/(.*) /$1 break; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://ip:8080; }}Copy the code

The bag that can’t be found

Unzip unzip client. Zip – bash: unzip: command was not found The solution: offline installer: downloads.sourceforge.net/infozip/unz…

Tar ZXVF unzip552.tar.gz 2. CD unzip-5.52/3. cp Unix /MakefileCopy the code

Start and restart

2.6 Starting and Stopping nginx Commands for starting and stopping nginx

Run./nginx./nginx -s stop to stop./nginx -s quit./nginx -s reloadCopy the code

/nginx nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use) Port 80 is occupied

Solution: Kill the port 80 process and run the following command:

ps -A | grep nginx  
kill -9 pid1 
kill -9 pid2
Copy the code

// After killing the two corresponding processes, start nginx./nginx does not report an error, enter the address in the browser such as: http://ip:8000/ successful deployment