Nginx安装(ubuntu下)

这里介绍的是编译安装,开始安装之前需要安装gcc编译环境,ubuntu下可以使用

apt-get install build-essential
apt-get install libtool
一、从网上下载的源码我们放置在/urs/local/src中
二、解压后都放在/usr/local中进行安装
三、接下来需要分别安装
1、安装 zlib1g-dev和libpcre3-dev

apt-get install zlib1g-dev libpcre3-dev -y
2、安装pcre

wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz

tar -xzf pcre-8.21.tar.gz

./configure

make

make install
3、安装openssl

wget http://www.openssl.org/source/openssl-0.0.1c.tar.gz

./config

make

make install
4、安装zlib

wget http://www.zlib.net/zlib-1.2.8.tar.gz

./configure

make

make install
5、下载nginx和编译安装
(1)执行下面编译设置

./configure --prefix=/usr/local/nginx-1.2.3 \

--conf-path=/usr/local/nginx-1.2.3/nginx.conf \

--openssl-path=/usr/local/openssl-1.0.1c \

--with-http_ssl_module \

--with-pcre=/usr/local/pcre-8.21 \

--with-http-stub-status-module

(说明:很多编译安装的说明都没有设置conf-path,但是我没有设置的话,在make install 阶段会出现

cp: `conf/koi-win' and `/usr/local/nginx/conf/koi-win' are the same file错误)
(2)make
(3)make install


编译参数说明:

    --prefix=path —

    Nginx安装路径。如果没有指定,默认为 /usr/local/nginx。

    --sbin-path=path —

    Nginx可执行文件安装路径。只能安装时指定,如果没有指定,默认为<prefix>/sbin/nginx。

    --conf-path=path —

    在没有给定-c选项下默认的nginx.conf的路径。如果没有指定,默认为<prefix>/conf/nginx.conf。

    --pid-path=path —

    指定nginx.pid的文件名,安装后该名字可以在nginx.cong文件中修改。如果没有指定,默认为 <prefix>/logs/nginx.pid。

    --error-log-path=path —

    在nginx.conf中没有指定error_log指令的情况下,默认的错误日志的路径。如果没有指定,默认为 <prefix>/logs/error.log。

    --user=name —

    在nginx.conf中没有指定user指令的情况下,默认的nginx使用的用户。如果没有指定,默认为 nobody。

    --group=name —

    在nginx.conf中没有指定user指令的情况下,默认的nginx使用的组。如果没有指定,默认为 nobody。

    --with-http_ssl_module —

    开启HTTP SSL模块,使NGINX可以支持HTTPS请求。这个模块需要已经安装了OPENSSL

    --with-pcre=path —

    指定PCRE库路径。(PCRE为正则表达式库)

    --with-pcre-jit — builds the PCRE library with “just-in-time compilation” support.

猜你喜欢

转载自liyonghui160com.iteye.com/blog/2099962