Install Laravel on ubuntu - php

I am new to laravel. I am following this tutorial to install it on Ubuntu. I have successfully managed to install all the PHP dependencies and Laravel is cloned successfully but when I do chmod -R 777 /var/www/laravel/app/storage, I am getting No such file or Directory.
I checked it manually and it is not there, I added the directory manually but when I run artisan comand to create controller, I am seeing this error
/var/www/html/laravel/storage/logs/laravel.log

You might need to update composer before you can fire up artisan.
Please try with following command:
composer.phar update
Hope this helps.

Which version of laravel are you using? Later versions of Laravel don't have the storage folder inside "app" but in the project root.
Try with:
chmod -R 777 /var/www/laravel/storage
However, I would recommend that you use 755 instead of 777. Using 777 is almost always bad practice.
In cases where you need more permissions, you could try changing the user owner / group owner of the folder, with the following code:
chown -R someuser:somegroup laravel/somefolder

Related

Laravel - Check storage folder permissions through custom php script

I don't know how laravel handles it, but can anybody give me a quick overview of how does laravel check folder permissions (storage and bootstrap)?
I have tried using is_writable("storage") but it doesn't seem to work atleast on a laravel installation on WAMP server. It gives true every time I try to run it.
Any other suggestions?
The storage and bootstrap/cache should be writable by your web server or Laravel will not run according to documentation (Directory Permissions
section).
So it's obvious that is_writable("storage") will always return true on your running Laravel app.
Note: You can use following commands to configure directory permissions after installing Laravel:
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

Error 500 after installing Laravel 5.3

I have a Laravel project (version 5.3) that works well on my localhost (wampserver).
Now I want to run this project on a subdomain of my website.I have ssh root access and a vps user access (not admin - with Directadmin - PHP version 5.4).
I uploaded project files to my server but when I try to see the project result , it gives me a 500 error.
I have tried to change 'storage' folder permissions , so I read this answer , but when I run "chchon" ssh command , I get errors like this :
can't apply partial context to unlabeled file ...
also , I have tested Laravel with version 4.2 and it worked well.
Does any boy have idea ?? Thanks
If you don't have SELinux enabled, you can set permissions simply with chmod or set the owner of the storage directory with chown to the web server's user. (which is probably www-data)
Try to run sudo chown -R www-data storage in the project directory
Try all this
// first delete the vendor folder inside your project root, then run
composer install
// laravel generates log file there
sudo chmod -R 777 storage/logs
// laravel cache the files here
sudo chmod -R 777 bootstrap/cache
// vendor folder, where laravel saves their dependencies
sudo chmod -R 777 storage/ vendor/
// generate a application key
php artisan key:generate
This might help :)

Laravel throws 'The bootstrap/cache directory must be present and writable' error after update

I used 'composer update', which updated a few packages. During the updating process the website still functions. However, after it says 'The compiled services file has been removed', the website doesn't load and instead says:
Exception in ProviderRepository.php line 190:
The bootstrap/cache directory must be present and writable.
The weirdest thing is, when I run 'composer update' again, the website starts to work again, until the compiled services file is removed, at which point it throws the same error again. I have already tried the usual things that should be done when this error appears (chown -R everything to the right user/group and chmod all the files and folders 664 and 775 respectively).
I don't know what to do anymore, as the error doesn't seem 'correct'..
Try this after you have run the composer update:
php artisan cache:clear
On your Laravel directory file, run:
sudo chmod -R 777 bootstrap/cache/
The best way to resolve this error is:
Open your project folder
Move to the bootstrap directory
Create an empty folder named as cache
Then do PHP artisan cache:clear
This will work for sure
Short version: If uploading using something like AWS eb cli Verify if bootstrap/cache folder (not talking about its contents) is being deployed.
Some background behind my answer
I am using Amazon Web Services' Elastic Beanstalk to host my Laravel project. As I just started using Laravel I do not have much idea about its functioning. Two days back My new deployments were all crashing midway with OP's error message.
Earlier that day, I realised that I was not using
php artisan config:cache
to cache configurations to make things faster. And I added the same in composer.json's "post-install-cmd" and "post-update-cmd" clauses.
And I also added statement in .ebignore file to not upload the content of /bootstrap/cache (as its content is environment dependent a.k.a my localhost configurations have no meaning on my production server)
And facepalm I did not realise that this will stop the bootstrap/cache folder from being uploaded (as Like git, eb cli ignores empty folders).
So, when I started to deploy at night The deployments were meant to crash.
So, now I have just placed empty-placeholder (say) .gitkeep file in bootstrap/cache. And deployments are working once again :)
(Though the problem was so simple I realised the reason after ssh-ing and digging an EBS EC2 instance for some sweet sleep hours ~.~ )
For me, I manually created the cache folder inside bootstrap.
Try this too after you have run the composer update:
php artisan config:clear
Im using cmder on windows 10 in non elevated mode (Non-Admin).
command php artisan cache:clear did not work for me.
The folder bootstrap/cache did not exist.
I created the folder and removed readonly from both bootstrap and bootstrap/cache folder.
Both composer install and composer update are working now.
sudo chmod -R ug+rwx storage bootstrap/cache
hopefully, this will solve the problem.
it work for me run in project folder
sudo chmod -R 777 bootstrap/cache
than run
composer update
than run
cache:clear
First make sure bootstrap/cache dir is exist if not create a new one
mkdir -p bootstrap/cache/
Then run php artisan config:cache
Simple. There are applications that can block the directory. Like google drive synchronizer, One driver synchronizer, or any other application that is using windows explorer.
Delete cache folder. Create this again.
Try executing the following commands in your project root directory
composer update
then do
composer dumpautoload
this will avoid the necessity of messing with cache files
which may lead to whole new sort of issues
I don't imagine what I got done wrong with that before and no games around with that cashclearings had sense. But as it claims there was no 'cache' folder inside /bootstrapp . Had to have create it manually. Now it all rocks ok again
I had to create these five folders to be able to run artisan again.
mkdir bootstrap/cache
mkdir storage/framework
mkdir storage/framework/cache
mkdir storage/framework/views
mkdir storage/framework/sessions
Answer was found in this related question:
"Please provide a valid cache path" error in laravel
In my case, I've found out that the bootstrap/cache is missing in my project during a fresh clone.
Re-adding the cache directory manually solved my issue.
Then running composer install now works fine.
If a web server (e.g. Apache or Nginx) is being used as a front-end the solution is to make the directory bootstrap/cache owned by web server group. For Nginx:
$ sudo chgrp -R nginx bootstrap/cache

Laravel setup on Mac in XAMPP

When I try to run laravel app using XAMPP localhost, it gives me a white screen of death. However, when I use artisan serve, the app works fine.
Here are the steps that I did:
1. I installed composer globally.
2. Install laravel using the zip file and also through composer. Through zip file, I ran composer install.
When I run localhost/my_app/public, it gives me blank white screen.
Seeing previous answers, I did some things
Added this to bash_profile:
export PATH=/Applications/XAMPP/xamppfiles/bin:$PATH
On running which php, I get this:
/Applications/XAMPP/xamppfiles/bin/php
Not able to figure out what would be the exact issue.
I think there is a problem with the storage directory access rights. You can change it's mod to 777 or assign the user(with which apache runs in XAMPP) the ownership of the storage directory.
Here is an example of the command to use:
sudo chmod -R 777 storage
Similarly, for assigning ownership:
sudo chown storage [user]:[group]
have u tried pointing to htdocs and run ?
composer create-project laravel/laravel myproject --prefer-dist
Try:
php artisan cache:clear
then
chmod -R 777 your_laravel_folder_path/storage
finally
php artisan dump-autoload
If you trying in XAMPP then your_laravel_folder_path will
/Applications/XAMPP/htdocs/YOUR_PROJECT_FOLDER . That folder contains storage directory.

blank page comes in laravel 5

i have setup a newly laravel 5 in my UBUNTU system which is 14.04.
when i ran my project which is http://localhost/blog/public/ it give me a blank page.
i have again and again setup laravel in my system but it not working.
i know "php artisan serve". it will run my project on http://localhost:8000/ but i don't want this. i want to run simply by entering a url. please help me and thanks a lot for your solutions.
Run below command on your project directory.
sudo chmod -R 777 storage/
after this its might be working fine.
You could try any of these pointers.
Give write permission to bootstrap/cache and storage folders
sudo chmod -R 777 bootstrap/cache storage
Generate new application key via the artisan command
php artisan key:generate
If the blank screen still persists, and you’re running on CENTOS, then it’s potentially be a SELinux issue. If so, run this command.
setenforce permissive
Hope this helps!
Give write permission to bootstrap/cache & storage folder by using below command
sudo chmod -R 777 bootstrap/cache
sudo chmod -R 777 storage
also make sure new application key generate. if not then use below command
php artisan key:generate

Categories