How can I start the Apache 2 Web Server under a Debian or Ubuntu or CentOS or RHEL Fedora Linux or UNIX-like operating system? follow the steps and see which commands I will use to stop or start the Apache 2 web server running on Linux.
Apache is used primarily to provide static as well as active Web websites that are accessible via the World Wide Web. A lot of web-based applications are created to work with the features and environment that Apache offers. Apache can be launched or restarted by using any of the following methods for Linux or similar Unix systems.
The first step is to log in to your web server by using the SSH client, in case the server is not located in the local data center.
ssh root@your-server-com #itexplanations box
ssh cloud2-user@itexplanations-ip-here # AWS
ssh vivek@192.14.152.100 # My home dev server
Debian/Ubuntu Linux Specific Commands to Start/Stop/Restart Apache
You may use the services as well as the /etc/init.d/ command to execute the following in Debian Linux version 7. x or Ubuntu Linux version Ubuntu 14.10 or later:
Restart Apache 2 web server, enter:
# /etc/init.d/apache2 restart
Or
$ sudo /etc/init.d/apache2 restart
Or
$ sudo service apache2 restart
To stop Apache 2 web server, enter:
# /etc/init.d/apache2 stop
Or
$ sudo /etc/init.d/apache2 stop
Or
$ sudo service apache2 stop
To start Apache 2 web server, enter:
# /etc/init.d/apache2 start
Or
$ sudo /etc/init.d/apache2 start
Or
$ sudo service apache2 start
A note about Debian/Ubuntu Linux system users
Use the systemctl command with Debian Linux version 8.x+ or Ubuntu Linux version Ubuntu 15.04plus or above:
## Start command ##
systemctl start apache2.service
## Stop command ##
systemctl stop apache2.service
## Restart command ##
systemctl restart apache2.service
We can view status using the following command:
$ sudo systemctl status apache2.service