When developing, it is often necessary to configure multiple sites and switch frequently.
The previous practice was to include all configuration files in httpd.conf and comment them when not needed. For example,
include conf/translate.conf #include conf/addons.conf include conf/spider.conf
In this case, you need to first locate the directory of httpd.conf and then open it with an editor. , modify, and then save, which is more troublesome.
Another way is to include all configuration files in httpd.conf.
include conf/*.conf
Then rename the unnecessary configuration files, this method is also more troublesome.
In fact, Apache provides convenient tools, namely a2ensite and a2dissite, both of which are in the apache2-common package.
a2ensite can activate sites containing configuration files in sites-available under the apache folder, a2dissite does exactly the opposite.
1. Enter the sites-available folder and create a new file, such as spider.conf.
<VirtualHost *:80> ServerName ci.hfahe.cn DocumentRoot /data/html/ci.hfahe.cn DirectoryIndex index.php </VirtualHost>
After running, you will see a prompt that you need to reload apache to make the configuration take effect. You can also use the apache2ctl graceful/restart command.
Go to the sites-enables directory and you can see that the symbolic link to the site configuration file just activated has been added to this folder. This is the principle of a2ensite and a2dissite controlling sites.
The principle and operation of a2dissite are similar to a2ensite, so I won’t go into details here.
With a2dissite and a2ensite, we can quickly activate/block sites and speed up development and deployment efficiency.
The above introduces apache's use of a2ensite and a2dissite to quickly switch sites, including related content. I hope it will be helpful to friends who are interested in PHP tutorials.