php 从 ubuntu 上的 laravel 开始
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11981621/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Starting with laravel on ubuntu
提问by Isaac Gonzalez
I'm trying laravel as a PHP framework, I have already extracted the laravel zip into ~/opt/xampp/htdocs/laravelbut when I go to localhost/laravelor localhost/laravelI get a 403 error message saying:
我正在尝试将 Laravel 作为 PHP 框架,我已经将 Laravel zip 解压缩到其中,~/opt/xampp/htdocs/laravel但是当我转到localhost/laravel或localhost/laravel收到 403 错误消息时说:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
禁止访问!
您无权访问所请求的对象。它要么受读保护,要么无法被服务器读取。
I read somewhere that I need to edit the storagefolder inside of laravel so it can be readable and writable so I chmod -R 766 laravel/storagebut still no luck, I'm doing this from Ubuntu 12.04 have anyone encountered this ?
EDIT
I have chmod -R 0+w laravel/storageand now when i go to localhost/laraveli get an index of some files in there, but when i go to localhost/laravel/public/still get the 403 error, instead of the expected result
EDIT 2
I have set chmod -R 765 laravel/publicand now when i get to localhost/laravel/publici get this message which leads me to believe i'm getting closer:
我在某处读到我需要编辑storagelaravel 中的文件夹,以便它可以读写,所以我chmod -R 766 laravel/storage但仍然没有运气,我正在 Ubuntu 12.04 中这样做有没有人遇到过这个?
编辑
我有chmod -R 0+w laravel/storage,现在当我去那里时,localhost/laravel我得到了一些文件的索引,但是当我去时localhost/laravel/public/仍然得到 403 错误,而不是
我设置的预期结果
EDIT 2现在当我到达时,我收到此消息这让我相信我越来越近了:chmod -R 765 laravel/publiclocalhost/laravel/public
Warning: require(/opt/lampp/htdocs/learning-laravel/laravel/laravel.php): failed to open stream: Permission denied in /opt/lampp/htdocs/learning-laravel/public/index.php on line 34
Fatal error: require(): Failed opening required '/opt/lampp/htdocs/learning-laravel/laravel/laravel.php' (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/learning-laravel/public/index.php on line 34
警告:需要(/opt/lampp/htdocs/learning-laravel/laravel/laravel.php):无法打开流:权限被拒绝在第 34 行的 /opt/lampp/htdocs/learning-laravel/public/index.php
致命错误:require():在 /opt/lampp/ 中打开所需的 '/opt/lampp/htdocs/learning-laravel/laravel/laravel.php' (include_path='.:/opt/lampp/lib/php') 失败htdocs/learning-laravel/public/index.php 第 34 行
回答by Isaac Gonzalez
Final Update
I finally solved it, what happened was that the laravelfolder was read protected, what i had to do was to set chmod 755 -R laraveland then chmod -R o+w storageand voila i had laravel up and running, thanks to everybody that contributed.
最后更新
我终于解决了它,发生的事情是laravel文件夹被读保护,我必须做的是设置chmod 755 -R laravel然后chmod -R o+w storage瞧,我已经启动并运行了 laravel,感谢所有贡献者。
回答by Sadegh
for just getting start with laravel, I just do these following steps:
为了刚开始使用 laravel,我只需执行以下步骤:
sudo chmod -R 770 /your/path/to/laravel/folder/
then add www-data group to your laravel
然后将 www-data 组添加到您的 Laravel
sudo chgrp -R www-data /your/path/to/laravel/folder/
回答by cborgia
Your on the right track, after install of laravel you need to ensure the storage directory has the correct permissions:
你在正确的轨道上,安装 laravel 后,你需要确保存储目录具有正确的权限:
sudo chmod o+w storage
Then make sure you are serving your public folder and not your laravel folder in apaches document root
然后确保您正在为您的公共文件夹提供服务,而不是在 apaches 文档根目录中为您的 laravel 文件夹提供服务
<VirtualHost *:80>
DocumentRoot /Users/JonSnow/Sites/MySite/public
ServerName mysite.dev
</VirtualHost>
Both requirements are covered here
此处涵盖了这两个要求
回答by Hendrik Jan
On the Laravel forum, Kaspien gave this usefull answers:
在 Laravel 论坛上,Kaspien 给出了这个有用的答案:
You do have to chmod 777, but only on the storage/views folder to use blade, which happens to be the view engine the default Laravel view uses. I usually chmod 777 all storage/* directories on a fresh install of Laravel before I start a project, since they have to be writable for views, sessions, etc.
您必须 chmod 777,但只能在 storage/views 文件夹上使用刀片,这恰好是默认 Laravel 视图使用的视图引擎。在我开始一个项目之前,我通常在全新安装的 Laravel 上 chmod 777 all storage/* 目录,因为它们必须是可写的视图、会话等。
From the thread: http://forums.laravel.com/viewtopic.php?id=1552
回答by RDK
In your .htaccess file:
在您的 .htaccess 文件中:
RewriteRule ^index.php(.*)$ /public/index.php [L]
回答by Cengkuru Michael
Change permission to the storage and bootstrap folders like so
像这样更改存储和引导文件夹的权限
sudo chmod -R 777 ./storage ./bootstrap

