Set the apache httpd service to start automatically under Linux
linux server to build svn+apache+ssl deployment environment:
1. svn installation and use under linux reference link: linux server svn installation and version control .
2. svn configuration http access service reference link under linux: linux server svn configuration http access .
3 , svn configuration https access service reference link under linu: linux server deployment svn https access .
4, linux svn setting boot self-starting reference link: linux svn setting booting self-starting .
1. Introduction
Svn is often built locally. The environment of the local server is also extremely unstable, and it is difficult to avoid power outages. When the server is started, it is very troublesome to restart various services.
The following is the svn self-starting setting under linux, record it for your own use later.
Two, linux self-starting settings
Check the server version command:
uname -a
first explain my version, different versions may be slightly different
The linux service startup scripts are mostly placed etc/init.d
in folders
2.1 Create httpd self-starting file
# 进入目录
cd /etc/init.d
# 创建自启动脚本文件
touch appache-httpd
ls -lt
2.2 Edit the appache-httpd script file
Edit the file appache-httpd:
gedit appache-httpd
Write the startup script:
#!/bin/bash
#
# created by rmling, 2022/05/05
#
# apache-httpd Startup script for the Apache HTTP Server
#
# chkconfig: 345 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# pidfile: /run/httpd/httpd.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}
# 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.
apahectl=/usr/sbin/apachectl
httpd=${HTTPD-/usr/sbin/httpd}
prog=httpd
pidfile=${PIDFILE-/run/httpd/httpd.pid}
lockfile=${LOCKFILE-/run/lock/subsys/httpd}
RETVAL=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: "
LANG=$HTTPD_LANG daemon $httpd $OPTIONS
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
# When stopping httpd a delay of >10 second is required before SIGKILLing the
# httpd parent; this gives enough time for the httpd parent to SIGKILL any
# errant children.
stop() {
echo -n $"Stopping $prog: "
killproc -d 10 $httpd
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
RETVAL=$?
echo $"not reloading due to configuration syntax error"
failure $"not reloading $httpd due to configuration syntax error"
else
killproc $httpd -HUP
RETVAL=$?
fi
echo
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status $httpd
RETVAL=$?
;;
restart)
stop
start
;;
condrestart)
if [ -f ${pidfile} ] ; then
stop
start
fi
;;
reload)
reload
;;
graceful|help|configtest|fullstatus)
$apachectl $@
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
exit 1
esac
exit $RETVAL
first row#! /bin/bash format standard
The following options are assigned according to their actual installation conditions:
#config: /etc/httpd/conf/httpd.conf
apahectl=/usr/sbin/apachectl
httpd= HTTPD − /usr/sbin/httpdpidfile = {HTTPD- /usr/sbin/httpd} pidfile=HTTPD−/usr/sbin/httpdpidfile={PIDFILE-/run/httpd/httpd.pid}
lockfile=${LOCKFILE-/run/lock/subsys/httpd}
2.3 Assign permissions
#执行如下命令,将该脚本标记为可执行文件(添加可执行的权限)
chmod +x /etc/init.d/appache-httpd
2.4 Set the startup
chkconfig --add appache-httpd
#执行如下命令,查看是否添加成功了
chkconfig httpd on
Note: If -> service does not support chkconfig, check the startup script above carefully
2.5 View status
#查看状态
chkconfig --list appache-httpd
At this time, all levels are off, and it is set to run at all levels:
chkconfig --level 0123456 appache-httpd on
2.6 Service start
service httpd start
3. Test
Immediately restart the server:
shutdown -r now
Execute the command after reboot:
#查看https是否启动成功
netstat -ntpl|grep 443