By using this site you agree to the use of cookies by Brugbart and our partners.

Learn more

Starting, Stopping and Restarting Web-servers in Ubuntu

This page shows how to start and stop different web-servers in Ubuntu, Debian, and other Unix/Linux based systems.

Edited: 2016-01-09 06:57

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 based systems such as Ubuntu, things are often located a bit all over the place – so for beginners it can sometimes be hard to know where to look – know then that this page should be using locations used when installing from the software center, or when using apt-get. If installing manually, it is also common to use the /opt directory.

Also remember, you may need to run these commands 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

Apache

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

XAMPP

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

Nginx

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

This is just a joke

If you wish to crash the server – for whatever personal reason – you may at any time type the non-existent crash command into a terminal. I.e.

/etc/init.d/apache2 crash
/opt/lampp/lampp crash
/etc/init.d/nginx crash

It doesn't work of course – but if for some reason it should work some day – just don't abuse it for your own enjoyment!

More Tutorials

  1. Location of Apache Configuration files
  2. Location of Apache error logs