转载自:http://hi.baidu.com/guanliyangy/item/a5a632279645b087af48f5c7
1、首先下载安装包 nginx.org/en/download.html
2、#tar -xvzf nginx-1.5.3.tar.gz
3、#./configure
4、编译的时候如果报错,说缺少pcre库,那我们安装它。则进行如下两部操作
#yum -y install openssl openssl-devel
#yum -y install pcre-devel openssl openssl-devel
5、在#./configure
6、#make
7、#make install
8、(方法1)启动nginx # /usr/local/nginx/sbin/nginx -s reload,如果报错:nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
原因是在logs下面没有nginx.pid
解决办法:
#/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
(方法2)检查是否安装成功
cd /usr/local/nginx/sbin
./nginx -t
结果显示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
启动nginx
cd /usr/local/nginx/sbin 目录下面 输入 ./nginx 启动 nginx
9、重新启动# /usr/local/nginx/sbin/nginx -s reload
10、查看进程是否启动成功# ps -ef|grep nginx
11、杀掉nginx #killall nginx