Ubuntu 从官方源安装 Nginx
cd ~ wget http://nginx.org/keys/nginx_signing.key sudo apt-key add nginx_signing.key sudo nano /etc/apt/sources.list # 添加以下两句 deb http://nginx.org/packages/ubuntu/ precise nginx deb-src http://nginx.org/packages/ubuntu/ precise nginx sudo apt-get update sudo apt-get install nginx
Ubuntu 从PPA源安装 Nginx :
sudo add-apt-repository ppa:nginx/stable sudo apt-get update sudo apt-get install nginx
Ubuntu 从常规源安装 Nginx :
sudo apt-get install nginx
编译安装Nginx
wget http://nginx.org/packages/mainline/ubuntu/pool/nginx/n/nginx/nginx_1.5.7-1~precise_i386.deb wget http://nginx.org/download/nginx-1.5.7.tar.gztar xzf nginx-1.5.7.tar.gzcd nginx-1.5.7
(注意:Nginx1.5.7是Mainline版而非Stable版)
为了方便开发和管理,我在根目录下新建了一个png目录,并且目录所有者设置为当前用户,nginx就编译在/png/nginx/1.5.7下面:
sudo mkdir /pngsudo chown eechen:eechen /png
运行用户我定义为png:png,所以我需要新建这样一个用户:
sudo addgroup png --systemsudo adduser png --system --disabled-login --ingroup png --no-create-home --home /nonexistent --gecos "png user" --shell /bin/false
(新建用户的命令可以参考官方Deb包里的预安装脚本DEBIAN/preinst)
编译参数参考了Nginx官方提供的Deb包(nginx -V可见).
./configure /
--prefix=/png/nginx/1.5.7 /--sbin-path=/png/nginx/1.5.7/sbin/nginx /--conf-path=/png/nginx/1.5.7/conf/nginx.conf /--error-log-path=/png/nginx/1.5.7/var/log/error.log /--http-log-path=/png/nginx/1.5.7/var/log/access.log /--pid-path=/png/nginx/1.5.7/var/run/nginx.pid /--lock-path=/png/nginx/1.5.7/var/run/nginx.lock /--http-client-body-temp-path=/png/nginx/1.5.7/var/cache/client_temp /--http-proxy-temp-path=/png/nginx/1.5.7/var/cache/proxy_temp /--http-fastcgi-temp-path=/png/nginx/1.5.7/var/cache/fastcgi_temp /--http-uwsgi-temp-path=/png/nginx/1.5.7/var/cache/uwsgi_temp /--http-scgi-temp-path=/png/nginx/1.5.7/var/cache/scgi_temp /--user=png /--group=png /--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-ipv6
注意:这一步按错误提示安装依赖的包,这时就是apt要发威的时候了,比如我的系统安装了这些包:
sudo apt-get -y install /
build-essential /autoconf /libtool /libxml2 /libxml2-dev /openssl /libcurl4-openssl-dev /libbz2-1.0 /libbz2-dev /libjpeg-dev /libpng12-dev /libfreetype6 /libfreetype6-dev /libldap-2.4-2 /libldap2-dev /libmcrypt4 /libmcrypt-dev /libmysqlclient-dev /libxslt1.1 /libxslt1-dev /libxt-dev /libpcre3-dev
新闻热点
疑难解答