系统环境:CentOS-6.3 软件:nginx-1.2.6.tar.gz
安装方式:源码编译安装
安装位置:/usr/local/nginx
下载地址:http://nginx.org/en/download.html
在安装nginx前,需要确保系统安装了g++、gcc、openssl-devel、pcre-devel和zlib-devel软件。安装必须软件:
[root@admin /]#yum install gcc-c++ yum -y install zlib zlib-devel openssl openssl--devel pcre pcre-devel
检查系统安装的Nginx:
[root@admin local]# find -name nginx ./nginx ./nginx/sbin/nginx ./nginx-1.2.6/objs/nginx
卸载原有的Nginx
[root@admin /]# yum remove nginx
安装前先升级ssl:http://www.0597seo.com/post/2629.html
将安装包文件上传到/usr/local中执行以下操作:
[root@admin local]# cd /usr/local
[root@admin local]# tar -zxv -f nginx-1.2.6.tar.gz
[root@admin local]# rm -rf nginx-1.2.6.tar.gz
[root@admin local]# mv nginx-1.2.6 nginx
[root@admin local]# cd /usr/local/nginx
[root@admin nginx]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-openssl=指定源码包所在的路径
[root@admin nginx]# make
[root@admin nginx]# make install
配置
#修改防火墙配置: [root@admin nginx-1.2.6]# vi + /etc/sysconfig/iptables #添加配置项 -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #重启防火墙 [root@admin nginx-1.2.6]# service iptables restart
#方法1 [root@admin nginx-1.2.6]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#方法2 [root@admin nginx-1.2.6]# cd /usr/local/nginx/sbin [root@admin sbin]# ./nginx
#查询nginx主进程号 ps -ef | grep nginx
#停止进程 kill -QUIT 主进程号
#快速停止 kill -TERM 主进程号
#强制停止 pkill -9 nginx
[root@admin local]# /usr/local/nginx/sbin/nginx -s reload
#测试端口 netstat –na|grep 80 #浏览器中测试 http://ip:80
三. 安装过程中出现的问题
1.pcre :/configure: error: no acceptable C compiler found in $PATH See `config.log' for more details
原因是没装gcc
解决办法:yum install gcc
2../configure :checking for C++ compiler default output file name... configure: error: C++ compiler cannot create executables See `config.log' for more details.
原因是由于c++编译器的相关package没有安装
解决办法:yum install gcc-c++
3.pcre:make时报错:[pcrecpp.lo] Error 1
原因是由于c++编译器的相关package没有安装
解决办法:yum install gcc-c++,重新configure,make && make install通过。
4../configure: error: the HTTP rewrite module requires the PCRE library
原因是需要PCRE library
解决办法:yum -y install pcre-devel
5../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.
原因是需要OpenSSL library
解决办法:yum -y install openssl openssl-devel
文章来源:http://www.cnblogs.com/zhoulf/archive/2013/02/09/2909653.html
发表评论