源码安装步骤:1、找包 2、配置环境 3、上传包 4、解压包 5、进入到对应目录 6、指定安装路径 7、编译 8、安装
源码包安装不会解决依赖关系,在安装过程中缺少了依赖包会提示错误,无法安装,此时需要先把缺少的依赖包安装好,再回来安装之前的源码包。
Httpd2.4版本相对坑比较多,对于刚学源码包安装是一个不错的练习案例
1、找httpd2.4包,进行上传到/tmp下
2、按章源码包环境:yum -y install gcc make openssl-devel pcre pcre-devel zlib-devel
3、解压 :tar xf httpd-v2.4.41.tar.gz tar命令一般解压.tar.gz结尾的文件。
4、进入到解压文件目录: cd httpd-2.4.41/
5.指定安装目录:/configure --prefix=/usr/local/httpd
[[email protected] httpd-2.4.41]# ./configure --prefix=/usr/local/httpd
checking for chosen layout… Apache
checking for working mkdir -p… yes
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking build system type… x86_64-pc-linux-gnu
checking host system type… x86_64-pc-linux-gnu
checking target system type… x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library…
configure:
checking for APR… no
configure: error: APR not found. Please read the documentation.
提示缺少APR包
6、回到tmp目录下,找APR包,上传到/tmp目录下,解压文件,进入到apr包解压目录下
7、指定安装目录:[[email protected]alhost apr-1.6.5]# ./configure --prefix=/usr/local/apr
红色箭头指的是命令,绿色箭头指的是安装过程
8、编译和安装apr : make && make install
红色箭头表示先编译,没有问题就安装,绿色箭头表示安装过程。
9、安装完apr以后回到httpd-2.4.41目录下,再次指定httpd安装位置
[[email protected] httpd-2.4.41]# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr/
此处两个地方注意,第一就是目录必须回到httpd-2.4.41目录下,第二个就是httpd依赖于apr,要把他们两个关联上,用–with-apr=/usr/local/apr/ 把他们两个关联起来。
此处需要注意的地方都用箭头标注。绿色箭头那提示APR-util没有发现,说明httpd安装还要依赖于apr-util。
10、下载apr-util包,上传到/tmp目录下,解压,进入到解压后目录下
11、指定apr-util安装路径 :./configure --prefix=/usr/local/apr-util
该命令执行需要注意两点用红色箭头标记,一定要在apr-util-1.6.1目录下。绿色箭头提示结果是apr-util安装依赖于apr,需要将apr于apr-util关联起来
12、将apr与apr-util关联起来:./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
此处还是两处需要注意,红色箭头的目录位置要对和绿色箭头的关联要对
13、编译:make
编译结果报错,找不到expat.h这个文件找不到。网上搜索这个文件,缺少依赖包expat-devel,直接安装
14、安装expat-devel包:yum -y install expat-devel
15、编译和安装:make && make install
16、依赖包都安装完了,现在重新进入到httpd-2.4.4目录下,下面所有操作都在该目录下。
17、指定安装位置,将apr和apr-util都关联到httpd上:./configure --prefix=/src/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
此处三处注意,执行目录一定要是httpd-2.4.41下,还有两处关联
18、编译:make
提示错误
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory /usr/local/httpd-2.4.33/support' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory/usr/local/httpd-2.4.33/support’
make: *** [all-recursive] Error
遇到报错不用着急,刚开始遇到错误就网上查找一下解决办法,遇到多了,自己就知道怎么解决
这个错误解决办法: 将解压好的apr和apr-util复制到解压好的httpd下的srclib目录下,重新编译
cp -r /tmp/apr-1.6.5 srclib/apr
cp -r /tmp/apr-util-1.6.1 srclib/apr-util
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-included-apr
19、重新编译和安装:make && make install
20、启动apache:/usr/local/httpd/bin/apachectl
红色箭头表示启动命令,蓝色箭头指的地方报错,提示servername需要修改。
解决办法修改/usr/local/httpd/conf/httpd.conf文件,将里面#ServerName localhost:80注释去掉就好了。
21、重新启动服务:/usr/local/httpd/bin/apachectl restart
22、查看httpd进程:ps aux | grep "httpd"
红色箭头指的就是httpd进程。
23、也可以查看80端口状态:lsof -i:80
查看80端口,被监听,说明服务启动成功。
以上仅供参考,每个人环境不一样,装同样的内容可能报错不一样,遇到报错不要紧张,直接网络搜索报错信息就可以。解决错误多了,自己就知道怎么解决