Not much to say, just go to the tutorial
One: Install dependencies
Enter the command: yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
Two: Download the nginx installation package
Enter the command: wget http://nginx.org/download/nginx-1.24.0.tar.gz
to download with the command, or copy it to the server after downloading from the official website. If wget is not installed, you can install it with yum first
yum install wget
Three: Unzip, configure, and install nginx
Find the compressed package you just downloaded. If you need to re-specify the directory, you can use the mv command to move the installation package to the specified location. If not, just decompress it.
Unzip the nginx compressed package, enter the command: tar zxf nginx-1.24.0.tar.gz
to enter the nginx root directory, enter the command: cd nginx-1.18.0
configure nginx, enter the command: ./configure
compile && install, enter the command: make&&make install
Four: Start nginx for testing
Switch to the default installation path of nginx, enter the command: cd /usr/local/nginx/sbin
to start nginx, enter the command: ./nginx
test, enter the command: curl http://localhost:80, if some html code comes out Indicates success. If the port is occupied or there is a firewall, it can be solved by configuring or adding a port to the firewall.
Five: Modify nginx proxy configuration
Run vim /usr/local/nginx/conf/nginx.conf to add or modify server inside
Six: nginx restart
Start service command: /usr/local/nginx/sbin/nginx
Stop service command: /usr/local/nginx/sbin/nginx -s stop
Restart service command: /usr/local/nginx/sbin/nginx -s reload
View local ip: ip addr
Seven: other issues
If you encounter errors such as "/usr/bin/yum ", line 30 e, it is most likely caused by the upgrade of python. It is recommended to modify the yum configuration to a lower version
and then upgrade. And there are many similar commands that have such problems, basically downgrading the version and then upgrading. Of course, this is just what I have encountered, so I will say it by the way. For specific problems, you can do it yourself, and Google can solve it