Red Hat Enterprise Linux Server release 5.5 (Tikanga) 配置Apache httpd-2.4.4
本文是在参见博友spinsoft的文章成功配置后整理。链接:http://www.cnblogs.com/spinsoft/archive/2012/09/07/2675078.html
感谢博友spinsoft的文章,我们环境不同,过程略有不同。
红色文字为重点内容,蓝色文字为引用博友spinsoft内容。
====================================
环境:
[[email protected] soft]# cat /etc/issue
Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Kernel \r on an \m
httpd-2.4.4.tar.gz
====================================
解压httpd-2.4.4.tar.gz,编译
[[email protected] soft]# tar jxvf httpd-2.4.4.tar.bz2
[[email protected] soft]# cd httpd-2.4.4
[[email protected] httpd-2.4.4]# ls
[[email protected] httpd-2.4.4]# ./configure --prefix=/usr/local/apache --enable-so //配置apache路径 ,后面跟 --enable-so 参数表示让apache核心装载DSO
Error:
checking for APR... no
configure: error: APR not found. Please read the documentation.
去Apache官网下载apr-1.4.6.tar.gz,解压编译安装。
[[email protected] soft]# tar zxf apr-1.4.6.tar.gz
[[email protected] soft]# cd apr-1.4.6
[[email protected] apr-1.4.6]# ./configure --prefix=/usr/local/apr
[[email protected] apr-1.4.6]# make
[[email protected] apr-1.4.6]# make install
继续编译Apache
[[email protected] httpd-2.4.4]# ./configure --prefix=/usr/local/apache --enable-so
Error:
configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type:
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... Invalid configuration ` ': machine ` ' not recognized
configure: error: /bin/sh build/config.sub failed
上百度找到解决方法,虽然是解决问题了,但是原理我还不是很理解。
[[email protected] httpd-2.4.4]# yum list | grep libtool*
libtool.i386 1.5.22-7.el5_4 installed
libtool-ltdl.i386 1.5.22-7.el5_4 base
libtool-ltdl-devel.i386 1.5.22-7.el5_4 base
[[email protected] httpd-2.4.4]# yum install libtool-ltdl.i386 libtool-ltdl-devel.i386
复制config.sub和config.guess到当前要configure目录下,比如安装Apache,进入解压后的文件夹(httpd-2.4.4)进行如下操作:
cp /usr/share/libtool/config.sub ./
cp /usr/share/libtool/config.guess ./
然后添加configure参数:./configure --enable-shared --enable-static
继续编译Apache
[[email protected] httpd-2.4.4]# ./configure --prefix=/usr/local/apache --enable-so --enable-shared --enable-static
Error:
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
去Apache官网下载apr-util-1.5.2.tar.gz,解压编译安装。
[[email protected] soft]# tar zxf apr-util-1.5.2.tar.gz
[[email protected] apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[[email protected] apr-util-1.5.2]# make && make install
编译通过,继续编译Apache
这时候要注意修改参数
[[email protected] httpd-2.4.4]# ./configure --prefix=/usr/local/apache --enable-so --enable-shared --enable-static --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
[[email protected] httpd-2.4.4]# make && make install
Apache编译安装完毕
停止&启动Apache
[[email protected] bin]# pwd
/usr/local/apache/bin
[[email protected] bin]# apachectl stop
[[email protected] bin]# apachectl start
查看Apache端口
[[email protected] bin]# netstat -an | grep :80
tcp 0 0 :::80 :::* LISTEN
[[email protected] bin]# lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
httpd 22569 root 4u IPv6 97220 TCP *:http (LISTEN)
httpd 22570 apache 4u IPv6 97220 TCP *:http (LISTEN)
httpd 22571 apache 4u IPv6 97220 TCP *:http (LISTEN)
httpd 22572 apache 4u IPv6 97220 TCP *:http (LISTEN)
httpd 22573 apache 4u IPv6 97220 TCP *:http (LISTEN)
httpd 22574 apache 4u IPv6 97220 TCP *:http (LISTEN)
httpd 22575 apache 4u IPv6 97220 TCP *:http (LISTEN)
httpd 22576 apache 4u IPv6 97220 TCP *:http (LISTEN)
httpd 22577 apache 4u IPv6 97220 TCP *:http (LISTEN)
查看Apache服务启动情况
[[email protected] bin]# ps -aux | grep httpd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root 22569 0.0 3.7 24636 9460 ? Ss 15:20 0:00 /usr/sbin/httpd -k start
apache 22570 0.0 1.8 24636 4800 ? S 15:20 0:00 /usr/sbin/httpd -k start
apache 22571 0.0 1.8 24636 4800 ? S 15:20 0:00 /usr/sbin/httpd -k start
apache 22572 0.0 1.8 24636 4800 ? S 15:20 0:00/usr/sbin/httpd -k start
apache 22573 0.0 1.8 24636 4800 ? S 15:20 0:00 /usr/sbin/httpd -k start
apache 22574 0.0 1.8 24636 4800 ? S 15:20 0:00 /usr/sbin/httpd -k start
apache 22575 0.0 1.8 24636 4800 ? S 15:20 0:00 /usr/sbin/httpd -k start
apache 22576 0.0 1.8 24636 4800 ? S 15:20 0:00 /usr/sbin/httpd -k start
apache 22577 0.0 1.8 24636 4800 ? S 15:20 0:00 /usr/sbin/httpd -k start
root 22735 0.0 0.2 3920 696 pts/3 S+ 15:25 0:00 grep httpd
访问一下apache默认页是否能打开,http://ip:80/index.html
我虚拟机和宿主机使用的是桥接,也能成功从宿主机访问Apache默认页面和自己创建的页面。
创建访问页面
[[email protected] html]# pwd
/var/www/html
[[email protected] html]# ll
total 8
-rwxr--r-- 1 root root 5 Apr 7 15:34 index.html
-rwxr--r-- 1 root root 5 Apr 7 15:34 luke.html
End
转载于:https://www.cnblogs.com/lukeblog/archive/2013/04/08/luke.html