虚拟化容器,大数据,DBA,中间件,监控。

Linux下apach+ssl自动启动的脚本

11 10月
作者:admin|分类:系统运维

Linux下apach+ssl自动启动的脚本

)配置apache启动时自动提取ssl_mod密码脚本

#cd  /usr/local/apache2/conf/extra

#cp   httpd-ssl.conf  httpd-ssl.conf.bak   --做个备份

#vi /usr/local/apache2/conf/extra/httpd-ssl.conf

注释SSLPassPhraseDialog  builtin

在后添加

SSLPassPhraseDialog  exec:/usr/local/apache2/conf/apache_pass.sh

 

#vi /usr/local/apache2/conf/apache_pass.sh

输入:

#!/bin/sh

echo "密码"    ---密码写启动apache时所用的ssl_mod密码(即server.key的内容)

 

#chmod  500  /usr/local/apache2/conf/apache_pass.sh     --使apache_pass.sh文件只有root可见,增加安全性

#chmod +x /usr/local/apache2/conf/apache_pass.sh  (或者上句直接改成511,省掉此句)

b)配置apache开机自动启动脚本

当手动编译安装apache服务器后一般不会开机自动运行,需要自己添加:

# cd /etc/init.d
# vi apache2

加上以下脚本

#!/bin/sh
# description: Apache auto start-stop script.
# chkconfig: - 85 15

APACHE_HOME=/usr/local/apache2
APACHE_OWNER=root
if [ ! -f "$APACHE_HOME/bin/apachectl" ]
then
    echo "Apache startup: cannot start"
    exit
fi
case "$1" in
    'start')
        su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl start"
        ;;
    'stop')
        su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl stop"
        ;;
    'restart')
        su - $APACHE_OWNER -c "$APACHE_HOME/bin/apachectl restart"
        ;;
esac

# chmod 755 apache2
# chkconfig --add apache2
# chkconfig --level 345 apache2 on

(chkconfig --add  name:增加一项新的服务。chkconfig确保每个运行级有一项启动(S)或者杀死(K)入口。如有缺少,则会从缺省的init脚本自动建立。   chkconfig --del  name:删除所指定的系统服务,不再由chkconfig指令管理,并同时在系统启动的叙述文件内删除相关数据。)

Ok,测试Apache
# service apache2 start
# service apache2 stop
# service apache2 restart

同时reboot OS试一下apache是否开机自动运行了。

浏览2383 评论0
返回
目录
返回
首页
apache 2.4 Compiling and Installing编译与安装 RedFlag LinuxSP3 Mysql 5.6 报错 Your password has expired