【发布时间】:2021-12-19 12:38:33
【问题描述】:
我有一个默认的虚拟主机。它被配置为在 /var/www/html 中观看 Document Root 并且效果很好。但我有一个问题。我在子目录中有多个站点,但我不知道如何为每个站点设置 Document Root。例如,/var/www/html/test、/var/www/html/test2 等。当我包含来自/var/www/html/test 的文件时,它会在var/www/html 中搜索。例如,我包含include_once '/core.php' 之类的文件,但我有一个错误Failed opening required '/var/www/html/core.php',因为这里没有当前文件。是否可以为主虚拟主机内的每个目录设置文档根目录?谢谢!
我的主要虚拟主机配置:
<VirtualHost *:80>
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
AccessFileName .htaccess
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
另外,您可以说,我需要使用相对路径,但在某些方面这是不可能的,因为有时我会使用由其他人创建的现成网站。
【问题讨论】:
标签: php apache2 virtualhost