nginx-1.12.0安装

###1.配置相关环境:nginx

<pre> yum install -y gcc glibc gcc-c++ zlib pcre-devel openssl-devel </pre>c++

rewrite模块须要pcre库 ssl功能须要openssl库 gzip模块须要zlib库 ###2.建立nginx用户vim

<pre> useradd -s /sbin/nologin -M www </pre>测试

-M 不建立家目录 ###3.进入用户级源码目录并下载nginx源码 www.nginx.orgip

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

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

<pre> tar xzvf nginx-1.12.0.tar.gz cd nginx-1.12.0/ </pre>get

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

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

--with-http_stub_status_module 状态模块,用于监控nginx ###6.根据makefile文件编译安装

<pre> make && make install </pre>

###7.建立软链接

<pre> ln -s /usr/local/nginx-1.12.0/ /usr/local/nginx </pre>

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

<pre> netstat -ntlp </pre>

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

<pre> vim /usr/local/nginx/conf/nginx.conf </pre>

location 用于匹配统一资源标识符(URI) ###10.进行配置文件测试

<pre> /usr/local/nginx/sbin/nginx -t </pre>

###11.启动nginx

<pre> /usr/local/nginx/sbin/nginx </pre>

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

相关文章
相关标签/搜索