CentOS7 下 nginx 安装配置
安装依赖
1
| yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl--devel
|
下载 nginx
1 2 3 4
| cd /usr/local wget http://nginx.org/download/nginx-1.7.4.tar.gz tar -zxvf nginx-1.7.4.tar.gz cd nginx-1.7.4
|
配置 nginx 安装选项
使用–prefix 参数指定 nginx 安装的目录
1 2
| ./configure ./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx
|
安装
启动、停止、重启
1 2 3
| nginx nginx -s stop nginx -s reload
|
遇到的问题
防火墙端口未开启
1 2 3 4 5 6 7
| systemctl stop firewalld.service
systemctl start firewalld.service netstat -lnpt firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --reload
|