|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
program in linux init
Hi to all,
I have this simple question but i can't figure out the answer. i want that apache starts when linux boot. does anybody knows how can i do it? how can i add a program to the system start up? thanks Fabrizzio |
|
#2
|
||||
|
||||
|
Depends on your Linux distro. Why don't you post that here first.
|
|
#3
|
|||
|
|||
|
linux redhat 7.2
the point is that i've installed apache from a .tar.gz, not from a rpm so i haven't the service. i've made a little script in the /etc/init.d so i cant start it like service httpd start and so on. but i can't set it to start after linux boot. thanks Fabrizzio |
|
#4
|
||||
|
||||
|
I'm running Debian, which I am told has a different start-up procedure than RH. So for what it's worth...
/etc/inittab is read by /sbin/init on boot-up and tells init which scripts to run for the default run level. The start-up script links are in /etc/rc2.d/ (in Debian for run level 2, the Deb default). RH may have a different directory name, but it will likely be similar. There will be a link similar to "S90apache". It will link to /etc/init.d/apache which is your start-up script. After adding the link to /etc/rc2.d/ and adding your script to /etc/init.d/ you can run your script to start the daemon, or use telinit (see man telinit) or do the funky MS thing and reboot (ouch). Here is my apache start script for comparison with your own. Code:
#! /bin/bash
#
# apache Start the apache HTTP server.
#
NAME=apache
PATH=/bin:/usr/bin:/sbin:/usr/sbin
DAEMON=/usr/sbin/apache
SUEXEC=/usr/lib/apache/suexec
PIDFILE=/var/run/$NAME.pid
CONF=/etc/apache/httpd.conf
APACHECTL=/usr/sbin/apachectl
trap "" 1
export LANG=C
export PATH
test -f $DAEMON || exit 0
test -f $APACHECTL || exit 0
# ensure we don't leak environment vars into apachectl
APACHECTL="env -i LANG=${LANG} PATH=${PATH} $APACHECTL"
if egrep -q -i "^[[:space:]]*ServerType[[:space:]]+inet" $CONF
then
exit 0
fi
case "$1" in
start)
echo -n "Starting web server: $NAME"
start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON
;;
stop)
echo -n "Stopping web server: $NAME"
start-stop-daemon --stop --pidfile $PIDFILE --oknodo --exec $DAEMON
;;
reload)
echo -n "Reloading $NAME configuration"
start-stop-daemon --stop --pidfile $PIDFILE --signal USR1 --exec $DAEMON
;;
reload-modules)
echo -n "Reloading $NAME modules"
start-stop-daemon --stop --pidfile $PIDFILE --oknodo --retry 30
start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON
;;
restart)
$0 reload-modules
exit $?
;;
force-reload)
$0 reload-modules
exit $?
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|reload|reload-modules|force-reload|restart}"
exit 1
;;
esac
if [ $? == 0 ]; then
echo .
exit 0
else
echo failed
exit 1
fi
BTW, there are several books on-line that deal with Linux administration. Google for "Rute" and check out the Linux Documentation Project.(www.tldp.org ?) cheers, gary
__________________
There are those who manage to build a web site without knowing what they're doing; thereby proving to themselves they do, indeed, know what they're doing. My html and css workshop, demos and tutorials. Ask a better question, get a better answer. |
|
#5
|
||||
|
||||
|
Put the following line in your /etc/rc.d/rc.local file :
/usr/local/apache/bin/apachectl start does the job for me christo
__________________
. Spiration channels: Free scripts, programming tutorials and articles Dotcut alerts: Online Press cuttings / news alerts Clearprop: UK microlight school, wiltshire Uk dating: UK safe dating with Topdates About Christo . . |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > Linux Help > program in linux init |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|