自己编译安装软件,需要经历以下步骤:
检查编译环境——>准备编译环境(需要依赖很多的第三方软件)——>编译——>安装——>使用
- 配置文件:Makefile
- 编译,安装命令:make
编译安装,现在有个名词,叫模块化。模块越多,代码越多,bug也就越多。
下面会以编译安装nginx的案例来说明!
编译安装nginx
下载源码
首先需要我们把tomcat、jdk、nginx三个压缩安装包通过xftp传送至节点。
解压
执行以下命令,得到tengine源码(x撕毁,f文件)
tar xf tengine-2.1.0.tar.gz
进入到源码目录:
cd tengine-2.1.0
查看README
进入README,执行 /install命令查看相关安装命令。打开configure里面有安装提示,configure一般支持 configure --help
./configure:创建Makefile
这里开始尝试执行 ./configure命令,会有一些提示信息:
[root@node1 tengine-2.1.0]# ./configure
checking for OS
+ Linux 2.6.32-642.el6.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
安装gcc:
yum install -y gcc
经过短暂的等待,安装好了gcc。重新执行命令 ./configure,还是会有提示信息:
//省略了N多行......
./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.
缺少pcre,可以通过yum来搜索pcre:
yum search pcre
安装确实的pcre,执行以下命令,并在提示中给出y的指令:
yum install pcre-devel
再次执行./configure命令,提示还缺少东西:
//省略了N行...
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
根据刚才pcre的经验,我直接安装openssl-devel,并给出指令y:
yum install openssl-devel
一切就绪后,重新执行./configure !
接下来编译:
make
执行make install新建目录、文件夹、拷贝目录:
make install
历经艰难,终于安装好了:
去到nginx目录下,看到有个sbin目录,sbin下还有个nginx:
最后,我们执行 ./nginx 启动外部server检验(80端口不写也行):
最后
尽量不要使用编译安装,太麻烦了…