Ubuntu 13.04 安装最新版本的Nginx
但是默认在Ubuntu13.04下安装得到的Nginx版本居然是1.2.x,太低了。
下面描述如何获取最新的安装包:
1.添加key
wget http://nginx.org/keys/nginx_signing.key
apt-key add nginx_signing.key
2.创建/etc/apt/sources.list.d/nginx.list文件,内容如下:
deb http://nginx.org/packages/mainline/ubuntu/ raring nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ raring nginx
3.更新及安装:
apt-get update
apt-get install nginx
4.检查一下版本
nginx -v
nginx version: nginx/1.5.0
5. 命令行
前面的安装在/etc/init.d/目录下创建了nginx脚本,该脚本支持几个命令参数:
echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload|upgrade|configtest}" >&2
非常好用。比如测试配置的参数:
service nginx configtest
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
6. 进程id
官方文档说:http://nginx.org/en/docs/control.html
进程id文件默认在
/usr/local/nginx/logs/nginx.pid
但实际上在nginx脚本文件中将其放在了
/var/run/nginx.pid
7. 编译选项,用-V可以查看编译nginx程序编译时的选项:
nginx -V
nginx version: nginx/1.5.0
built by gcc 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_spdy_module --with-ipv6
基本够用,如果要打开debug日志的话,此版本没有。需要自己编译Nginx,并使用下面的参数:
--with-debug