#chkconfig:26 80 30
#description: Apache Server
prog=/usr/local/apache/bin/httpd
lockfile=/var/lock/subsys/httpd
pidfile=/var/run/httpd.pid
. /etc/init.d/functions
start() {
if [ -e $lockfile ] ;then
echo "the programe `basename $prog` is started..."
else
echo -e -n "the programe `basename $prog` is starting....."
sleep 2
$prog && echo [ok] && touch $lockfile || echo "fail"
fi
}
stop() {
if [ -e $lockfile ] ;then
echo -e -n "the programe `basename $prog` is stoping......"
sleep 2
killproc `basename $prog` && rm -rf $lockfile && echo "ok" || echo "fail"
else
echo -e "the programe `basename $prog` is stoped"
fi
}
status() {
if [ -e $pidfile ];then
echo "the prog `basename $prog` `cat $pidfile` is running"
else
echo "the prog `basename $prog` is stop"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
start
;;
*)
echo "usage: start|stop|status"
esac
测试一下脚本是否可行:
7)了解http的配置文件
apache安装完成了,接下来我们了解一下它的配置文件,(配置文件安装在了/etc/apache)
主配置文件为httpd.conf,大部分配置都包括在区域中规则如下:
<Directory />
Options FollowSymLinks
AllowOverride None // 代理相关
Order deny,allow // 规则 拒绝 允许 (注意二者顺序不一样,规则也不一样)
(allow,deny 表示先允许后拒绝,执行的时候,先满足允许的规则,再看拒绝的规则
deny,allow 表示先拒绝后允许,执行的时候,先满足拒绝的规则,在看允许的规则)
Allow from all // 允许所有
</Directory>
在安装apache完成后,我们可以在/etc/apache/http.conf中修改配置文件,来部署web服务器
vim /etc/apache/httpd.conf编辑其中的内容
ServerAdmin //管理员的邮箱 ServerName // 服务器的域名
ServerName 192.168.1.190
启动apache service httpd start
![2013-08-26_093410.png web服务器的搭建(apache)和基于客户端的验证_linux_05](https://s2.51cto.com/attachment/201308/093636134.png?x-oss-process=image/resize,m_fixed,w_1184)