1、首先进入nginx解压目录,
执行命令
./configure --prefix=/usr/local/nginx/ --add-module=/usr/local/share/fastdfs-nginx-module/src --with-pcre=/usr/local/share/pcre-8.39 --with-zlib=/usr/local/zlib-1.2.8 --with-openssl=/usr/local/openssl-1.0.1t --with-http_ssl_module
然后用make && make install 编译
但是报错如下:
make[1]: Entering directory `/root/nginx-0.7.61'
cd /server/openssl \make: *** [build] Error 2
问题来了,为什么会这样呢,首先分析
./configure --prefix=/usr/local/nginx/ --add-module=/usr/local/share/fastdfs-nginx-module/src --with-pcre=/usr/local/share/pcre-8.39 --with-zlib=/usr/local/zlib-1.2.8 --with-openssl=/usr/local/openssl-1.0.1t --with-http_ssl_module
这个命令中指出需要安装的模块有:
fastdfs-nginx-module,指定目录/usr/local/nginx/,引用/usr/local/share/pcre-8.39按准过包
with-http_ssl_module 制定目录/usr/local/nginx/ ,引用zlib-1.2.8、openssl-1.0.1t
这个命令实际上很有问题,如果要装with-http_ssl_module,如需要增加ssl,必须将md5和openssl装上,废话不说,直接是正确的命令
./configure --prefix=/usr/local/nginx/ --add-module=/usr/local/share/fastdfs-nginx-module/src --with-pcre=/usr/local/share/pcre-8.39 --with-zlib=/usr/local/share/zlib-1.2.11 --with-md5=/root --with-http_ssl_module --with-openssl=/usr/local/share/openssl-0.9.8t
重点:
--with-zlib=/usr/local/share/zlib-1.2.11 --zlib的解压目录,不是编译目录
--with-openssl=/usr/local/share/openssl-0.9.8t --openssl-0.9.8t的解压目录,不是编译目录,
然后再make && make install 成功
ps:普及下linxu下面的一个命令
在Linux上编译安装软件时,经常遇到./configure –prefix=usr这个命令。./configure –prefix 是什么意思呢?下面简单介绍一下./configure –prefix 的用法。
源码的安装一般由有这三个步骤:配置(configure)、编译(make)、安装(make install)。
Configure是一个可执行脚本,它有很多选项,在待安装的源码路径下使用命令./configure –help输出详细的选项列表。
其中–prefix选项就是配置安装的路径,如果不配置该选项,安装后可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc,其它的资源文件放在/usr /local/share,比较分散。
为了便于集中管理某个软件的各种文件,可以配置–prefix,如:
./configure –prefix=/usr/local
可以把所有资源文件放在/usr/local的路径中,就不会分散了。
用了—prefix选项的另一个好处是卸载软件或移植软件。当某个安装的软件不再需要时,只须简单地删除该安装目录,就可以把软件卸载得干干净净;移植软件只需拷贝整个目录到另外一个机器即可(相同的操作系统)。
当然要卸载程序,也可以在原来的make目录下用一次make uninstall,但前提是make文件指定过uninstall。