Installing Nginx Using the One-Click Script
One-click scripts include compilation, deployment, and optimization scripts. The following describes how to install Nginx 1.14.2 on CentOS 7.6 using the one-click script. You can also refer to this section to install Nginx of other versions.
Table 1 lists the Nginx versions and OS versions that can be installed using the one-click script.
|
Software Version |
Whether to Support CentOS 7.6 |
Whether to Support CentOS 8.1 |
Whether to Support openEuler 20.03 (LTS-SP1) |
|---|---|---|---|
|
Nginx 1.14.2 |
Yes |
Yes |
No |
|
Nginx 1.19.3 |
Yes |
No |
No |
Obtaining the One-Click Script
- Download the one-click script for Nginx using the local browser.
Download addresses:
- Nginx 1.14.2 (CentOS 7.6):
https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/web/Scripts/nginx_automation.tar.gz
- Nginx 1.14.2 (CentOS 8.1):
https://repo.huaweicloud.com/kunpeng/archive/kunpeng_solution/web/Scripts/nginx-1.14.2-install.sh
- Nginx 1.19.3 (CentOS 7.6):
https://repo.huaweicloud.com/kunpeng/archive/kunpeng_solution/web/Scripts/nginx-1.19.3-install.sh
- Nginx 1.14.2 (CentOS 7.6):
- Upload the one-click script to the /home directory.
If the server is connected to the Internet, you can run the wget command on the server to download the one-click script. The following describes how to download the one-click script of Nginx 1.14.2 by using the wget command on CentOS 7.6. To download the one-click script of other Nginx versions, replace the download link of the one-click script as required:
1 2
cd /home/ wget https://mirrors.huaweicloud.com/kunpeng/archive/kunpeng_solution/web/Scripts/nginx_automation.tar.gz --no-check-certificate
Running the One-Click Script (for Nginx 1.14.2 on CentOS 7.6)
- Decompress the one-click script.
1tar -xzvf nginx_automation.tar.gz

- Go to the nginx_automation directory and run the ls command to query the files in the directory.
1 2
cd nginx_automation ll

Table 2 describes the overall one-click script directory structure.
Table 2 Overall one-click script directory structure Folder or File
Description
deps directory
Directory used for compilation and installation.
NOTE:The installer script obtains the OpenSSL and Nginx source code using the wget command. If the server cannot access the Internet, download the source code (see Installing Nginx by Compiling Source Code) and save the source code to this directory.
scripts directory
Directory in which the general tuning script, Nginx configuration optimization script, and the script for binding NIC interrupts to cores are stored.
install.sh
Script used to implement one-click compilation, deployment, and tuning of Nginx.
rollback.sh
Script used to roll back all operations performed by install.sh.
startNginx.sh
Script for starting the Nginx instance.
- Configure the network ports in the environment.
- Open the install.sh file.
1vim install.sh - Press i to enter the insert mode. Find the eth0, eth1, eth2, and eth3 parameters and enter the network interface names of the current environment. Find the sense parameter and enter the current test scenario based on the comments.
- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open the install.sh file.
- Run the install.sh script. After the script is executed, restart the server for the settings to take effect.
1sh install.sh
The settings about the binding between NIC interrupts and CPU cores will be invalid after the server is restarted. Therefore, add the settings in the /etc/profile file, which enables the command for binding NIC interrupts to cores to run each time the server restarts.
- Run the startNginx.sh script to start Nginx.
1sh startNginx.sh - Check the Nginx process.
1ps -ef | grep nginx

- The current one-click script contains the commands for running and verifying Nginx. After this step is performed, you do not need to perform the Running Nginx and Verifying Nginx operations.
- If the one-click script fails to be executed or the environment needs to be rolled back, run the following script to roll back: After the rollback script is executed, restart the server.
1sh rollback.sh
Running the One-Click Script (for Nginx 1.19.3 on CentOS 7.6 or Nginx 1.14.2 on CentOS 8.6)
In the following commands, 1.14.2 indicates the Nginx version. When installing another version, replace 1.14.2 with the actual version.
- Execute the one-click installation script.
sh nginx-1.14.2-install.sh
- Check whether the Nginx installation is successful.
ls /usr/local/nginx
