您的位置:首页 > 理论基础 > 计算机网络

CentOS 6 安装,配置 httpd-2.4详解

2016-05-22 12:41 573 查看
实验主机IP 172.18.254.37 ,此时httpd程序版本为2.2.15,apr,apr-util版本均为1.3.9。





主要思路:要想此主机应用httpd-2.4,要编译安装httpd-2.4,升级apr,apr-util版本为1.4+

安装详解:
1、安装开发环境包组和开发程序包
# yum groupinstall "Development Tools" "Server Platform Development" -y //开发环境包组
# yum install pcre-devel -y //开发程序包

# service httpd stop // 停掉httpd服务,确保一会安装httpd-2.4不会覆盖原有安装配置
# chkconfig httpd off // 关闭开机自动启动
2、下载源码包(这里以本地ftp服务器下载)
# lftp 172.16.0.1/pub
> cd Sources/sources/httpd
> ls





> mget apr-1.5.0.tar.bz2 apr-util-1.5.3.tar.bz2 httpd-2.4.10.tar.bz2

3、编译安装 (apr-util依赖apr,所以先安装apr)
a)编译安装apr
# tar xf apr-1.5.0.tar.bz2
# cd apr-1.5.0
# ./configure --prefix=/usr/local/apr //rpm安装apr默认路径在/usr下,为区分此处装在/usr/local下
# make && make install
# ls /usr/local/apr //查看安装文件是否生成
bin build-1 include lib
b) 编译安装apr-util
# cd
# tar xf apr-util-1.5.3.tar.bz2
# cd apr-util-1.5.3
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make -j 3 && make install
# ls /usr/local/apr-util/
bin include lib
c) 编译安装 httpd-2.4
# cd
# tar xf httpd-2.4.10.tar.bz2
# cd httpd-2.4.10
# ./configure --prefix=/usr/local/apache24 --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

//sysconfdir=/etc/httpd24 指定配置文件安装位置

//enable-so 支持动态共享模块(DOS),如果没有这个模块PHP将无法与apache结合工作
//enable-ssl 支持ssl功能
// enable-cgi支持cgi
//enable-rewrite 支持URL重写
//enable-modules=most 启用哪些模块
//enable-mpms-shared=all 支持多道处理模块
//with-mpm=prefork 设定默认模块为prefork模块
//with-zlib 支持压缩库,便于页面压缩后的发送和接收,互联网传播时可节约带宽
//with-pcre 支持cre扩展的正则表达式,支持更强大的正则表达式分析功能

# make && make install
# make -j 4 && make install

4、验证httpd-2.4服务

# apachectl
# hash





# ls /usr/local/apache24/bin





# /usr/local/apache24/bin/apachectl start
# ss -tnl





配置详解:
如何直接使用apachectl,而不是使用全路径进行httpd2.4的服务器控制??????

1、可以通过改变PATH环境变量的方法进行设置(只对当前shell和子shell生效,重启shell后无效)

# export PATH=/usr/local/apache24/bin:$PATH
# echo $PATH
/usr/local/apache24/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

2、编辑配置文件(全局有效且重启shell后依然有效)
# vim /etc/profile.d/httpd24.sh
export PATH=/usr/local/apache24/bin:$PATH //添加内容

只改配置文件,环境变量不会立即生效,但是对新登录的用户有效,然后新用户登录进行验证




重新用原来主机进行验证:




登录浏览器,输入 http://172.18.254.37



//此处为编译安装默认的访问页面

1、编译安装的网页页面详解:
[root@www httpd-2.4.10]# cd /usr/local/apache24/
[root@www apache24]# ll
total 52
drwxr-xr-x 2 root root 4096 May 21 18:28 bin //程序路径
drwxr-xr-x 2 root root 4096 May 21 18:28 build //编译安装的相关文件
drwxr-xr-x 2 root root 4096 May 21 18:28 cgi-bin //cgi格式的页面程序存放的位置
drwxr-xr-x 3 root root 4096 May 21 18:28 error //错误页面(可以自定义错误内容,并非访问错误)
drwxr-xr-x 2 root root 4096 May 21 18:04 htdocs //网页文件存放位置
drwxr-xr-x 3 root root 4096 May 21 18:28 icons //各种各样图标
drwxr-xr-x 2 root root 4096 May 21 18:28 include //头文件
drwxr-xr-x 2 root root 4096 May 21 18:30 logs //日志
drwxr-xr-x 4 root root 4096 May 21 18:28 man //man手册
drwxr-xr-x 14 root root 12288 Jul 16 2014 manual //官方文档
drwxr-xr-x 2 root root 4096 May 21 18:28 modules //模块

2、编译的configure的命令内容在 /build/config.nice下




CentOS 6 配置httpd-2.4,利用服务器脚本进行启动

# cd /etc/rc.d/init.d/
# cp httpd httpd24
# vim httpd24
#if [ -f /etc/sysconfig/httpd ]; then
#. /etc/sysconfig/httpd
#fi //注释或删除掉上面的文件加载

apachectl=/usr/local/apache24/bin/apachectl
httpd=${HTTPD-/usr/local/apache24/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/usr/local/apache24/logs/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd24}

# chkconfig --add httpd24 //修改完必须进行添加
# chkconfig --list httpd24



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  安装 编译 CentOS