By using this site you agree to the use of cookies and related technologies.

Learn more

Starting, Stopping and Restarting Web-servers in Linux

How to control servers such as Apache and Nginx in Linux.

Edited: 2016-10-04 18:16

Controlling your web servers can typically be done using simple commands like: start, stop and restart – but XAMPP also have a few additional commands that can be used to control the servers independently.

The part you write in front of the command may look something like: /etc/init.d/apache2, the front part of the command should of course correspond to your installation directory. Keep in mind that in Unix-like systems, such as Ubuntu, things are often located somewhat all over the place.

You may need to run the commands in this article as root, so either run them with sudo in front, or switch to root with the su command before using them. I.e.

sudo /etc/init.d/apache2 start


The Apache HTTP Server can be controlled from a terminal with the "standard" start, stop and restart commands. I.e.

/etc/init.d/apache2 start
/etc/init.d/apache2 stop
/etc/init.d/apache2 restart


When using XAMPP, you can use the start, stop and restart commands to control your servers. I.e.

/opt/lampp/lampp start
/opt/lampp/lampp stop
/opt/lampp/lampp restart

In addition to these commands, you can also use commands such as: restartapache, startapache, stopapache and stopmysql, startmysql, restartmysql. I.e.

/opt/lampp/lampp startapache
/opt/lampp/lampp stopapache
/opt/lampp/lampp restartapache

/opt/lampp/lampp startmysql
/opt/lampp/lampp stopmysql
/opt/lampp/lampp restartmysql


The Nginx web server can also be controlled with the same start, stop, and restart commands as Apache. I.e.

/etc/init.d/nginx start
/etc/init.d/nginx stop
/etc/init.d/nginx restart