登录 用户中心() [退出] 后台管理 注册
   
您的位置: 首页 >> SoftHub关联区 >> 主题: nginx linux 下编译步骤[自定义配置目录]     [回主站]     [分站链接]
nginx linux 下编译步骤[自定义配置目录]
clq
浏览(638) - 2017-09-23 12:20:14 发表 编辑

关键字: nginx

[2017-09-23 12:30:06 最后更新]

nginx linux 下编译步骤[自定义配置目录]

因为 linux 上很可能是已经有了 nginx 的,所以不能直接 make install,应当想办法安装到自己的目录下.


1.
先下载源码
http://nginx.org/download/nginx-1.12.1.tar.gz

#解压到当前路径
# tar -zxv -f nginx-1.6.2.tar.gz

2.
这个是指定安装路径的,可以不要
#指定安装路径
[root@localhost nginx-1.6.2]# ./configure --prefix=/usr/local/nginx

3.
centos 上可能没安装 gcc,用以下命令安装
    
yum -y install gcc
yum -y install gcc-c++
yum install make
 
-- 或者
yum groupinstall "Development Tools"
 
-- 或者
yum install gcc gcc-c++ kernel-devel

4.
 ./configure
命令后提示
 PCRE library
错误,那就经安装
yum -y install pcre-devel

同理还有以下可能要安装:
yum install -y zlib-devel

5.
编译后会显示配置路径
Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

6.
编译的默认路径可以用命令查看
nginx -V

7.
config 成功后可用 make 编译出 nginx 程序,生成在 /root/setup_bak/nginx_cdn/nginx-1.12.1/objs
但是其配置是指明在 "/usr/local/nginx/conf/nginx.conf" ,如何修改呢?

./configure --prefix=/usr/local/nginx 是可以,但是太固定了,参照 windows 的
configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= -
-conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access
.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-te
mp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fast
cgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsg
i-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msv
c8/lib/pcre-8.41 --with-zlib=objs.msvc8/lib/zlib-1.2.11 --with-select_module --w
ith-http_v2_module --with-http_realip_module --with-http_addition_module --with-
http_sub_module --with-http_dav_module --with-http_stub_status_module --with-htt
p_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_s
tatic_module --with-http_auth_request_module --with-http_random_index_module --w
ith-http_secure_link_module --with-http_slice_module --with-mail --with-stream -
-with-openssl=objs.msvc8/lib/openssl-1.0.2l --with-openssl-opt=no-asm --with-htt
p_ssl_module --with-mail_ssl_module --with-stream_ssl_module

修改为:
./configure -conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp
但在当前最新稳定版本的 nginx-1.12.1 中不支持,所以直接把路径前的 "/" 去掉就可以了,这样会以当前路径作为查找起点.即:
./configure --prefix=usr/local/nginx

8.
nginx 的程序名其实也可以改,不过那样要修改一个 .h 的源代码,所以还是算了.
实际上直接复制出另外一个名称的程序就可以了,已经测试过,并且用 kill-9 nginx 不会再被杀死

9.
要自定义目录那就不能 make install, make 后自己将生成的 nginx 文件和配置文件等复制到自己喜欢的目录就行了,另外为了好管理进程及服务,最好是将生成的
nginx 改一下名称.

--------------------------------------------------
看不懂或者不愿看以上步骤的同学请移步到 "SoftHub" 区直接下载编译好的版本 :)




总数:0 页次:1/0 首页 尾页  
总数:0 页次:1/0 首页 尾页  


所在合集/目录
nginx 更多



发表评论:
文本/html模式切换 插入图片 文本/html模式切换


附件:



NEWBT官方QQ群1: 276678893
可求档连环画,漫画;询问文本处理大师等软件使用技巧;求档softhub软件下载及使用技巧.
但不可"开车",严禁国家敏感话题,不可求档涉及版权的文档软件.
验证问题说明申请入群原因即可.

Copyright © 2005-2020 clq, All Rights Reserved
版权所有
桂ICP备15002303号-1