You can use the service or systemctl command to restart httpd server. Another option is use /etc/init.d/httpd service script.
Restart Httpd Server on RHEL/CentOS 7.x/8.x
Use the systemcl command command as follows:
sudo systemctl start httpd
sudo systemctl stop httpd
sudo systemctl restart httpd
sudo systemctl status httpd
Command to restart / stop / start httpd on Linux
Task: Start httpd server:
Login as root user and type the following commands on RHEL/CentOS version 5.x/6.x or older:
# service httpd start
Task: Restart httpd server:
# service httpd restart
Task: Stop httpd server:
# service httpd stop
Please note that restart option is a shorthand way of stopping and then starting the Apache HTTPd Server. You need to restart server whenever you make changes to httpd.conf file. It is also good idea to check configuration error before typing restart option:
# httpd -t
# httpd -t -D DUMP_VHOSTS
Sample output:
Syntax OK
Now restart httpd server:
# service httpd restart
Where,
- -t : Run syntax check for config files
- -t -D DUMP_VHOSTS : Run syntax check for config files and show parsed settings only for vhost.
/etc/init.d/httpd script option
You can also use following command:
# /etc/init.d/httpd restart
# /etc/init.d/httpd start
# /etc/init.d/httpd stop
A note about Debian / Ubuntu Linux (older version)
Type the following command under Debian / Ubuntu Linux:
# /etc/init.d/apache2 restart
# /etc/init.d/apache2 stop
# /etc/init.d/apache2 start
You can also use service command under Debian / Ubuntu Linux:
# service apache2 restart
# service apache2 stop
# service apache2 start
If you are using the systemd based latest version of Debian/Ubuntu Linux
Try the following command:
sudo systemctl start apache2
sudo systemctl stop apache2
sudo systemctl restart apache2
sudo systemctl status apache2
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
- RSS feed or Weekly email newsletter
- Share on Twitter • Facebook • 8 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 |
great resource. Thank you for helping us out.
regards,
sysvconfig deb pkg is now not available for Debian Squeeze!
Anyone tried the old lenny stable v0,81 on squeeze?
and about CentOS we use this
/sbin/service httpd start
Thanks a lot man!!!! It really helped me a lot!!!
Thank you!!
:)
Not able to start httpd service, because of following error..
[root@cate4-br1-pc3 ~]# service httpd start
Starting httpd: httpd: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
(30)Read-only file system: httpd: could not open error log file /etc/httpd/logs/error_log.
Unable to open logs
[FAILED]
You install httpd?
# sudo yum install httpd
i am typing “/etc/init.d/httpd start” in terminal of centos 7 and gets me an error saying
“-bash: /etc/init.d/httpd: No such file or directory”
Hello Orestis,
check first if http is installed, if not then install it