Article directory
Download the Nignx installation package
Click download on the right
to select the version you want to download (I chose 1.14.2)
Preparation before installation
1. Is the gcc compiler installed?
#检查是否安装:
yum list installed | grep gcc
#安装:
yum install gcc -y
2. Whether the openssl library is installed
#检查是否安装:
yum list installed | grep openssl
#安装:
yum install openssl openssl-devel -y
3. Is the pcre library installed?
#检查是否安装:
yum list installed | grep pcre
#安装:
yum install pcre pcre-devel -y
4. Is the zlib library installed?
#检查是否安装:
yum list installed | grep zlib
#安装:
yum install zlib zlib-devel -y
One-time install command
yum install gcc openssl openssl-devel pcre pcre-devel zlib zlib-devel -y
Upload the installation package to Linux
I am using Xftp 7 to upload files
decompress
Unzip the ngnix file
tar -zxvf nginx-1.14.2.tar.gz -C /opt
After decompression, go to the nginx home directory, and then execute
#指定安装目录,=号两边没有空格
./configure --prefix=/opt/nginx
then execute make
Then execute make install
Installation is complete
Open firewall ports
Check firewall open ports
firewall-cmd --list-all
Set an open port (nginx default port is 80)
sudo firewall-cmd --add-port=80/tcp --permanent
restart firewall
firewall-cmd --reload
Start the Nignx service
Switch to the sbin directory of the nginx installation directory to execute
./nginx
About 403Forbidden
If 403Forbodden appears, you can modify the configuration file
of nginx. 1. Go to the conf directory under the nginx installation directory.
2. Use the vim nginx.conf command to modify the configuration file
. 3. Configure the running user of the worker to be root
. 4. Save :wq
. restart nginx
./nginx -s reload