欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

mac中laravel框架的public文件夹无法访问?

程序员文章站 2022-05-28 17:55:22
...
Mac环境下,用安装包直接布置的laravel,通过浏览器访问laravel文件夹,可以显示文件列表,但浏览器中不显示public文件夹,地址栏直接输入地址./laravel/public/,则会报错:
Forbidden
You don't have permission to access /~jnwb/laravel/public/ on this server.

apache中的rewrite模块已开启。
vhosts.conf配置如下

ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common

ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common

求助!

回复内容:

Mac环境下,用安装包直接布置的laravel,通过浏览器访问laravel文件夹,可以显示文件列表,但浏览器中不显示public文件夹,地址栏直接输入地址./laravel/public/,则会报错:
Forbidden
You don't have permission to access /~jnwb/laravel/public/ on this server.

apache中的rewrite模块已开启。
vhosts.conf配置如下

ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common

ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common

求助!

laravel默认访问public目录作为服务的根目录,你的URL中不应该出现public,例如你要访问 /public/static/css/style.css 你的URL地址就是 http://domain/static/css/style.css

难道不是权限问题?改一下文件夹的权限?