各位用户为了找寻关于nginx安装到指定目录的方法示例的资料费劲了很多周折。这里教程网为您整理了关于nginx安装到指定目录的方法示例的相关资料,仅供查阅,以下为您介绍关于nginx安装到指定目录的方法示例的详细内容
公司需求,需要在同一台机器上装两个不同位置的 nginx。what!我之前都是直接装在 /user/local/ 下的啊, 或者 yum install nginx 装在 /etc/nginx 啊,这怎么办
经过我的一番寻找终于看到的一些靠谱的答案。
? 1 2 3 4 5 6 7 8 9 10 11 12 13./configure
--prefix=你想要安装的目录
--sbin-path=/你想要安装的目录/nginx
--conf-path=/你想要安装的目录/nginx.conf
--pid-path=/你想要安装的目录/nginx.pid
--with-http_ssl_module
--with-pcre=/usr/local/pcre-8.38
--with-zlib=/usr/local/zlib-1.2.11
--with-openssl=/usr/local/openssl-1.0.1t
make && make install
test -d
我的理解
这是源码编译安装 ngixn,./configure 这一步是给 nginx 设置一些常量。而 --prefix 则是设置编译后到处 nginx 执行文件的地址。
现在网上虽然也有些教程但是也有很多已经老了,有些包找不到了。那我就把我这此安装的步骤分享出来
nginx 安装到自定义位置
先安装 pcre
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14cd
/usr/local/
# 下载
wget
ftp
:
//ftp
.csx.cam.ac.uk
/pub/software/programming/pcre/pcre-8
.38.
tar
.gz
# 解压
tar
-zxvf pcre-8.38.
tar
.gz
cd
pcre-8.38
.
/configure
# 编译
make
&&
make
install
# 记住这个安装目录一会儿会用到
# /usr/local/pcre-8.38
其次是 zlib
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14cd
/usr/local/
# 下载
wget http:
//www
.zlib.net
/zlib-1
.2.11.
tar
.gz
# 解压
tar
-zxvf zlib-1.2.11.
tar
.gz
cd
zlib-1.2.11
.
/configure
# 编译
make
&&
make
install
# 记住这个安装目录一会儿会用到
# /usr/local/zlib-1.2.11
ssl 这个不用编译,简单
? 1 2 3 4 5 6cd
/usr/local/
wget https:
//www
.openssl.org
/source/openssl-1
.0.1t.
tar
.gz
tar
-zxvf openssl-1.0.1t.
tar
.gz
# 记住这个安装目录一会儿会用到
# /usr/local/openssl-1.0.1t
现在安装 Nginx
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24cd
/usr/local
#下载解压
wget http:
//nginx
.org
/download/nginx-1
.4.2.
tar
.gz
tar
-zxvf nginx-1.4.2.
tar
.gz
# 注意:这只是源码
cd
nginx-1.4.2
# 设置常量
.
/configure
--prefix=/自定义位置/
--sbin-path=/自定义位置
/nginx
--conf-path=/自定义位置
/nginx
.conf
--pid-path=/自定义位置
/nginx
.pid
--with-http_ssl_module
--with-pcre=
/usr/local/pcre-8
.38
# 刚刚安装的 pcre 的位置
--with-zlib=
/usr/local/zlib-1
.2.11
# 刚刚安装的 zlib 的位置
--with-openssl=
/usr/local/openssl-1
.0.1t
#刚刚安装的 openssl 的位置
# 编译
make
&&
make
install
# 重要:如果不执行则不会创建真正的 nginx 文件
test
-d
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://segmentfault.com/a/1190000017273078