当前位置: > CentOS教程 > 软件安装教程 >

Centos6.9编译安装httpd2.4

时间:2017-10-10 01:52来源:blog.csdn.net 作者:ZhaoYang93 举报 点击:

环境: 
centos6.9 
apr-1.6.2.tar.gz 
apr-util-1.6.0.tar.gz 
httpd-2.4.27.tar.bz2


一、安装开发包组

[root@CentOS6 /app]$ yum groupinstall "Development tools"
[root@CentOS6 /app]$ yum install openssl-devel pcre-devel expat-devel

二、下载并解压软件包

[root@CentOS6 /app]$tar xvf apr-1.6.2.tar.gz    
[root@CentOS6 /app]$tar xvf apr-util-1.6.0.tar.gz
[root@CentOS6 /app]$tar xvf httpd-2.4.27.tar.bz2

三、编译安装  1) apr

[root@CentOS6 /app]$cd apr-1.6.2
[root@CentOS6 /apr-1.6.2]$./configure --prefix=/app/apr
[root@CentOS6 /apr-1.6.2]$make -j 4 & make install

2) apr-util

[root@CentOS6 /app]$cd /app/apr-util-1.6.0 
[root@CentOS6 /apr-util-1.6.0]$./configure --prefix=/app/apr-util --with-apr=/app/apr
[root@CentOS6 /apr-util-1.6.0]$make -j 4 & make install

3) httpd2.4  ① 创建账户

[root@CentOS6 /app]$useradd -r -d  /app/website -s /sbin/nologin apache  

② 编译安装

[root@CentOS6 /app]$cd /app/httpd-2.4.27
[root@CentOS6 /httpd-2.4.27]$./configure --prefix=/app/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/app/apr/ --with-apr-util=/app/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
[root@CentOS6 /httpd-2.4.27]$make -j 4 & make install

四、配置  1) 配置httpd服务

[root@CentOS6 /httpd-2.4.27]$vim /app/httpd24/conf/httpd.conf
user apache
group apache
Documentroot /app/website
<directory /app/website>

2) 配置PATH变量

[root@CentOS6 /httpd-2.4.27]$vim /etc/profile.d/httpd24.sh
export PATH=/app/httpd24/bin:$PATH

3) 配置服务脚本

[root@CentOS6 /httpd-2.4.27]$vim /etc/init.d/httpd24
apachectl=/app/httpd24/bin/apachectl
httpd=${HTTPD-/app/httpd24/bin/httpd}
pidfile=${PIDFILE-/app/httpd24/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}

4) 添加服务脚本并设置开机启动

[root@CentOS6 /app]$chkconfig --add httpd24
[root@CentOS6 /app]$chkconfig  --list httpd24
httpd24         0:off   1:off   2:off   3:off   4:off   5:off   6:off
[root@CentOS6 /app]$chkconfig httpd24 on

5) 创建主站点文件夹并启动服务

[root@CentOS6 /app]$mkdir /app/website
[root@CentOS6 /app]$echo /app/website/index.html > /app/website/index.html
[root@CentOS6 /app]$service httpd24 start
[root@CentOS6 /app]$ss -tnl|grep 80
LISTEN     0      128                      :::80                      :::*

五、测试

[root@CentOS6 /app]$curl 172.18.46.6
This is a test web page

------分隔线----------------------------
发表评论
为了和诣的生活,我关闭了评论页面,请大家到QQ群里交流吧:348944156,也欢迎关注本站微信公众号:centoscn