1、环境的安装。
参考(http://www.nginx.cn/install 。http://www.2cto.com/os/201108/100296.html)网站的步骤安装。
1、gcc,g++直接apt-get install 或 rpm -i 安装
2、zlib。pcre直接apt-get install或 rpm -i 安装,
在编译nginx时执行./configure --prefix=/usr/local/nginx --user=nginx --group=nginx
后有如下错误
Configuration summary
+ PCRE library is not found
+ OpenSSL library is not used
+ md5 code is not used
+ sha1 library is not found
+ zlib library is not found
则下载zlib。pcre源码
1、./configure
2、make
3、make install
在次执行./configure --prefix=/usr/local/nginx --user=nginx --group=nginx 会有这样的信息
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library
3、安装openssl,这个版本能用(
openssl-1
.0.1c.
tar
.gz)有的版本在nginx编译时会出现某些头文件找不到的问题。
4、安装nginx
.
/configure
--sbin-path=
/usr/local/nginx/nginx
--conf-path=
/usr/local/nginx/nginx
.conf
--pid-path=
/usr/local/nginx/nginx
.pid
--with-http_ssl_module
--with-pcre=
/usr/local/src/pcre-8
.21 //pcre源码包路径
--with-zlib=
/usr/local/src/zlib-1
.2.7 //zlib源码包路径
--with-openssl=
/usr/local/src/openssl-1
.0.1c //openssl源码包路径
make
make install
2、运行和停止nginx
1、输入命令useradd -M -s /sbin/nologin nginx 否则运行nginx会出错
2、/usr/local/nginx/sbin/nginx -t 启动nginx,有可能ps -aux 查看不到nginx已启动。
这时用/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 启动nginx
3、停止nginx/usr/local/nginx/sbin/nginx -s stop