Laravel setup on Mac in XAMPP - php

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.

Related

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 :)

artisan key generate error

I am trying to duplicate a laravel project on my local machine (windows, wamp, laravel 5.4)
I copied all the files and folders beside the vendor folder to a new folder.
I ran composer install, artisan cache:clear and composer dump-autoload
But, when I ran artisan key:generate I get this error:
file_put_contents: failed to open
stream: Permission denied.
Why is that and how do I solve it?
Thank you
You need to run:
chmod -R 777 storage/*
sometimes sudo chmod -R 777 storage/*
then php artisan cache:clear
then php artisan key:generate
This is due to the file permissions not being writeable. Seems to be quite a regular occurrence this happens but the steps above will rectify your problem.
To utilise more of these commands on a windows you can use a program called Git Bash. It's a very neat and handy tool: Git Bash
If you do not wish to use git bash you can take this approach:
Locate the Storage folder within your file explorer. Right click and press permissions and change the security permissions to allow write access.

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

Install Laravel on ubuntu

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

Laravel 4 PHP Not Found

I am trying to setup my first laravel project. I am running XAMPP for Linux (LAMPP) and I installed composer in /opt/lampp/bin/php.
I then cd /opt/lampp/htdocs
I then run: /opt/lampp/bin/php composer.phar create-project laravel/laravel new_proj --prefer-dist
Everything seems to be going great for the install then I get
Script php artisan optimize handling the post-install-cmd event returned with an error
[Runtime Exception]
Error Output: sh: 1: php: not found
I have PHP 5.4.
I think I understand the error but I don't know Laravel well enough to solve this. I have searched for this and can't seem to find an answer.
Also I can't seem to find a good starting point for trying to install this on XAMPP for Linux (LAMPP). Any help here would be greatly appreciated.
Problem was that I did not specify
/opt/lampp/bin
in my Path so it could not find PHP and more specifically it could not find the version of PHP that I was using in LAMPP. So I added
Path=$PATH:/opt/lampp/bin
to my ~/.bashrc file then I was able to successfully install laravel. Next issue that came up after that was setting permissions on the appropriate folders.
Permissions Problem, See Below:
Set permission for your project folder: sudo chmod 755 -R laravel_proj_name
Set permission for your project storage folder:
sudo chmod o+w -R laravel_proj_name/app/storage
Refresh Page, Good to Go!
I think the problem is that the PHP CLI binary is not in your path. Try adding it to your path or putting a symbolic link into /usr/bin or some other appropriate place.

Categories