Tutorial details | |
---|---|
Difficulty | Easy (rss) |
Root privileges | Yes |
Requirements | Apache 2 on Linux / Unix |
Time | 1m |
First, login to your web-server using ssh client, if server is not in your local data center:
ssh root@your.server.com
Once logged in type the following commands as per your Linux or Unix variant.
Debian/Ubuntu Linux Specific Commands to Start/Stop/Restart Apache
You can either use service or /etc/init.d/ command as follows on Debian Linux version 7.x or Ubuntu Linux version Ubuntu 14.10 or older:
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 systemd users
Use the following systemctl command on Debian Linux version 8.x+ or Ubuntu Linux version Ubuntu 15.04+ or above:
## Start command ##
systemctl start apache2.service
## Stop command ##
systemctl stop apache2.service
## Restart command ##
systemctl restart apache2.service
CentOS/RHEL (Red Hat) Linux version 4.x/5.x/6.x or older specific commands
## Start ##
service httpd start
## Stop ##
service httpd stop
## Restart ##
service httpd restart
CentOS/RHEL (Red Hat) Linux version 7.x or newer specific commands
Most modern distro now using systemd, so you need to use the following systemctl command:
## Start command ##
systemctl start httpd.service
## Stop command ##
systemctl stop httpd.service
## Restart command ##
systemctl restart httpd.service
Alpine Linux start / stop / restart Apache 2 using openrc
We need to use the service command as root user:
# service apache2 start
# service apache2 stop
# service apache2 status
# service apache2 restart
Session:
* Stopping apache2 ... * Starting apache2
Generic method to start/stop/restart Apache on a Linux/Unix
The syntax is as follows (must be run as root user):
## stop it ##
apachectl -k stop
## restart it ##
apachectl -k restart
## graceful restart it ##
apachectl -k graceful
## Start it ##
apachectl -f /path/to/your/httpd.conf
apachectl -f /usr/local/apache2/conf/httpd.conf
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 23 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |
or try this: invoke-rc.d apache2 restart
reset apache.404 not found
Sorry, this doesn’t work on Red Hat:
/etc/init.d/apache2: command not found
For Redhat use:
If you want to stop,start, restart apache2 in Debian give this a try after su’ing
/etc/init.d/apache2ctl stop
or start restart what ever
Sorry, this doesn’t work on Debian:
/etc/init.d/apache2: command not found
remove the leading $ sign
service httpd start|stop|restart|status
okey what is mean when this message coming to u : No apache MPM package installed
sudo service apache2 restart
hello there,
can someone help me out with how i can stop my apache from running.?
run
# service httpd restart
…is better!
Can some one help me..
When apache server restart then apache service will not working it shows…
Not Found
The requested URL / was not found on this server.
Apache/2.2.22 (Debian) Server at 192.168.1.39 Port 80
Not Found
The requested URL/ was not Found on
this server cool
Hi
?
root@dermaproflin:/home/jakub# /etc/init.d/apache2 stop
[….] Stopping web server: apache2apache2: Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName
[ ok waiting .
Bonjour,
en utilisant la commande suivante :
service httpd restart
j’obtient le resultat suivant :
Redirecting to /bin/systemctl start httpd.service
Job for httpd.service failed. See “systemctl status httpd.service” and “journalctl -xe” for details.
j’ai pas bien comprit ce resultat
Pouvez vous m’aider svp
merci
Hi All,
I am running three sites under /var/www/html.
i want to restart a single site
can you advice
sh startup.sh
## Start / Stop and Restart Apache 2 Web Server Command
https://www.cyberciti.biz/faq/star-stop-restart-apache2-webserver/
Any one can help me for solve this problem occurred on centos vps(cpanel):
Stopping httpd: [FAILED]
Starting httpd: AH00526: Syntax error on line 12 of /etc/apache2/conf.d/modsec2.conf:
ModSecurity: Failed to open the audit log file: /etc/apache2/logs/modsec_audit.log
[FAILED]
Hi, everyone!
I have a problem.
When i run, sudo service apache2 restart
Nothing was change in server. And i did not show a Errors…
May i know your OS name and version ?