CentOS7下安装Nginx
一.准备环境
首先由于nginx的一些模块依赖一些lib库,所以在安装nginx之前,必须先安装这些lib库,这些依赖库主要有g++、gcc、openssl-devel、pcre-devel和zlib-devel 所以执行如下命令安装
yum install gcc-c++
yum install pcre pcre-devel
yum install zlib zlib-devel
yum install openssl openssl--devel
二.下载并解压
wget http://nginx.org/download/nginx-1.13.0.tar.gz
tar -zxvf nginx-1.13.0.tar.gz
mv nginx-1.13.0 /usr/local/nginx
三.安装
cd /usr/local/nginx
./configure
make
四.启动
/usr/local/nginx/sbin/nginx
如果启动有这个问题
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
2017/05/27 10:36:33 [emerg] 15424#0: open() "/usr/local/nginx/logs/access.log" failed (2: No such file or directory)
mkdir /usr/local/nginx/logs
五.添加变量
vi ~/.bash_profile
添加下面这条
PATH=$PATH:/usr/local/nginx/sbin
然后
source ~/.bash_profile
六.常用命令
nginx -s stop
nginx -s reload
nginx -c file_path //设置conf路径
网友评论