./configure
#可以指定安装路径,启用或者禁用功能等,最终生成makefile
make
#按Makefile文件编译
make install
#按Makefile定义的文件路径安装
make clean
#清除上一次make命令所产生的object文件,要重新执行
configure时,需要执行make clean。
4.2以简单安装nginx为例
下载nginx tar包
[root@localhost ~]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
[root@localhost ~]# ll nginx-1.12.2.tar.gz
-rw-r--r--. 1 root root 981687 Oct 21 2018 nginx-1.12.2.tar.gz
解压安装包
[root@localhost ~]# tar xf nginx-1.12.2.tar.gz
[root@localhost nginx-1.12.2]# ./configure
[root@localhost nginx-1.12.2]# make && make install
不指定路径默认编译的路径
[root@localhost ~]# ls /usr/local/nginx/
conf html logs sbin
4.3解决编译依赖问题
编译nginx未安装依赖库报错
./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 library
解决方法1:
进入/mnt/Packages
[root@localhost Packages]# ls pcre*
pcre-8.32-15.el7.x86_64.rpm pcre-devel-8.32-15.el7.x86_64.rpm
[root@localhost Packages]# ls *pcre*
pcre-8.32-15.el7.x86_64.rpm pcre-devel-8.32-15.el7.x86_64.rpm
[root@localhost Packages]# ls *pc* #上两步找不到,则匹配一半
[root@localhost Packages]# ls *re*
安装
[root@localhost Packages]# rpm -ivh pcre-devel-8.32-15.el7.x86_64.rpm###一般只需要安装名字带有devel的包
解决方法2:
[root@localhost ~]# yum search pcre