码迷,mamicode.com
首页 > 其他好文 > 详细

centos下安装nginx

时间:2014-11-02 18:00:26      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   os   sp   div   

1、下载稳定版本的nginx. http://nginx.org/en/download.html

2、按照如下命令安装

#检查系统路径
[root@localhost usr]# pwd
/usr

#解压到当前路径
[root@localhost usr]# tar -zxv -f nginx-1.6.2.tar.gz 

#删除压缩包
[root@localhost usr]# rm -rf nginx-1.6.2.tar.gz 

#进入到解压包下
[root@localhost usr]# cd nginx-1.6.2/

[root@localhost nginx-1.6.2]# 

#指定安装路径
[root@localhost nginx-1.6.2]# ./configure --prefix=/usr/local/nginx

#编译
[root@localhost nginx-1.6.2]# make

#安装
[root@localhost nginx-1.6.2]# make install

#回退到解压缩包上级目录
[root@localhost usr]# cd ../

#解除解压缩包
[root@localhost usr]# rm nginx-1.6.2 -rf

3、安装缺少包提示

错误提示 ./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

解决方案

[root@localhost nginx-1.6.2]# yum -y install pcre-devel
错误提示 ./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

解决方案
[root@localhost nginx-1.6.2]# yum install -y zlib-devel
错误提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.   You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.

解决方案
[root@localhost nginx-1.6.2]# yum  -y install openssl openssl-devel

4、修改防火墙配置:

#修改防火墙配置:
[root@localhost nginx]# vi + /etc/sysconfig/iptables

#添加配置项

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

#重启防火墙
[root@localhost nginx]# service iptables restart

5、启动nginx

#方法1
[root@localhost nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 

#方法2
[root@localhost nginx]# cd /usr/local/nginx/sbin [root@admin sbin]# ./nginx

6、查看nginx是否启动

[root@localhost nginx]# netstat -ntlp

bubuko.com,布布扣

或者

#测试端口
[root@localhost nginx]# netstat –na|grep 80

#浏览器中测试
http://ip:80

 附录:

#查询nginx主进程号
[root@localhost sbin]# ps -ef | grep nginx

#停止进程
[root@localhost sbin]# kill -QUIT 主进程号

#快速停止
[root@localhost sbin]# kill -TERM 主进程号

#强制停止
[root@localhost sbin]# pkill -9 nginx

转载请注明出处:[http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html]

centos下安装nginx

标签:style   blog   http   io   color   ar   os   sp   div   

原文地址:http://www.cnblogs.com/dennisit/p/4069521.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!