surroundings:
Linux version: CentOS7 64 bit
[Yum install the latest version of nginx: https://www.cnblogs.com/xxoome/p/7256214.html ]
Before installing nginx, make sure that gcc, pcre-devel, zlib-devel, and openssl-devel are installed in the system .
Installation command:
yum -y install gcc pcre-devel zlib-devel openssl openssl-devel
nginx download address: https://nginx.org/download/
Create a folder for easy management
mkdir software
Download "nginx-1.12.2.tar.gz" and move to /root/software.
安装: 解压 tar -zxvf nginx-1.12.2.tar.gz 进入nginx目录 重命名 mv nginx-1.12.2 nginx 切换到 cd nginx
配置 ./configure --prefix=/usr/local/nginx 安装 # make make make install
OK, now you can execute make.
Execute make, make install commands
Test whether the installation is successful
# cd到刚才配置的安装目录/usr/loca/nginx/
./sbin/nginx -t
Information output under normal conditions:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
Start nginx
cd /usr/local/nginx/sbin ./nginx //启动nginx
Nginx accesses port 80 by default, and you need to confirm whether it can be used after startup.
Because the linux system version I use is CentOS7, I can execute the following command in the server to verify the port 80 situation
firewall-cmd --query-port=80/tcp
Obviously port 80 is not open.
Next we open port 80:
firewall-cmd --add-port=80/tcp --permanent
#重启防火墙
systemctl restart firewalld
--permanent #Permanent effect, invalid after restart without this parameter
For personal learning and use, the firewall can be turned off for convenience.
Permanently turn off the firewall
systemctl disable firewalld
chkconfig iptables off
Refresh browser
Configured!
Configure nginx to start automatically
vim /etc/rc.d/rc.local