apache uses a2ensite and a2dissite to quickly switch sites

WBOY
Release: 2016-08-08 09:20:28
Original
1349 people have browsed it

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
Copy after login

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  
Copy after login

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>
Copy after login

Run a2ensite and you can see that it gives choices. These choices are all the files under sites-available. Enter the required file name to activate the site.


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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!