【发布时间】:2021-08-14 15:14:59
【问题描述】:
每当我尝试在 Debian 10 上使用 apache 设置虚拟主机时都会遇到问题。
我正在尝试在地址 products.crud 上设置虚拟主机。所以目录结构是var/www/products.crub/web。
所以,我在 /etc/apache2/sites-available 目录中创建了 Apache 虚拟主机配置文件,我也可以在 /etc/apache2/sites-enabled 目录中启用它。 products.crud.conf 文件的内容是:
<VirtualHost *:80>
ServerName products.crud
DocumentRoot /var/www/products.crud/web
<Directory /var/www/products.crud/web>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</Directory>
所以,我使用以下方式启用了域:
$ sudo a2ensite products.crud
然后我使用
测试了语法$ sudo apachectl 配置测试
问题是我收到这个错误:
AH00558:apache2:无法可靠地确定服务器的完全限定域名,使用 fe80::2ff5:a177:ff45:30b3。全局设置“ServerName”指令以禁止显示此消息 语法OK
我试图解决的问题
我尝试在 /etc/hosts 中添加域
127.0.0.1 localhost
#127.0.1.1 terminale
#127.0.0.1 products.test
127.0.0.5 products.crud
我也尝试在apache2.conf中添加:
# Global configuration
#
ServerName products.crud
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
每当我尝试连接到 products.crud 时,我都会看到 apache 的 localhost 主页,而不是我的 index.php。我该如何解决这个问题?
【问题讨论】:
标签: php apache debian apache2 virtualhost