Check Out Ways to Stop and Restart Apache on Linux Systems

stop and restart apache linux

As we all know, Apache is a free and open source cross-platform web server that is used to serve both static and dynamic web pages. on the web. In this article, we’ll focus on how you can start and restart Apache web server on Linux systems using the apache2 command.

On Ubuntu/Debian Linux

Let’s see how we can start, stop and restart apache2 web server in Ubuntu and Debian versions

Apache2 Restart/Start/Stop/

For Ubuntu and Debian Systemd users – Ubuntu 18.04,16.04 and Debian 9.x later use below commands.

Start Apache2 by running

# systemctl start apache2

Stop Apache2 by running

# systemctl stop apache2

Restart Apache2 by running

# systemctl restart apache2

To check Apache2 status on the terminal run

# systemctl status apache2

Sample Output

● apache2.service – LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Tue 2018-09-11 12:49:03 UTC; 26s ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/apache2.service
├─28788 /usr/sbin/apache2 -k start
├─28791 /usr/sbin/apache2 -k start
└─28792 /usr/sbin/apache2 -k start

To verify whether the web server is indeed running, open your browser and enter your server’s IP address

http://server-ip-address/

You should be able to view Apache’s default page as shown below

restart Apache web server on Linux Systems

For older versions of Ubuntu -14.10 and older and Debian older

Start Apache2 service by running

# sudo service apache2 start
or
# /etc/init.d/apache2 start
or
# sudo /etc/init.d/apache2 start

Stop Apache2 service by running

# sudo service apache2 stop
or
# /etc/init.d/ apache2 stop

Restart Apache2 service by running

# sudo service apache2 restart
or
# /etc/init.d/ apache2 restart
or
# sudo /etc/init.d/ apache2 restart

Sample Output

[ ok ] Restarting apache2 (via systemctl): apache2.service.

Check Apache2 status run

# sudo service apache2 status
or
# /etc/init.d/ apache2 status
or
# sudo /etc/init.d/ apache2 status

Sample Output

● apache2.service – LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Tue 2018-09-11 12:49:03 UTC; 26s ago
Docs: man:systemd-sysv-generator(8)
CGroup: /system.slice/apache2.service
├─28788 /usr/sbin/apache2 -k start
├─28791 /usr/sbin/apache2 -k start
└─28792 /usr/sbin/apache2 -k start

On RHEL/CentOS

Apache2 Restart/Start/Stop

For newer versions of RHEL / CentOS (Versions 7.x and later)

Start Apache2 by running

# systemctl start httpd
or
# systemctl start httpd.service

Stop Apache2 by running

# systemctl stop httpd
or
# systemctl stop httpd.service

Restart Apache2 by running

# systemctl restart httpd
or
# systemctl restart httpd.service

To verify/check the status of Apache2

# systemctl status httpd

Sample Output

● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor prese t: disabled)
Active: active (running) since Tue 2018-09-11 17:33:28 UTC; 6min ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 1450 (httpd)
Status: “Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/s ec”
CGroup: /system.slice/httpd.service
├─1450 /usr/sbin/httpd -DFOREGROUND
├─1451 /usr/sbin/httpd -DFOREGROUND
├─1452 /usr/sbin/httpd -DFOREGROUND
├─1453 /usr/sbin/httpd -DFOREGROUND
├─1454 /usr/sbin/httpd -DFOREGROUND
└─1455 /usr/sbin/httpd -DFOREGROUND

Sep 11 17:33:28 ip-172-31-16-67.us-east-2.compute.internal systemd[1]: Starti…
Sep 11 17:33:28 ip-172-31-16-67.us-east-2.compute.internal systemd[1]: Starte…
Hint: Some lines were ellipsized, use -l to show in full.

For older versions (CentOS/RHEL (Red Hat) Linux version 4.x/5.x/6.x )

Start Apache2 by running

# service httpd start

Stop Apache2 by running

# service httpd stop

Restart Apache2 by running

# service httpd restart

To check the status of Apache web server

# service httpd status

sample output

● httpd.service – The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2018-09-11 19:46:30 UTC; 1 weeks 1 days ago
Docs: man:httpd(8)
man:apachectl(8)
Process: 9118 ExecStop=/bin/kill -WINCH $ (code=exited, status=0/SUCCESS)
Process: 22055 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS)
Main PID: 9122 (httpd)
Status: “Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec”
CGroup: /system.slice/httpd.service
├─ 9122 /usr/sbin/httpd -DFOREGROUND
├─22058 /usr/sbin/httpd -DFOREGROUND
├─22059 /usr/sbin/httpd -DFOREGROUND
├─22060 /usr/sbin/httpd -DFOREGROUND
├─22061 /usr/sbin/httpd -DFOREGROUND
├─22062 /usr/sbin/httpd -DFOREGROUND
├─22149 /usr/sbin/httpd -DFOREGROUND
└─27556 /usr/sbin/httpd -DFOREGROUND

Just like in Debian systems, you can verify that the web server is running by opening your browser and typing your server’s IP address

http://server-ip-address/

restart Apache web server on Linux Systems

On Fedora

Apache2 Restart/Start/Stop

For Fedora Systems (22 and later)

Start Apache2 by running

# systemctl start httpd
or
# apachectl start

Stop Apache2 by running

# systemctl stop httpd
or
# apachectl -k stop

To restart Apache2 run

apachectl -k restart

To check Apache2 status

systemctl status httpd

To confirm that the server is up and running on a web browser, type the server’s IP

http://server-ip-address/

restart Apache web server on Linux Systems

In this article, we focussed on How you can start, stop and restart Apache2 web server on Linux Systems such as Ubuntu/Debian and Redhat systems. We hope that this tutorial has been helpful.

Read Also:

Source

Leave a Reply

Your email address will not be published. Required fields are marked *

WP2Social Auto Publish Powered By : XYZScripts.com