Configure multiple sites in apache and sites in apache

Source: Internet
Author: User

Configure multiple sites in apache and sites in apache

The following configuration is available in the httpd. conf file (Note: remove the comments from the httpd. conf file)

Listen 80ServerName localhost<Directory />    AllowOverride none    Require all denied</Directory>DocumentRoot "E:"<Directory "E:/Workshop/Apache">    Options Indexes FollowSymLinks    AllowOverride None    Require all granted</Directory>



(It is best to clear the browser cache before testing). Enter http: // localhost/Workshop/Apache/in the browser to access all files under E:/Workshop/Apache, note that the root Directory here is E:, but the above Directory is set with permissions, so it cannot access all the content under the E disk. If you change the above Directoy:


<Directory />    Options Indexes FollowSymLinks    AllowOverride None    Require all granted</Directory>



Then you can access everything on the e-disk from the browser. When you enter localhost in the browser, the browser will display all the content in the root directory of the e-disk, and you can access it. For security purposes, we usually do not do this, so we often set the method as follows:


Listen 80ServerName localhost<Directory />    AllowOverride none    Require all denied</Directory>DocumentRoot "E:/Workshop/Apache"<Directory "E:/Workshop/Apache">    Options Indexes FollowSymLinks    AllowOverride None    Require all granted</Directory>



You can only access a specific directory through a browser, which is all the content in the E:/Workshop/Apache directory. Of course, for the second Dir, you can set access permissions for different folders in E:/Workshop/Apache.


Finally, you can set the VM settings in the following format (just at the end of the httpd. conf file ):


As shown in the following figure, you must first set the listening port, then specify the host address and port for NameVirtualHost, and then set the VirtualHost, including the SeverName, that is, the host name, and the document root directory, note: During local development, set ServerName to localhost or 127.0.0.1. The document root directory is the same as the directory settings, alternatively, you can set different access permissions for different folders in the document root directory. The X number indicates the VM that listens to all access ports.

Listen 81NameVirtualHost *:81<VirtualHost *:81>    ServerName 127.0.0.1    DocumentRoot "C:/Users/Administrator/php/webroot1"    <Directory "C:/Users/Administrator/php/webroot1">   Options Indexes FollowSymLinks   AllowOverride None   Require all granted</Directory></VirtualHost>Listen 82NameVirtualHost ×:82<VirtualHost *:82>    ServerName 127.0.0.1    DocumentRoot "C:/Users/Administrator/php/webroot2"    <Directory "C:/Users/Administrator/php/webroot2">   Options Indexes FollowSymLinks   AllowOverride None   Require all granted</Directory></VirtualHost>

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.