Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

(Strangley) My installed Apache2 does not start up when logging in to Linux Mint.

Running this command gets it going:

sudo service apache2 start

How should I attempt to start up this service upon each login?

share|improve this question
    
You could place that command in ~/.xinitrc, which will be run at startup. –  MaxMackie Mar 8 '12 at 19:25
1  
@MaxMackie On the contrary, ~/.xinitrc is run at login time, which isn't right. Apache needs to be started by root at boot time. –  Gilles Mar 8 '12 at 23:23
    
@Gilles, right I forgot about that, thanks for correcting. However, why does apache need to be started at boot? Wouldn't login accomplish roughly the same thing? –  MaxMackie Mar 8 '12 at 23:54
    
@MaxMackie Not if you don't log in immediately after boot, obviously. Also Apache doesn't run as you, so you'd have to grant it privileges. It should start at part of the boot scripts, and normally does. –  Gilles Mar 8 '12 at 23:57
    
@Gilles right. Thanks for shedding light on that. –  MaxMackie Mar 9 '12 at 0:32
add comment

4 Answers

Since Mint is based on Ubuntu, and Ubuntu has switched to Upstart, the Upstart Cookbook has all of the info for having a service start on boot, or at any specified runlevel.

This site Gives a detailed cookbook for starting Apache at boot.

share|improve this answer
    
That page talks about placing a bash script in /etc/init.d/apache2. But that file is full of a much more complicated bash script already, which must have been placed there by Apache itself. –  eoinoc Jun 24 '12 at 6:50
add comment

Debian (Ubuntu/Linux Mint)

rcconf (CLI-GUI)

sudo apt-get install rcconf
sudo rcconf

update-rc.d

sudo update-rc.d -f apache2 add

or

sudo update-rc.d apache2 defaults

RedHat/Fedora/CentOS

chkconfig

sudo chkconfig --add apache2

or

sudo chkconfig -- level 35 apache2 on
share|improve this answer
    
Apache was already checked when I ran rcconf. –  eoinoc Jun 24 '12 at 6:52
    
Running the update-rc.d command lead to an error: update-rc.d: warning: apache2 start runlevel arguments (none) do not match LSB Default-Start values (2 3 4 5). –  eoinoc Jun 24 '12 at 6:53
    
Have you given update-rc.d apache2 defaults or update-rc.d -f apache2 add 3 5 –  earthmeLon Jun 24 '12 at 20:35
    
Thanks, but neither worked. First resulted in an "already exists" warning, the second resulted in warning: apache2 start runlevel arguments (none) do not batch LSB default-Start values (2 3 4 5). –  eoinoc Jun 27 '12 at 19:38
add comment
up vote 1 down vote accepted

At shutdown, I saw an error:

Syntax error on line 230 of /etc/apach2/apache.conf .... /etc/apache/sites-enables/mysite: No such file or directory

The thing was, mysite was symlinked to a file in my home folder.

That normally shouldn't be a problem, I thought.

But as far as I know, my home partition is encrypted. Therefore, I'm guessing that Apache could not read the virtual site file when it was loading. The file wasn't accessible until I type in my password.

A complex situation, and took months to work it out :)

share|improve this answer
add comment

Another cause of the same problem is the priority of the apache links in rc[0-6].d. Mine were S90 and K09, and Apache wouldn't start at boot. Setting the priorities at their defaults, 20, worked for me. The existing links need to be removed first.

sudo update-rc.d -f apache2 remove
sudo update-rc.d apache2 defaults
share|improve this answer
add comment

Your Answer

 
discard

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.