Image may be NSFW.
Clik here to view.
I’m currently learning Linux environment and decided to manually install Apache server.For educational purposes I’ve compiled it into:
/server/apache
http.conf configured correctly. It works – I can open up a browser and navigate to localhost and I can see “It works message”.
But how does one goes about adding apache into Ubuntu’s startup so I won’t have to do:
sudo /server/apache/bin/apachectl start
all the time:)
Can somebody explain how does one goes into adding programs to Ubuntu startup (10.10 64 bit).
Thanks:)
UPDATE – RESOLUTION
I learned a lot. It looks like there are 2 ways of doing it:
1) Historical ways: most Unix/Linix distros historically followed System.V initialization patter. This way all u have to do is write a special start/stop/restart script, chmod +x it and put in under /etc/init.d directory. Then you run update-rc.d command which creates links under different runlevels. and that’s how it works. la la la
2) New way. Many linux distros currently switching from old runlevel based system to event based initialization. In my case Ubuntu (also RHEL 6.0 and Fedora) uses system called Upstart which eventually will completely replace systemV version. it uses /etc/init folder. All you have to do is create a script, chmod +x it and put it under /etc/init dir.
Upstart information
Image may be NSFW.
Clik here to view.
The easiest way would be to put:
/server/apache/bin/apachectl start
into “/etc/rc.local”. The better way to do it would be to create an /etc/init/apache.conf upstart script, I believe the correct values would be something along the lines of:
start on runlevel [2345]
stop on runlevel [!2345]
expect daemon
exec /server/apache/bin/apachectl start
pre-stop exec /server/apache/bin/apachectl stop
Then run “initctl start apache” to start it and “initctl stop apache” to stop it. For more information on upstart configuration files like the above, see “man 5 init”.
Check more discussion of this question.