httpd 配置开机启动
/etc/init.d/httpd
cat > /etc/init.d/httpd << EOF
#!/bin/bash
### chkconfig: 12345 80 90
function start_http(){
/usr/local/apache/bin/apachectl start
}
function stop_http(){
/usr/local/apache/bin/apachectl stop
}
case "\$1" in
start)
start_http
;;
stop)
stop_http
;;
restart)
stop_http
sleep 2
start_http
;;
*)
echo "Usage : start | stop | restart"
;;
esac
EOF
/usr/lib/systemd/system/httpd.service
cat > /usr/lib/systemd/system/httpd.service << EOF
[Unit]
Description=httpd service
After=network.target
[Service]
Type=forking
ExecStart=/etc/init.d/httpd start
ExecReload=/etc/init.d/httpd restart
ExecStop=/etc/init.d/httpd stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
##################
EOF
添加执行权限
chmod +x /etc/init.d/httpd /usr/lib/systemd/system/httpd.service
开机启动
systemctl daemon-reload
systemctl enable httpd.service
systemctl start httpd.service
本文来自博客园, 作者:Star-Hitian, 转载请注明原文链接:https://www.cnblogs.com/Star-Haitian/p/16335514.html