Starting, Stopping and Restarting Web-servers in Linux
How to control servers such as Apache and Nginx in Linux.
Edited: 2019-11-21 05:58
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
Apache
The Apache HTTP Server can be controlled from a terminal with the "standard" start, stop and restart commands.
The preferred way is to use the service interface:
service apache2 start
service apache2 stop
service apache2 restart
service apache2 reload
If this does not work for you, this might work instead:
/etc/init.d/apache2 start
/etc/init.d/apache2 stop
/etc/init.d/apache2 restart
/etc/init.d/apache2 reload
Otherwise, look up the documentation for your distribution of Linux.
MySQL
Use the following to control your MySQL server:
service mysql start
service mysql stop
service mysql 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
Postfix
Controlling the postfix SMTP server can be done with these commands:
service postfix start
service postfix stop
service postfix restart
Tell us what you think: