Apache uses a2ensite and a2dissite to quickly switch between sites

Source: Internet
Author: User
: This article describes how to use a2ensite and a2dissite in apache to quickly switch websites. For more information about PHP tutorials, see. During development, you often need to configure multiple sites and switch frequently.

In the past, we often used to include all the configuration files in httpd. conf and annotate them when they are not needed. for example

include conf/translate.conf#include conf/addons.confinclude conf/spider.conf

In this case, you need to first locate the httpd. conf directory, then open it in the editor, modify it, and save it, which is troublesome.

Another way is to include all the configuration files in httpd. conf.

include conf/*.conf  

Rename unnecessary configuration files. this method is also troublesome.

In fact, Apache provides a convenient tool, a2ensite and a2dissite, they are in the apache2-common package.

A2ensite can activate the sites where the sites-available file in the apache folder contains configuration files. a2dissite works in the opposite way.

1. enter the sites-available folder and create a new file, such as spider. conf.

 
      ServerName ci.hfahe.cn    DocumentRoot /data/html/ci.hfahe.cn    DirectoryIndex index.php
 

Run a2ensite and you can see that it provides a selection. these options are all files under sites-available. enter the desired file name to activate the site.


After running, the system prompts you that you need to reload apache to make the configuration take effect. You can also use the apache2ctl graceful/restart command.

Under the sites-enables directory, you can see that the signed link of the activated site configuration file is added to this folder. this is how a2ensite and a2dissite control the site.


The operating method of a2dissite is similar to that of a2ensite.

Through a2dissite and a2ensite, we can quickly activate/shield websites to accelerate development and deployment efficiency.

The above describes how to use a2ensite and a2dissite in apache to quickly switch the site, including some content, and hope to help friends who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.