Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't make Laravel 4 to work on localhost

I'm trying Laravel for the first time after reading an announcement of the Laravel4 beta releasing.

I followed these steps I installed composer and laravel with all the dependencies it needed. I put the laravel inside my ~/public_html directory - as I'm used to do it with Codeigniter, but I think something's wrong here.

If I point to the browser to http://localhost/~carlo/laravel-develop/, it just displays the content of the directory.

Then, while on the filesystem I had a laravel-develop/public folder, it didn't appear on the browser.

I've found that changing the .htaccess like this:

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule>

resulted in an error when I try to access the public folder. The error:

ErrorException: Warning: file_put_contents(/home/carlo/public_html/laravel-develop/app/config/../storage/meta/services.json): failed to open stream: Permission denied in /home/carlo/public_html/laravel-develop/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php line 77

another one:

/home/carlo/public_html/laravel-develop/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php line 77

then a long list of errors. The last one is:

require_once('/home/carlo/public_html/laravel-develop/start.php') in /home/carlo/public_html/laravel-develop/public/index.php line 53

like image 405
Carlo Avatar asked Jan 15 '13 19:01

Carlo


3 Answers

Try to change the folder permissions for the storage folder using the terminal:

chmod -R 777 storage

More info on this matter can be found here.

like image 89
adridev Avatar answered Oct 22 '22 14:10

adridev


Your errors resulted because laravel couldn't write to the app/storage folder. The rest was just a stack trace. In order to make the storage folder writable, cd into your app folder and then run:

chmod -R 777 storage
like image 16
girlcode Avatar answered Oct 22 '22 14:10

girlcode


Production way, moderate complexity for people not familiar with Unix, but more secure:

  1. Go in super user mode (sudo -s or su).
  2. Create group web (groupadd web)
  3. Add you main user to group web (suppose your user is cool_user, so run usermod -a -G web cool_user)
  4. Add php-fpm or web server user (if php is used as a SAPI module) to web group (for example, on CentOS php-fpm utilize apache user name, so in most cases this will work: usermod -a -G web apache)
  5. Change your project root directory group owner to web recursively (chgrp -R web /path/to/project/root/)
  6. Grant recursively write permission for group (chmod -R g+w /path/to/project/root/
  7. Optionally To allow all newly created by apache (or some other) user files and folders be accessible from your user, make them receive group ownership same as their parent folder by setting groupid bit recursively on your project root directory (chmod -R g+s /path/to/project/root/).

Voila!.

Fast and dirty way, for those who doesn't care about security and want make it works at any cost, not secure:

  1. Go in super user mode (sudo -s or su).
  2. Grant recursively full permission (read, write, execute) for all users (chmod -R o=rwx /path/to/project/root/
like image 11
pinepain Avatar answered Oct 22 '22 14:10

pinepain