Linux下对Nginx手动打包教程

我们在上一篇文章中聊起Nginx自动打包工具,具体参考:nginx免安装包制作工具:nginx-portable,工具始终是工具,我们并不能排除他没有任何问题, 所以在有条件的情况下,我们还是建议手动通过源码编译方式,制作一个免安装的nginx二进制包。

以下操作均在CentOS中测试正常。

安装依赖:

yum install gcc-c++ perl  pcre make wget pcre-devel zlib zlib-devel openssl openssl-devel -y

下载nginx依赖软件包和源码包,并解压:

wget https://www.openssl.org/source/openssl-1.0.2s.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
wget https://zlib.net/zlib-1.2.11.tar.gz
wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar -xvf openssl-1.0.2s.tar.gz && tar -xvf pcre-8.43.tar.gz
tar -xvf zlib-1.2.11.tar.gz && tar -xvf nginx-1.16.1.tar.gz

编译nginx:(编译目录在/root/nginx中,可按需更改)

cd nginx-1.16.1
./configure \
--with-openssl=../openssl-1.0.2s \
--with-pcre=../pcre-8.43 \
--with-zlib=../zlib-1.2.11 \
--with-pcre-jit --user=root \
--prefix=/root/nginx \
--with-http_ssl_module \
--with-http_v2_module

配置过程未报错,进行编译:

make
make install

编译之后nginx将会被安装到“/root/nginx”路径下,Nginx的二进制文件在sbin目录下,配置文件在conf目录下。

将整个nginx目录打包拷贝到目标主机,解压之后就可以使用,具体使用方法参考上一篇文章。

 

» 本文链接:Linux下对Nginx手动打包教程
» 转载请注明来源:刺客博客
» 如果文章失效或者安装失败,请留言进行反馈。