nginx-1.12.0安装

1.配置相关环境:

yum install -y gcc glibc gcc-c++ zlib pcre-devel openssl-devel

rewrite模块需要pcre库
ssl功能需要openssl库
gzip模块需要zlib库

2.创建nginx用户

useradd -s /sbin/nologin -M www

-M 不创建家目录

3.进入用户级源码目录并下载nginx源码

www.nginx.org


cd /usr/local/src
wget http://nginx.org/download/nginx-1.12.0.tar.gz

4.解压源码包并进入nginx目录、

tar xzvf nginx-1.12.0.tar.gz
cd nginx-1.12.0/

5.执行./configure脚本检查环境,生成安装规则文件makefile

./configure --prefix=/usr/local/nginx-1.12.0 --user=www --group=www  --with-http_ssl_module --with-http_stub_status_module

--with-http_stub_status_module 状态模块,用于监控nginx

6.根据makefile文件编译安装

make && make install

7.创建软连接

ln -s /usr/local/nginx-1.12.0/ /usr/local/nginx

8.查看80端口是否被占用

netstat -ntlp

9.编辑配置文件/usr/local/nginx/conf/nginx.conf

vim /usr/local/nginx/conf/nginx.conf

location 用于匹配统一资源标识符(URI)

10.进行配置文件测试

/usr/local/nginx/sbin/nginx -t

11.启动nginx

/usr/local/nginx/sbin/nginx

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

猜你喜欢

转载自www.cnblogs.com/Peter2014/p/11640744.html
今日推荐