(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?
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
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 :)
A new answer updated in 2019:
sudo systemctl start httpd
sudo systemctl enable httpd
The systemctl command is a new tool to control the systemd system and service. This is the replacement of old SysV init system management. Most of modern Linux operating systems are using this new tool. If you are working with CentOS 7, Ubuntu 16.04 or later or Debian 9 system. They have opted systemd now.
The enabled service autostarts on system boot. This is the similar option for systemd than chkconfig for the SysV init.