httpd是Apache
超文本传输协议(HTTP)服务器的主程序。被设计为一个独立运行的
后台进程,它会建立一个处理请求的子进程或线程的池。
Redhat公司每几年出一张系统盘,相对于最新的其它软件来说,他推出得有些慢,所以,我们要用最新的软件,我们就得自己来安装。
下面,我来介绍Httpd 源代码安装
首先下载最新的httpd 源代码在http://httpd.apache.org/
将源代码拆包 tar -jxvf httpd-2.4.4.tar.bz2 -C /usr/local/src/
切换到/usr/local/src/httpd-2.4.4
查看安装手册
[root@zlj httpd-2.4.4]# vim INSTALL
根据安装手册来安装
1、执行
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd
--prefix指明安装地方
--sysconfdir指明安装的配置的地方
2、它将会提示下面的错误
configure:
checking for APR... no
configure: error: APR not found. Please read the documentation.
说明缺少 APR文件(Apache Portable Runtime library),即Apache可移植运行时工具库
在
http://www.rpmfind.net(该网站可以直接转到RPM数据库)上搜索APR下载并安装
apr-1.4.6.tar.gz
tar -zxvf apr-1.4.6.tar.gz -C /usr/local/src/ #将其解压
[root@zlj apr-1.4.6]#./configure --prefix=/usr/local/apr #将其安装在/usr/local/apr目录下
[root@zlj apr-1.4.6]# make #编译
[root@zlj apr-1.4.6]# make install #安装
3、继续执行1,它将报
configure:
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
[root@zlj httpd-2.4.4]#
说明缺少 APR-util文件(Apache Portable Runtime Utility library),即Apache可移植运行时工具库
同理
[root@zlj pub]# tar -zxvf apr-util-1.5.1.tar.gz -C /usr/local/src/ #将其解压
[root@zlj apr-util-1.5.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
#将其安装在/usr/local/apr-uti目录下 并指明apr
[root@zlj apr-util-1.5.1]# make && make install
4、继续安装
[root@zlj httpd-2.4.4]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
它将提示
checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from
http://pcre.org/
我们可以到
http://pcre.org/下载pcre( Perl兼容的正则表达式)
[root@zlj pub]# unzip -o pcre-8.32.zip #解压
[root@zlj pcre-8.32]# ./configure --prefix=/usr/local/pcre #将其安装在/usr/local/pcre目录下
[root@zlj pcre-8.32]# make && make install
5、继续安装
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre/ 指明apr 、apr-util 、prce
[root@zlj pcre-8.32]# make && make install #编译安装
[root@zlj init.d]# vim /etc/rc.d/init.d/httpd # 编写脚本,让其开机自动启用
#!/bin/sh
#chkconfig: 345 85 15
#description: httpd for 52lamp 20101016 21:54
ACMD="$1"
ARGV="$@"
case $ACMD in
start)
echo -n "httpd is running ..."
if [ -e /var/lock/subsys/httpd ];then
sleep 1
echo -e "\033[31m [faile]\033[0m"
else
/usr/local/apache/bin/httpd -k start
sleep 1
echo -e "\033[32m [ok]\033[0m"
touch /var/lock/subsys/httpd
fi;;
stop)
echo -n "httpd is stoping ..."
if [ -e /var/lock/subsys/httpd ];then
/usr/local/apache/bin/httpd -k stop
sleep 1
echo -e "\033[32m [ok]\033[0m"
rm -f /var/lock/subsys/httpd
else
sleep 1
echo -e "\033[31m [faile]\033[0m"
fi;;
restart|reload)
if [ -e /var/lock/subsys/httpd ];then
/usr/local/apache/bin/httpd -k restart
echo -n "httpd is stoping ..."
sleep 1
#!/bin/sh
#chkconfig: 345 85 15
#description: httpd for 52lamp 20101016 21:54
ACMD="$1"
ARGV="$@"
case $ACMD in
start)
echo -n "httpd is running ..."
if [ -e /var/lock/subsys/httpd ];then
sleep 1
echo -e "\033[31m [faile]\033[0m"
else
/usr/local/apache/bin/httpd -k start
sleep 1
echo -e "\033[32m [ok]\033[0m"
touch /var/lock/subsys/httpd
fi;;
stop)
echo -n "httpd is stoping ..."
if [ -e /var/lock/subsys/httpd ];then
/usr/local/apache/bin/httpd -k stop
sleep 1
echo -e "\033[32m [ok]\033[0m"
rm -f /var/lock/subsys/httpd
else
sleep 1
echo -e "\033[31m [faile]\033[0m"
fi;;
restart|reload)
if [ -e /var/lock/subsys/httpd ];then
/usr/local/apache/bin/httpd -k restart
echo -n "httpd is stoping ..."
sleep 1
echo -n "httpd is stoping ..."
sleep 1
echo -e "\033[32m [ok]\033[0m"
echo -n "httpd is running ..."
sleep 1
echo -e "\033[32m [ok]\033[0m"
else
echo -n "httpd is restart ..."
sleep 1
echo -e "\033[31m [faile]\033[0m"
fi;;
status)
sleep 1
if [ -e /var/lock/subsys/httpd ];then
sleep 1
echo "httpd is running ..."
else
sleep 1
echo "httpd is stop"
fi;;
*)
echo "Usage: /etc/init.d/httpd {start|stop|restart|condrestart|status}"
;;
esac
启用该进程
[root@zlj bin]# service httpd start
httpd is running ... [ok]
[root@zlj bin]#
6、测试
让其开机自动启用
[root@zlj bin]# chkconfig httpd on
[root@zlj bin]#