I have LAMP server installed on my system and it is working perfectly. However, I am very curious to know why we need not start Apache server in LAMP. When we have WAMP on Windows, by contrast, we have to start it and activate Apache and MySQL. Does Apache start as we start Ubuntu (i.e., it always runs in the background) or does it start when we open localhost?
The answers to the question "Manually Start LAMP Server" describe how to start LAMP manually, but not how it works internally to start LAMP automatically.
Best Answer
Linux in general, so Ubuntu too, has directories where you can put scripts that start/stop/restart/reload a service (or whatever action this service can provide):
/etc/init.d/
(=old but still used very often).As an example, the start of the
apache2
script (all the others will be similar in style):...
There is also
/etc/init
(=upstart):So basically inside these scripts/configuration it is stated what other service needs to be started before this service can be started and what service needs to have stopped before this service can be stopped.
When you install a service like apache (or mysql (databaseserver) or cups (print server)) it generally also includes a startup script AND this is also activated (since the assumption is: if installed you want it running).
So the answer is: it is always running and not started when you access an URL (ie. http://localhost).
It is by the way also possible to stop a service, remove the auto-start from
/etc/init.d/
and manually start that service.There are 2 session managers that take care of this: old Ubuntu (ie. <15.10) uses
upstart
. New Ubuntu (>15.10) usessystemd
.service start apache2
orservice stop apache2
.systemctl start apache2
orsystemctl start apache2
but also supports the method Upstart uses on Debian/Ubuntu systems.