Centos 7 安装 Nginx

安装依赖

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

下载源码并安装

wget https://nginx.org/download/nginx-1.15.8.tar.gz
tar -xzvf nginx-1.15.8.tar.gz
cd nginx-1.15.8
./configure --user=www --group=www
make && make install

修改Nginx配置

mkdir /usr/local/nginx/conf/servers
vim /usr/local/nginx/conf/nginx.conf

在http模块最后添加

include servers/*.conf;

配置环境变量

echo "export PATH=\$PATH:/usr/local/nginx/sbin" >> /etc/profile
source /etc/profile

自启动

echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.local
chmod +x /etc/rc.local

启动、停止Nginx

nginx 
nginx -s stop
nginx -s quit
nginx -s reload

标签: none

添加新评论