为什么我得到错误的文档根目录?
Why am I getting the wrong document root?
我正在学习本教程- https://docs.zendframework.com/tutorials/getting-started/skeleton-application/
为了在 Apache 本地服务器上设置它,我使用了这段代码-
<VirtualHost *:80>
ServerName zf-tutorial.localhost
DocumentRoot /var/www/html/skeleton-application/public
SetEnv APPLICATION_ENV "development"
<Directory /var/www/html/skeleton-application/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
当我尝试转到 http://zf-tutorial.localhost 时,我看到一个如下所示的目录列表 -
这个 url- http://zf-tutorial.localhost/skeleton-application/public/ 实际上显示了正确的 index.php 文件。
如何让 http://zf-tutorial.localhost 显示 index.php 文件?
尝试删除 Apache 的默认虚拟主机:
sudo a2dissite 000-default.conf
并重新加载网络服务器以使更改生效。
我喜欢把所有东西都整理好并连接好。我关心目录名称以匹配配置文件和名称,所以我会在这里告诉你我会怎么做。
- 在
/var/www/zf-tutorial.localhost
中安装您的应用程序
cd /etc/apache2/sites-available
sudo cp 000-default.conf zf-tutorial.localhost.conf
- 打开该文件并将
ServerName
更改为 zf-tutorial.localhost
- 将
DocumentRoot
更改为/var/www/zf-tutorial.localhost/public
- 您可以添加额外的 parameters/settings 比如
SetEnv APPLICATION_ENV "development"
- 您可以更改访问日志和错误日志,以便于调试和故障排除。对我来说是
${APACHE_LOG_DIR}/zf-tutorial.localhost.access.log
和 ${APACHE_LOG_DIR}/zf-tutorial.localhost.error.log
- 保存并关闭
sudo a2ensite zf-tutorial.localhost.conf
sudo service apache2 reload
你应该准备好了。有了这个,你不需要在那里单独的 VirtualHost 规则,因为你现在在单独的配置文件中设置它。
我正在学习本教程- https://docs.zendframework.com/tutorials/getting-started/skeleton-application/
为了在 Apache 本地服务器上设置它,我使用了这段代码-
<VirtualHost *:80>
ServerName zf-tutorial.localhost
DocumentRoot /var/www/html/skeleton-application/public
SetEnv APPLICATION_ENV "development"
<Directory /var/www/html/skeleton-application/public>
DirectoryIndex index.php
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
当我尝试转到 http://zf-tutorial.localhost 时,我看到一个如下所示的目录列表 -
这个 url- http://zf-tutorial.localhost/skeleton-application/public/ 实际上显示了正确的 index.php 文件。
如何让 http://zf-tutorial.localhost 显示 index.php 文件?
尝试删除 Apache 的默认虚拟主机:
sudo a2dissite 000-default.conf
并重新加载网络服务器以使更改生效。
我喜欢把所有东西都整理好并连接好。我关心目录名称以匹配配置文件和名称,所以我会在这里告诉你我会怎么做。
- 在
/var/www/zf-tutorial.localhost
中安装您的应用程序
cd /etc/apache2/sites-available
sudo cp 000-default.conf zf-tutorial.localhost.conf
- 打开该文件并将
ServerName
更改为zf-tutorial.localhost
- 将
DocumentRoot
更改为/var/www/zf-tutorial.localhost/public
- 您可以添加额外的 parameters/settings 比如
SetEnv APPLICATION_ENV "development"
- 您可以更改访问日志和错误日志,以便于调试和故障排除。对我来说是
${APACHE_LOG_DIR}/zf-tutorial.localhost.access.log
和${APACHE_LOG_DIR}/zf-tutorial.localhost.error.log
- 保存并关闭
sudo a2ensite zf-tutorial.localhost.conf
sudo service apache2 reload
你应该准备好了。有了这个,你不需要在那里单独的 VirtualHost 规则,因为你现在在单独的配置文件中设置它。