首页 > 代码库 > centos下安装nginx
centos下安装nginx
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_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically 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_moduleoption, or install the zlib library into the system, or build the zlib librarystatically 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 functionsfrom 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
或者
#测试端口[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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。