【发布时间】:2019-12-03 11:22:48
【问题描述】:
我想为我的 laravel 应用创建一个更真实的开发环境。 我想用 apache 启动我的 laravel 应用。
问题是,如果我尝试通过 URL (localhost.eu) 访问项目,我总是会收到此错误:
Forbidden
You don't have permission to access / on this server.
到目前为止我做了什么:
- 在
Apache\conf中编辑了httpd.conf,我取消了对这一行的注释:
LoadModule rewrite_module modules/mod_rewrite.so
- 编辑了
Apache\conf\extra中的httpd-vhosts.conf,我补充道:
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
ServerName localhost.eu
<Directory Y:/PHP-Projects/Project-Admin-PHP/public>
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
- 编辑了
Windows\System32\drivers\etc中的hosts文件,我补充道:
127.0.0.1 www.localhost.eu localhost.eu
我也尝试过编辑默认的laravel
.htaccess,基本上我尝试了this thread.中的所有解决方案在
Apache\conf中编辑了httpd.conf:
<Directory Y:/PHP-Projects/Project-Admin-PHP/public>
AllowOverride all
Require all granted
</Directory>
原来是:
<Directory />
AllowOverride none
Require all denied
</Directory>
在每一步之后我都重新启动了 apache24 服务。
注意:如果我尝试访问,f.e. localhost.eu/robots.txt 我看到了文件,所以它正确连接到项目文件夹。
如果我输入http://localhost.eu/index.php 我看到了 index.php 的代码,它不知何故没有执行?
【问题讨论】:
-
P.S.:在第 5 步中,我在 httpd.conf 文件中编辑了 Directory 参数,不要这样做。此外,您还需要在
httpd-vhosts.conf的Directory块中添加此DirectoryIndex index.php。
标签: php windows laravel apache