I want to manually install Apache server. I've compiled it into:


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)?


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

  • Is there one not included in your src, from where you compiled it? – Arenstar Nov 17 '10 at 5:29
  • Is there any reason you're using a custom version? Unless there's a specific reason, NOT using the provided version is not recommended. – Andrew M. Nov 17 '10 at 13:19
  • 1
    You should really look at the Filesystem Hierarchy Standard. /server is an incredibly questionable place to put binaries. – jgoldschrafe Nov 17 '10 at 13:33
  • i'm new to linux. i think the best way to learn is by trying stuff. True - one can use yum or apt-get to get things done quickly. but this way u don't know what's going on behind the scene. As to /server directory - yeah - that wasn't the right place. Afterlooking through Linux hierarchy standard it looks like you'd be better of putting your binaries either into /opt or /usr/local - right? – Stann Nov 17 '10 at 18:12
  • Unless you're interested in the actual compilation process, I'd say you're better off sticking to the packages. They're provided for a reason--and by circumventing the packages, you're going to clutter up your system even more. For example, the answer that was provided works--but is going to be impossible to maintain. Just keep that in mind. – Andrew M. Nov 17 '10 at 18:33

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".

  • nice. that's what worked for me.... – Stann Nov 17 '10 at 18:15
sudo update-rc.d httpd defaults

This will use the default run levels that the script provides, which includes starting it up and shutting it down. update-rc.d is the standard for manipulating services on Debian-based systems. Good luck!


  • update-rc.d requires that the init script already exist, including meta information within it formatted for update-rc.d, which the question asker doesn't have because they aren't using the packaged install. – Sean Reifschneider Nov 17 '10 at 11:31
  • You're absolutely right; I glazed over the fact that the OP was compiling their own version. – Andrew M. Nov 17 '10 at 13:19
  • I was wondering about that....:) – Stann Nov 17 '10 at 18:14

Here is a link that contains an init script..

It will need to be modified to your custom compile..

but it should work :D


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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