安装兼容包;

yum install -y pcre pcre-devel openssl openssl-devel


#下载 Nginx 源码包

cd /usr/src ;wget -c http://nginx.org/download/nginx-1.4.2.tar.gz


#解压 Nginx 源码包

tar -xzf nginx-1.4.2.tar.gz


#进入解压目录,然后 sed 修改 Nginx 版本信息为 WS

cd nginx-1.4.2 ; sed -i -e 's/1.4.2//g' -e 's/nginx\//WS/g' -e

's/"NGINX"/"WS"/g' src/core/nginx.h


#预编译 Nginx

useradd www ;./configure --user=www --group=www --prefix=/usr/local/nginx --with-

http_stub_status_module --with-http_ssl_module


#.configure 预编译成功后,执行 make 命令进行编译

make


#make 执行成功后,执行 make install 正式安装

make install


#自此 Nginx 安装完毕

/usr/local/nginx/sbin/nginx -t 检查 nginx 配置文件是否正确, 返回 OK 即正确。

[root@localhost ~]# /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

[root@localhost ~]#


然后启动 nginx,/usr/local/nginx/sbin/nginx 回车即可。查看进程是否已启动:

[root@localhost ~]# ps -ef |grep nginx

nobody 5381 30285 0 May16 ? 00:04:31 nginx: worker process

root 30285 1 0 2014 ? 00:00:00 nginx: master process

/usr/local/nginx/sbin/nginx

root 32260 32220 0 12:34 pts/0 00:00:00 grep nginx

[root@localhost ~]#