一台 apache 服务器托管多个网站的方法: Difference between revisions

From 清冽之泉
Jump to navigation Jump to search
Created page with "== 子目录 == <VirtualHost *:80> ServerName sample.com DocumentRoot /var/www/site1 <Directory /var/www/site1> AllowOverride All Require all granted </Directory> Alias /site2 /var/www/site2 <Directory /var/www/site2> AllowOverride All Require all granted </Directory> Alias /site3 /var/www/site3 <Directory /var/www/site3> AllowOverride All Require all granted </Directory> Alias..."
 
No edit summary
Line 1: Line 1:
== 子目录 ==
== 子目录 ==
<syntaxhighlight lang="apache" line>
<VirtualHost *:80>
<VirtualHost *:80>
     ServerName sample.com
     ServerName sample.com
Line 63: Line 64:
     </Directory>
     </Directory>
</VirtualHost>
</VirtualHost>
</syntaxhighlight>

Revision as of 15:53, 19 October 2024

子目录

<VirtualHost *:80>
    ServerName sample.com
    DocumentRoot /var/www/site1
    <Directory /var/www/site1>
        AllowOverride All
        Require all granted
    </Directory>

    Alias /site2 /var/www/site2
    <Directory /var/www/site2>
        AllowOverride All
        Require all granted
    </Directory>

    Alias /site3 /var/www/site3
    <Directory /var/www/site3>
        AllowOverride All
        Require all granted
    </Directory>

    Alias /site4 /var/www/site4
    <Directory /var/www/site4>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

== 子域名 ==
<VirtualHost *:80>
    ServerName site1.sample.com
    DocumentRoot /var/www/site1
    <Directory /var/www/site1>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName site2.sample.com
    DocumentRoot /var/www/site2
    <Directory /var/www/site2>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName site3.sample.com
    DocumentRoot /var/www/site3
    <Directory /var/www/site3>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName site4.sample.com
    DocumentRoot /var/www/site4
    <Directory /var/www/site4>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>