Home  >  Article  >  Backend Development  >  apache configuration multisite

apache configuration multisite

WBOY
WBOYOriginal
2016-08-08 09:23:491008browse

In the httpd.conf file, there is the following configuration (Note: Omit the comment content of the httpd.conf file)

Listen 80
ServerName 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), then enter http:// in the browser localhost/Workshop/Apache/ You can access all files under E:/Workshop/Apache. Note that the root directory here is E:, but the Directory above has set permissions so you cannot access all the contents under the E drive. If you change Change the Directoy above to:

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


Then you can access everything in the E drive from the browser. When you enter localhost in the browser, the browser will display all the contents in the root directory of the E drive. and accessible. For security reasons, we usually don’t do this, so the common setting method is the following configuration:

Listen 80
ServerName 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>


Only allow access to specific directories through the browser, which is all the content under the E:/Workshop/Apache directory. Of course, for the second Dir, you can set the access permissions for different folders under E:/Workshop/Apache.
Finally, let’s talk about the settings of the virtual host. Please set it in the following format (just put it at the end of the httpd.conf file):
As shown below, you need to set the listening port first, then specify the host address and port for NameVirtualHost, and then the VirtualHost is set up, including SeverName, which is the host name and document root directory. Note that for local development, set ServerName to localhost or 127.0.0.1, and the document root directory can be the same as the directory setting, or you can Different access permissions can be set for different folders in the document root. The × sign represents the virtual host that listens to all access settings ports.

Listen 81
NameVirtualHost *: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 82
NameVirtualHost ×: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>

The above introduces the configuration of apache multi-site, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

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