I have installed LAMP stack on Ubuntu 14.04. Now I want to start apache2 server from terminal. What are the commands to do that?
Asked
Active
Viewed 9,167 times
2 Answers
5
Try executing following command
$sudo service apache2 restart|stop|start
open the web browser and go to the URL http://localhost
if you read
"It works!"
message on browser
which is the content of the file
/var/www/index.html
this proves that Apache server has started and it is working. source.
-
I think '$sudo service apache2 restart' will restart the server. What if the server is down and I want to start it again.? – Mostafiz Ur Rahman Dec 29 '16 at 11:27
-
here is : http://askubuntu.com/questions/6358/how-do-you-restart-apache – dkb Dec 29 '16 at 11:31
-
I think it is the way to restart the server, where the server is already running. – Mostafiz Ur Rahman Dec 29 '16 at 11:33
-
you can use any of the commands $sudo service apache2 start or $sudo service apache2 stop or $sudo service apache2 restart based on your need. – dkb Dec 29 '16 at 11:35
1
To start the apache2
server from terminal run the command as follows.
sudo /etc/init.d/apache2 start
To make it start automatically at bootup, execute the command as follows.
sudo update-rc.d apache2 enable

Thomas
- 6,223
-
Don't I need to add '$sudo' before the command to start apache2? – Mostafiz Ur Rahman Dec 29 '16 at 11:30
-
If you are not logged in as
root
, then yes you have to add sudo. Sorry... – Thomas Dec 29 '16 at 16:45