CentOS7 下 Nginx1.13.7 安装

软件环境:centos7_x64 nginx-1.13.7

一、安装依赖软件

yum -y install gcc gcc-c++ autoconf automake make

yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel


二、安装nginx

//下载软件

wget http://nginx.org/download/nginx-1.13.7.tar.gz

//解压

tar zxvf nginx-1.13.7.tar.gz

//创建安装目录

mkdir -p /usr/local/nginx

//修改配置

cd nginx-1.13.7/

在编译的时候 需要配置 ssl支持

./configure --prefix=/usr/local/nginx --with-http_ssl_module  

如果不需要,则用下面命令

./configure --prefix=/usr/local/nginx  

//安装

make && make install


三、启动

进入安装目录

cd /usr/local/nginx/sbin

启动

./nginx    

这时候在安装机器就可以输入地址查看了。

如果远程访问的话需要关闭防火墙或者将80端口开放,添加新端口后需要reload 防火墙。

关闭防火墙:

CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。

systemctl stop firewalld.service #停止firewall

systemctl disable firewalld.service #禁止firewall开机启动

firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)


开放端口:

添加  firewall-cmd --zone=public --add-port=80/tcp --permanent    (--permanent永久生效,没有此参数重启后失效)

重新载入 firewall-cmd --reload

查看 firewall-cmd --zone= public --query-port=80/tcp

删除 firewall-cmd --zone= public --remove-port=80/tcp --permanent


输入地址后出现如下表示安装成功了。

修改配置文件:

cd /usr/local/nginx/conf 进入目录

vim nginx.conf 打开文件

重新加载nginx

/usr/local/nginx/sbin/nginx -s reload




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值