定制化Nginx的输出目标

参考网站:http://heartbeats.jp/hbblog/2012/02/nginx02.html
参考网站:http://heartbeats.jp/hbblog/2012/02/nginx02.html

本次环境:
【linux】CentOS6.2
【nginx】1.2.6

如果不考虑将nginx的输出目录从源代码编译到安装目录,那么像proxy_temp和fastcgi_temp等目录将在${NGINX_ROOT}目录下创建,导致目录结构看起来很凌乱。
而且,将可执行文件、配置文件和其他文件放在不同的目录中,以实现后续版本升级的耐用结构。

${NGINX_ROOT}
   +---1.2.6
       +--sbin
       +--conf
    +---running
        +--logs
        +--html
        +--temp
           +-client_body_temp
           +-proxy_temp
           +-fastcgi_temp
           +-uwsgi_temp
           +-scgi_temp
(デフォルトでは~_tempのディレクトリがlogsとかと一緒の場所に作成されてしまい、
 htmlとかlogsの存在が埋もれてしまいそうになる。)

实际命令如下(在此将${NGINX_ROOT}设为/var/opt/nginx/)

$ tar xzf ./nginx-1.2.6.tar.gz
$ cd ./nginx-1.2.6
$ ./configure --user=nginx --group=nginx \
    --with-http_ssl_module \
    --with-http_random_index_module \
    --with-http_dav_module \
    --without-select_module \
    --prefix=/var/opt/nginx/running \
    --sbin-path=/var/opt/nginx/1.2.6/sbin/nginx \
    --conf-path=/var/opt/nginx/1.2.6/conf/nginx.conf \
    --pid-path=/var/run/nginx.pid \
    --lock-path=/var/lock/subsys/nginx \
    --http-client-body-temp-path=temp/client_body_temp \
    --http-proxy-temp-path=temp/proxy_temp \
    --http-fastcgi-temp-path=temp/fastcgi_temp \
    --http-uwsgi-temp-path=temp/uwsgi_temp \
    --http-scgi-temp-path=temp/scgi_temp
$ make
$ make isntall

也许在./configure阶段会出现以下类似的错误。

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

在那时,没有PRCE库,所以我安装了它后,再运行./configure会很好。

安装完成后,请不要忘记创建目录。

$ mkdir /var/opt/nginx/running/temp

如果以忘记的情况启动,会出现这种错误。(事实上已经出现了。)

nginx: [emerg] mkdir() "/var/opt/nginx/running/temp/client_body_temp" failed (2: No such file or directory)

还需要创建一个专用于nginx目录的用户,并且不要忘记进行安全防护。

bannerAds