Apache2.4.43源码安装
一、检查系统中是否安装过apache软件:
rpm -qa httpd
如果发现需要删除:
rpm -e httpd
二、预安装软件:
yum -y install gcc gcc++ zlib zlib-devel
三、下载apache安装相关的软件包:
APR 1.6.5
APR-UTIL 1.6.1
Pcre 8.00
Httpd-2.4.43
四、开始安装:
1.APR1.6.5安装
$tar -xzvf apr-1.6.5.tar.gz -C /usr/src
#解压到指定目录/usr/src下
$cd /usr/src/apr-1.6.5
$./configure --prefix=/usr/local/apr
$make&&make install
2.APR-util安装
$tar -xzvf apr-util-1.6.1.tar.gz -C /usr/src
#解压到指定目录/usr/src下
$cd /usr/src/apr-util-1.6.1
$./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
$make&&make install
3.Pcre安装
$tar -xzvf pcre-8.00.tar.gz -C /usr/src
#解压到指定目录/usr/src下
$cd /usr/src/pcre-8.00
$./configure --prefix=/usr/local/pcre
$make&&make install
4.Httpd安装
$tar -xzvf httpd-2.4.43.tar.gz -C /usr/src
#解压到指定目录/usr/src下
$cd /usr/src/httpd-2.4.43
$./configure \
--prefix=/usr/local/httpd \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--with-pcre=/usr/local/pcre \
--enable-so \
--enable-rewrite \
--enable-ssl \
--enable-cgi \
--enable-module=most \
--enable-mods-shared=most \
--enable-mpms-shared=all \
--with-mpm=event \
--enable-cgid \
--enable-proxy \
--enable-proxy-fcgi \
--enable-expires \
--enable-deflate \
$make&&make install
5.启动apache服务
$cd /usr/local/httpd/bin
$./apachectl start
6.设置开机自启动服务控制脚本
#apache start
/usr/local/httpd/bin/apachectl start
#apache stop
/usr/local/httpd/bin/apachectl stop
#让apache随系统启动自启动
#echo "/usr/local/httpd/bin/apachectl start" >> #/etc/rc.local
#把apache加入到系统服务
#首先以apachectl脚本为模板生成apache服务控制脚本:
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
#编辑/etc/init.d/httpd,在文件第二行插入下面的行,使其支 持chkconfig命令:
#!/bin/sh
# chkconfig: 2345 85 15
# description: Apache is a World Wide Web server.
...
#为apache服务控制脚本添加执行权限:
chmod +x /etc/init.d/httpd
#将apache服务加入到系统服务:
chkconfig httpd on
#检查apache服务是否生效:
chkconfig --list httpd
如果命令输出如下结果则表明apache服务已经生效:
httpd0:off 1:off 2:on 3:on 4:on 5:on 6:of
上面表明apache在2、3、4、5系统运行级别随系统启动而自启动。
以上如果全部成功后,可以用service命令控制apache的启动和停止。
$systemctl start httpd
$systemctl stop httpd