原文地址:
http://blog.csdn.net/duck_genuine/article/details/6760893
http://www.ligaofeng.com/?p=1107
ubuntu11.04编译安装nginx1.0.5
http://www.ligaofeng.com/?p=1107
1、 PCRE库的安装:
官网:http://www.pcre.org/
下载页面:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
选择最新版本下载:
1 2 3 4 5 | #wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz #tar zxvf pcre-8.12.tar.gz #cd pcre-8.12 #./configure –prefix=/usr/local/pcre #make && make install |
2、 OpenSSL库的安装
官网:http://www.openssl.org
下载页面:http://www.openssl.org/source/
选择最新版本下载:
1 2 3 | #wget http://www.openssl.org/source/openssl-1.0.0d.tar.gz #tar zxvf openssl-1.0.0d.tar.gz #mv openssl-1.0.0d openssl |
zlib安装
http://www.zlib.net/
1 2 3 4 | #wget http://www.gzip.org/zlib/zlib-1.2.3.tar.gz #./configure #make #make install |
2、ngnix安装
选择最新版本下载:
1 2 3 4 5 6 7 8 9 | #groupadd nginx #useradd -r -g nginx nginx #wget http://nginx.org/download/nginx-1.0.5.tar.gz #tar zxvf nginx-1.0.5.tar.gz #cd nginx-1.0.5 #sudo ./configure --prefix=/usr/local/nginx --with-openssl=/usr/local/openssl/ --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --user=nginx --group=nginx #sudo make #sudo make install |
修改/usr/local/nginx/conf/nginx.conf配置文件后,用命令/usr/local/nginx/sbin/nginx -t 检查配置文件是否正确
如果报:
./nginx: error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
错误而导致nginx不能启动,可用:
ln -s /usr/local/lib/libpcre.so.0 /usr/lib/libpcre.so.0
解决。
4、启动及停止nginx的命令
1 2 | #/usr/sbin/nginx #/usr/sbin/nginx -s stop |
也可通过向nginx进程发送信号来停止nginx
步骤1:查询nginx主进程号
ps -ef | grep nginx
在进程列表里面找master进程,它的编号就是主进程号了。
步骤2:发送信号
从容停止Nginx:
kill -QUIT 主进程号
快速停止Nginx:
kill -TERM 主进程号
强制停止Nginx:
pkill -9 nginx
参考信息:http://wiki.nginx.org/NginxChsInstallOptions
遇到的问题:
没有nginx,logs目录访问权限
nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
2014/03/30 22:34:22 [emerg] 12209#0: open() "/usr/local/nginx/logs/nginx.pid" failed (13: Permission denied)
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
解决办法:
- sudo chmod a+rwx -R logs
- sudo chmod a+rwx -R /usr/local/nginx
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed