Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm currently learning the Linux environment, and decided to manually install the Apache server. For educational purposes, I've compiled it into:


The http.conf location is configured correctly. It works -- I can open up a browser and navigate to localhost and see the "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 the Ubuntu startup (10.10 64 bit)?

share|improve this question
While a good learning experience, please don't do this sort of thing long-term. The whole point of the distributions package manager is to keep things patched and up to date. If you start manually building things then YOU need to ensure they stay up to date. – developmentalinsanity Nov 17 '10 at 7:56
@develop: Of course, a distribution like Ubuntu is going to keep versions fixed, only doing maintenance updates, and there aren't necessarily bleeding-edge PPAs for every package you care about - so sometimes if you want a new version, you do have to build it yourself. – Jefromi Nov 17 '10 at 18:19
up vote 2 down vote accepted

The easiest way is to take the Apache startup script in Ubuntu's Apache package, and replace /usr/sbin/apachectl by /server/apache/bin/apachectl.

If it's a learning exercise, you have several options (from most flexible to least flexible):

  • Start Apache through Upstart. You have to write a file /etc/init/my_apache.conf. Given the state of Upstart documentation, I recommend reading existing examples and the man pages in parallel.
  • Start Apache through a SysV script: an executable script in /etc/init.d that starts, stops, restarts or reloads the Apache configuration depending on whether its first (and sole) argument is start, stop, restart, or reload (with force-reload as an alias for reload). To have the script start on boot, run update-rc.d. See also the Ubuntu Bootup Howto.
  • Start Apache from /etc/rc.local.
share|improve this answer
thanks. i came to a conclusion that Ubuntu's Upstart is the way to go as well. RHEL 6 is using it as well. – Stann Nov 20 '10 at 0:20

Here is a good resource, quite close to what you ask for. Basically to make apache2 start automatically you need to run

update-rc.d apache2 defaults

This will make the startup script start the service located in /etc/init.d/apache2 after booting up. Beforehand, you need to make an init script and put it in /etc/init.d/. In your case

ln -s /server/apache/bin/apachectl /etc/init.d/apache2

may be good enough.

share|improve this answer
You could also grab the init.d script out of the apache package, and tweak it just a little bit. You'd end up with a much more robust script. – Jefromi Nov 17 '10 at 6:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.