我使用centos7X64最小化安装 CentOS-7-x86_64-Minimal-1708
关闭防火墙和加入放行端口二选一
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
[root@localhost ~]# firewall-cmd --state
not running
[root@localhost ~]#
firewall-cmd --zone=public --add-port=80/tcp --permanent #添加放行端口(--permanent永久生效,没有此参数重启后失效)
firewall-cmd --reload #刷新防火墙 使其生效
firewall-cmd --zone=public --list-ports #查看防火墙放行端口列表
[root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent #添加放行端口(--permanent永久生效,没有此参数重启后失效)
success
[root@localhost ~]# firewall-cmd --reload #刷新防火墙 使其生效
success
[root@localhost ~]# firewall-cmd --zone=public --list-ports #查看防火墙放行端口列表
80/tcp
[root@localhost ~]#
yum -y install wget
yum install gcc-c++
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
官方查看最新稳定版本 nginx1.12.2官网链接直达 我现在最新稳定版本是:nginx-1.12.2
wget -c https://nginx.org/download/nginx-1.12.2.tar.gz
tar -zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
./configure
make
make install
cd /usr/local/nginx/sbin/
./nginx
./nginx -s reload #重新加载配置文件
./nginx -s quit #:推荐 待nginx进程处理任务完毕进行停止
./nginx -s stop #:先查出nginx进程id再使用kill命令强制杀掉进程。
ps aux|grep nginx
在rc.local增加启动代码就可以了。
vi /etc/rc.local
底部增加一行:
/usr/local/nginx/sbin/nginx
设置执行权限:
chmod 755 /etc/rc.local
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有