Start / Stop / Restart Apache Web Server Via SSH

Posted on in Categories , last updated February 14, 2011

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 [email protected]
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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

6 comment

  1. ssh [email protected] pkill -HUP apache2

  2. ssh -C -t [email protected] 'sudo su - root -c "
    /etc/init.d/apache2 status;
    /etc/init.d/apache2 stop;
    /etc/init.d/apache2 start;
    /etc/init.d/apache2 status;
    "
    
  3. Bonjour,en voulant m’inscrire sur un site,apache 2 m’est apparu sur l’écran et je n’arrive pas à m’en défaire et je ne suis toujours pas dans le site voulu.Quelqu’un a eu un truc pareil ou peut m’aider???Mille mercis

Leave a Comment