二.安装
按照httpd mysql php 的顺序依次安装
1.安装apache
其实关于apache的安装,本人前边的博客已有介绍
[root@lly ~]# tar -zxvf apr-1.4.6.tar.gz -C /usr/local/src/
[root@lly ~]# tar -zxvf apr-util-1.5.1.tar.gz -C /usr/local/src/
[root@lly src]# cd /usr/local/src/apr-1.4.6/
[root@lly apr-1.4.6]# ./configure --prefix=/usr/local/apr把apr安装到/usr/local/apr目录下
[root@lly apr-1.4.6]#make
[root@lly apr-1.4.6]#make install
[root@lly apr-1.4.6]# cd ..
[root@lly src]# cd apr-util-1.5.1/
[root@lly apr-util-1.5.1]# ./configure --with-apr=/usr/local/apr/bin/apr-1-config
[root@lly apr-util-1.5.1]# make
[root@lly apr-util-1.5.1]# cd
[root@lly ~]# tar -jxvf httpd-2.4.4.tar.bz2 -C /usr/local/src/
[root@lly ~]# cd /usr/local/src/httpd-2.4.4/
[root@lly httpd-2.4.4]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-rewrite --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --with-pcre -with-z --enable-mpms-shared=all
[root@lly httpd-2.4.4]# make
[root@lly httpd-2.4.4]# make install
[root@lly httpd-2.4.4]#/usr/local/apache/man
[root@lly man]# vim /etc/man.config
把apache的man手册添加到man路径方便查看apache的man手册
为了防止系统调用apache的头文件include时找不到路径,可以做一个连接
[root@lly apache]# ln -s /usr/local/apache/include/ /usr/include/apache
为了更好的管理httpd,为其编辑一个启动脚本
[root@lly ~]# cd /etc/init.d/
[root@lly init.d]# vim httpd
脚本如下
#!/bin/sh
#set -x
HTTPD='/usr/local/apache/bin/httpd'
CONFFILE='/etc/httpd/httpd.conf'
#description: http server
#chkconfig: 2345 88 60
start(){
[ -f /var/lock/subsys/httpd ]&& echo "apache is started" && exit
echo -n "starting apache......"
sleep 1
}
stop(){
[ ! -f /var/lock/subsys/httpd ] && echo "httpd is stoped..." && exit
echo -n "stoping httpd........"
sleep 1
/bin/rm -rf /var/lock/subsys/httpd
$HTTPD -k stop && RETVAL=0 ||RETVAL=1
}
case $1 in
stop(){
[ ! -f /var/lock/subsys/httpd ] && echo "httpd is stoped..." && exit
echo -n "stoping httpd........"
sleep 1
/bin/rm -rf /var/lock/subsys/httpd
$HTTPD -k stop && RETVAL=0 ||RETVAL=1
[ $RETVAL -eq 0 ] && rm -rf /var/lock/subsys/httpd && echo "ok" || echo "fail"
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "start|stop|restart"
;;
esac
[root@lly init.d]# chmod a+x /etc/init.d/httpd
[root@lly init.d]# service httpd start
[root@lly init.d]# netstat -tupln |grep http
tcp 0 0 :::80 :::*
[root@lly init.d]# chkconfig --add httpd添加自启动
[root@lly init.d]# chkconfig --list |grep http
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off