1、编译安装apache2.2.15版本
Tar –zvxf httpd-2.2.15.tar.gz
(经测试,该版本通过加参数--enable-modules=most --enable-mods-shared=all --enable-so可减少so文件缺失重新编译带来的麻烦)
Cd httpd-2.2.15./configure -prefix=/usr/local/apache2 --enable-modules=most --enable-mods-shared=all --enable-soMake
Make install2、复制启动脚本至/etc/rc.d/init.dcp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
3、在启动级别3中加入链接cd /etc/rc3.dln -s /etc/rc.d/init.d/httpd S85httpdln -s /etc/rc.d/init.d/httpd K85httpd4、在/etc/rc.d/init.d/httpd脚本中第二行开始加入如下内容:#chkconfig:3 85 85
#description:apache5、将服务添加至chkconfigchkconfig --add httpd6、添加至启动级别chkconfig --level 3 httpd on按照以上方法,可以让机器启动的时候,启动apache,也是可以service httpd stat stop restart
但是在启动,停止时没有任何的提示,并且缺少reload选项。后在互联网上寻找相关解决方案,测试可用,将脚本转录如下:
###################################
#!/bin/bash
## Startup script for the Apache Web Server## chkconfig: - 85 15# description: Apache is a World Wide Web server. It is used to serve \# HTML files and CGI.# processname: httpd# pidfile: /usr/local/apache2/logs/httpd.pid# config: /usr/local/apache2/conf/httpd.conf# Source function library.
. /etc/rc.d/init.d/functionsif [ -f /etc/sysconfig/httpd ]; then
. /etc/sysconfig/httpdfi# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.INITLOG_ARGS=""# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache2/bin/apachectlhttpd=/usr/local/apache2/bin/httpdpid=/usr/local/apache2/logs/httpd.pidprog=httpdRETVAL=0# The semantics of these two functions differ from the way apachectl does# things -- attempting to start while running is a failure, and shutdown# when not running is also a failure. So we just do it the way init scripts# are expected to behave here.start() { echo -n $"Starting $prog: " daemon $httpd $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd return $RETVAL}stop() { echo -n $"Stopping $prog: " killproc $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid}reload() { echo -n $"Reloading $prog: " killproc $httpd -HUP RETVAL=$? echo}
# See how we were called.
case "$1" in start) start ;; stop) stop ;; status) status $httpd RETVAL=$? ;; restart) stop start ;; condrestart) if [ -f $pid ] ; then stop start fi ;; reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|reload|status" echo $"|fullstatus|graceful|help|configtest}" exit 1esacexit $RETVAL
该文原文为pid=$httpd/logs/httpd.pid,如果报错,可修改为绝对路径:
pid=/usr/local/apache2/logs/httpd.pid解决。
7、虚机配置
NameVirtualHost 172.28.88.99:80
<VirtualHost 172.28.88.99:80> ServerAdmin DocumentRoot "/usr/local/apache2/htdocs/www.bobo365.com" ServerName ServerAlias bobo.365.com ErrorLog /usr/local/apache2/logs/www.bobo365.com-error_log CustomLog /usr/local/apache2/logs/www.bobo365.com-access_log common</VirtualHost><VirtualHost 172.28.88.99:80>
ServerAdmin DocumentRoot "/usr/local/apache2/htdocs/wap.bobo365.com" ServerName wap.bobo365.com ServerAlias bobo.365.com ErrorLog /usr/local/apache2/logs/wap.bobo365.com-error_log CustomLog /usr/local/apache2/logs/wap.bobo365.com-access_log common</VirtualHost>