2

let's say I want to stop only the example2 VirtualHost. How do I do it?

sudo service apache2 stop will stop all the VirtualHosts. I want example1 to keep running

<VirtualHost *:80>

    ServerName www.example1.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/example1

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

<VirtualHost *:80>

    ServerName www.example2.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/example2

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
Aman Deep
  • 21
  • 1

1 Answers1

1

The only way I know of would be to comment out the entire VirtualHost block for the one you want stopped, and reload Apache config.

For future reference, a better way to set up your configurations would be to have each VirtualHost block in a separate file in sites-available/, and symlink to them from sites-enabled/. In this way, to disable a site you would just remove the symlink and then reload apache config (no commenting required).

Jason Rush
  • 1,808
  • 1
  • 11
  • 12