Thursday, April 26, 2012

Start / Stop / Restart Apache Web Server Via SSH

How do I start / stop or restart Apache web sever via SSH (secure shell) under Linux or UNIX operating systems?

Open a command-line terminal (select Applications > Accessories > Terminal), and then type the following command to login to remote server called server1.cyberciti.biz using the ssh client:
$ ssh user@server1.cyberciti.biz
Once logged in switch to the root user by typing su - and entering the root password, when prompted:
$ su -
To restart Apache 2 web server over the ssh, enter:
# /etc/init.d/apache2 restart
To stop Apache 2, enter:
# /etc/init.d/apache2 stop
To start Apache 2, enter:
# /etc/init.d/apache2 start
If you are using RHEL / CentOS / Fedora based server, enter:
# service httpd restart
To stop RHEL / CentOS / Fedora based Apache server, enter:
# service httpd stop
To start RHEL / CentOS / Fedora based Apache server, enter:
# service httpd start

A Note About apachectl Command

You can also use the apachectl command as follows to restart the apache server:
# apachectl -k restart

No comments:

Post a Comment