闲话不说,进入正题
准备工具
httpd_-2.4.4.tar.bz2
apr-1.4.6.tar.gz(apache的一个可移植的运行库)
apr-util-1.5.1.tar.gz
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom/(建立光盘挂载点)
cd /mnt/cdrom/Server/
ll apr*
rpm -ivh apr-devel-1.2.7-11.e15_3.1.i386.rpm(安装apr 开发包)
安装apr-1.4.6运行库
tar -zxvf apr-1.4.6.tar.gz -C/usr/local/src/
cd /usr/local/src/apr-1.4.6/
配置apr-1.4.6
ll
less README
./configure (默认安装到/usr/local目录下自动生成的apr目录下)
make
make install
cd
安装apr-util-1.5.1
tar -zxvf apr-util-1.5.1.tar.gz -C /usr/local/src/
cd /usr/local/src/apr-util-1.5.1/
ll
ls
./configure
./configure --with- apr=/usr/local/apr/bin/apr-1-config(要指定apr-config的完整路径)
make
make install
Cd
安装pcre 及其开发包(别问为什么要装这个,不装会出问题的。。。)
ll /mnt/cdrom/Server/pcre*
rpm -ivh /mnt/cdrom/Server/pcre-6.6-2.el5_1.7.i386.rpm
rpm -ivh /mnt/cdrom/Server/pcre-devel-6.6-2.e15_1.7.i386.rpm
安装http2.4.4
tar -jxvf httpd-2.4.4.tar.bz2 -C /usr/local/src/
cd /usr/local/src/httpd-2.4.4/
cd /usr/local/apr
vim /etc/ld.so.conf.d/apr.conf
写入路径/usr/local/apr/lib(让系统调用运行库)
ldconfig加载
./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd(配置文件目录)--with-apr=/usr/local/apr/bin/apr-1-config(要指定apr-config的完整路径)
make
make install
cd /usr/local/
cd bin/
./apachectl start
netstat -tupln |grep 80(查看80端口是否启动)
此时调用的是apachectl,那么我们想调用自己的脚本来启动apache呢?
那就写脚本吧。。
cd /etc/init.d
vim httpd
#!/bin/bash
#descriptionion: httpd server
#chkconfig: -88 90
HTTPD=’/usr/local/apache/bin/httpd’
CONFFILE=’etc/httpd/httpd.conf’
. /etc/init.d/FUNCTIONS
start() {
[-f /var/lock/subsys/http ] && echo “httpd is starting....”
echo -n “httpd is starting......”
sleep 1
$HTTPD -f $CONFFILE && RETVAL=0||RETVAL=1
[$RETVAL -eq 0] &&touch /var/lock/subsys/http && echo -e “\033[31m [ok] \033[0m”||echo -e “\033[31m [fail] \033[0m”
}
stop (){
Echo -n “httpd is stoping.....”
sleep 1
killproc httpd && RETVAL=0||RETVAL=1
[$RETVAL -eq 0] && rm -rf /var/lock/subsys/http ||echo -e “\033[31m [fail] \033[0m”
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo “Usage:start|stop|restart”
;;
esac
chmod a+x httpd
chkconfig --add httpd(把httpd服务设置开机自启动)
结束
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。