【问题标题】:How is it possible to run 2 Websites in 2 different subfolders on one Apache instance?如何在一个 Apache 实例上运行 2 个不同子文件夹中的 2 个网站?
【发布时间】:2021-04-14 01:36:03
【问题描述】:
我只想运行 2 个 Web 应用程序,它们都位于单独的子文件夹中。
所以子文件夹一(即主页)应该可以在:example.com 下访问。
虽然子文件夹二应该可以在 example.com/subfolder 下访问。
我知道 Apache vhosts 文件可以通过某种方式实现,但我是这个 vhost 的新手,不知道如何解决这个问题。
感谢您的帮助!
【问题讨论】:
标签:
linux
apache
ubuntu
virtualhost
【解决方案1】:
我只是让它像那样运行!考虑到安全性,这可能是个问题吗?
<VirtualHost *:80>
ServerName example.com
ServerAdmin example@mail.com
Redirect permanent / https://example.com
DocumentRoot /var/www/webpage/
<Directory /var/www/webpage/>
</Directory>
</VirtualHost>
**And for SSL**
<VirtualHost *:443>
ServerAdmin example@mail.com
ServerName example.com:443
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
DocumentRoot /var/www/webpage/
<Directory /var/www/webpage/>
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/webpage>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Alias /subfolder /var/www/subfolder/
<Directory /var/www/subfolder>
Order allow,deny
allow from all
</Directory>
SSLCertificateFile /etc/certs/live/**********/fullchain.pem
SSLCertificateKeyFile /etc/certs/live/**********/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>