Laravel mkdir and copy Errors - php

I'm trying to install a laravel application. This question might be specific to Wardrobe, or not. I'm not sure. The Laravel application I'm trying to install is called Wardrobe.
So, there are 2 options that can be used to install this application (or script, I don't know). The first one is with Composer, and the second one is with git.
I'm trying to install this script to my server for weeks. I failed all the time. I can do this on my local computer, but can't on my server.
So, to tell you the problems, I'm creating two subdomains. One is called w1, and the other one is called w2. I'm trying to install Wardobe to w1 using composer, and I'll use git clone on w2.
I cd into /var/www/w2.domain.com/ and execute composer create-project wardrobe/wardrobe public_html. This creates the project into /var/www/w1.domain.com/public_html.
Then, for w2,
I cd into /var/www/w2.domain.com/ and execute git clone https://github.com/wardrobecms/wardrobe.git
Then, I go into database.php of each folder and write my database information.
Then I execute
chmod -R 777 app/storage/
chmod 777 public/img/
After all this, I go to w1.domain.com from my browser. I get '500 Internal Server Error', so I update both (w1 and w2) my .htaccess file from Laravel Installation Doc.
Now, I enter to w1.domain.com. I see the Installer Step 1. I click on 'Install Database & Continue'. BAM! Permission denied!
Here's the error message for w1:
copy(/var/www/w1.domain.com/public_html/public/packages/wardrobe/core/.gitkeep): failed to open stream: Permission denied
Then I enter w2.domain.com. BAM! Permission denied!
Here's the error message for w2:
mkdir(): Permission denied
Then I go into w1 and w2 folders and chown all.
Nothing changes.
Do you have any idea how to fix this?
Thanks in advance.

Here's the fix:
chmod 777 everything.
Install script.
Turn privileges to normal values using chmod.
End of story.
Thank you everyone for being so helpful.

Related

file put content error: no such file in directory

I am trying to upload my laravel project from Xampp to shared hosting, but I get the error:
file_put_contents(C:\xampp\htdocs\resido\storage\framework/sessions/Jmmr9HI35UYdhIfZLDTVlLGjCy5AHiuVK9NfOQuT): failed to open stream: No such file or directory
when I try either of the following solutions:
delete the file app/bootstrap/cache/config.php
composer dump-autoload
php artisan config:clear,
the application works. however, all the changes I made while working with xampp is gone and I get the old view from the application template.
how do I fix this problem without losing the changes I made to the project?
I think I'm having this error because the folder C:\xampp\htdocs\resido\storage\framework/sessions does not exist
how do I change this directory to that of the live hosting?
Make sure the which you are calling is available in the "storage\framework/sessions" folder
OR you can unset all the current sessions from the browser and try
It is quietly often when we try to move our code to the server by copy paste the whole project.
To solve this problem you need to check inside storage/framework/sessions.
Is there a sessions folder available or not, if not then create it manually on the server and give the permission of 664 or 775 to the storage directory recursively.
For permission, you can use this command from server cmd inside the project directory :
sudo chmod -R 775 storage and sudo chmod -R 775 storage/*.

How do I fix laravel.log cannot be opened in AWS deploy?

We have a Laravel app (version 4) that we're trying to deploy on AWS. Previously, it was hosted in our local servers via XAMPP. On AWS, I created a folder for the laravel app in var/www/html directory path. But as I try to access http://aws-url/laravel_folder/public, I get the error message:
Error in exception handler: The stream or file "/var/www/html/laravel_folder/app/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/laravel_folder/bootstrap/compiled.php:9134
I've checkout all similar questions and have followed the suggestions, i.e. setting permission of laravel.log to 777, but still keep getting the same problem.
How do I fix this problem?
Thank you
First 777 permission is not a good idea.
If you're on linux, use the following command:
chmod -R 770 logs (add sudo in front if you're not the owner of the folder!)
That will give owner and group read-write-execute permission on the logs folder and everything inside it but will give no permission to other users.
Also make sure that the folder and files inside it have the web server's user as group.
Hope that's help!
You need to set the permissions for the entire storage folder to 777
sudo chmod -R 777 storage/

.composer/config file permission denied using laravel

I have a laravel project on an ubuntu virtualbox.
I used to run composer update and all worked fine. I don't know of any changes that could have affected this but now when I run composer update I get
file_get_contents(/home/user/.composer/config.json): failed to open stream:
Permission denied
Does anyone know why? When I run sudo composer update , it works.
Your permissions got changed somehow (perhaps not related with running composer). Setting the owner of that file as your user should fix the issue:
sudo chown user /home/user/.composer/config.json
The above assumes that the username is user from the home path. As a side note, it works when running it as a super user using sudo because there's no permissions restrictions in that case.
It seems you don't have valid permissions for this file. Try running:
sudo chmod 0777 /home/user/.composer/config.json
EDIT
Of course, you should do it only in development environment (you mentioned you use Virtualbox). You should not do it in production environment.
Run below command.
sudo composer update

New Laravel Project Throwing 500 Error: require(): Failed opening required autoload.php

I trying to learn laravel and I am attempting to set it up on my server.
I have meticulously followed all the instructions in this tutorial while changing some variables based on the names of my own directories:
http://davidmyers.name/post/laravel-on-digital-ocean
The 500 error only is thrown when I visit the laravel project's public folder. When I attempt to visit any other page such as PHPMyAdmin or any other PHP or HTML page, the page pulls up just fine.
Is there anything I could be missing that is not included in the tutorial that I referenced? I double checked that I am following all the steps correctly.
Also, running composer update in the directory throws this error:
[RuntimeException]
Error Output: PHP Warning: require(/var/www/html/testproj/bootstrap/../vendor/autoload.php): failed to open stream: No
such file or directory in /var/www/html/testproj/bootstrap/autoload.php on line 17
PHP Fatal error: require(): Failed opening required '/var/www/html/testproj/bootstrap/../vendor/autoload.php' (include
_path='.:/usr/share/php:/usr/share/pear') in /var/www/html/testproj/bootstrap/autoload.php on line 17
I found this related stackoverflow article:
Laravel 5 Failed opening required bootstrap/../vendor/autoload.php
but the solution did not work for me, since my phpinfo() shows that OpenSSL is enabled.
The problem is that the server does not have access to those locations.
Run the following commands
sudo chmod 755 -R "your project name"
and then
chmod -R o+w "your project name" /storage
if it still doesn't work try running:
sudo chmod 775-R "your project name"
sudo chmod 775-R "your project name"/storage
or
sudo chmod 777-R "your project name"
sudo chmod 777-R "your project name"/storage
Have you run composer install ? This should automatically run php artisan optimize after install, which I believe is the command to create the file in question.
You must install dependencies by composer using:
composer install
and then give right permission to storage directory:
chmod 777 -R storage
or
sudo chmod 777 -R storage
It turns out that I was doing everything right, but when I went to run composer install I didn't see that it was throwing an installation error due to my server not having enough memory. Increasing my server's memory fixed the problem.
There are 2 things to consider,
1. Web server throwing 500 error (as if text and font were from Chrome) or
2. The application is showing 500 error (with beautiful image and text)
Case 1: you probably need to install composer
sudo composer install
Case 2: Check appropriate permission on storage/ (as suggested on other answers) and check if you have .env file. if not copy .env.example and rename to .env and you also need to generate application key.
sudo php artisan key:generate
PS: You may be in this situation mostly if you have used git to deploy your code on server and your development machine is different. This answer is based on the scenario which I faced and how it was solved.

Laravel Digital Ocean Error in exception handler

I have followed through the phpacademy digital ocean tutorial in order to try and get my laravel site set up. After following through the steps there was a difference between my setup and theirs. My default index.html page was located at /var/www/html instead of /var/www
I removed the index.html page and uploaded my laravel app. I am not using any DB connections (just using static content). I developed my site locally with vagrant and homestead.
After uploading the app and going to the IP address I get the Laravel app directory listing. When I went into public I got a message saying mcrypt was require/not installed. I installed it with sudo php5enmod mcrypt and restarted the server.
Again I reloaded the page and I get the following message (after turning debugging to true) "Error in exception handler: The stream or file
"/var/www/html/app/storage/logs/laravel.log" could not be opened:
failed to open stream: Permission denied in
/var/www/html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:84"
How do I fix this and can i remove the /public and just use straight IP / domain (once i get that far)
Error message indicates it can't open your log file there. Assuming you're using this tutorial (https://www.digitalocean.com/community/tutorials/how-to-install-laravel-with-nginx-on-an-ubuntu-12-04-lts-vps), take a look at the subsection "Fixing Permissions", you'll need to chmod your storage directory.
chmod -R 775 /var/www/laravel/app/storage
Start artisan with sudo. This will give artisan all the permissions it needs and won't make any security troubles as well.
so instead starting artisan serve with:
$ php artisan serve
try using:
$ sudo php artisan serve
thus you wont have to make any permission changes

Categories