: 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.