This question already has answers here:
Laravel 5.0 Permission on ubuntu
(2 answers)
Closed 6 years ago.
I am using Laravel 5 and whenever i pull from git on my production server, which is azure vps, i have to give permission to my proejct directory, so that apache user can access it. Otherwise it says, permission denied exception. so i have to run following line in terminal every time whenever i pull new code,
sudo chown -R www-data:www-data projectDirectory
So after above command everything works fine.
But the worst thing is whenever Laravel creates new files for log, same issue happens, which gives me following exception:
Symfony\Component\Debug\Exception\FatalErrorException: Exception
'Symfony\Component\Debug\Exception\FatalErrorException' with message
'Uncaught exception 'UnexpectedValueException' with message 'The
stream or file " /storage/logs/laravel-2016-03-17.log
Can anyone tell me how i can get rid of this critical issue. Thanks
Try adding www-data to your project group:
useradd -G <your-project-group> www-data
If larval writes to the logs directory with 'rwx' perms on the group, you will be fine. If the group by default doesn't have write permission on logs, which may be the case, then you will need to make the logs directory open (which #SRK hinted at) DO NOT, however run chmod 755 on your entire web app. You will be exposing configuration parameters (database access) to the outside world.
Check with it will work. you have give permission to this folder to create temporary files
sudo chmod -R 755 /storage/
Related
I was working on my ubuntu 16.0.4 server, on a Symfony 3.4 app.
I accidentaly did a bad manipulation
sudo chown -R USER /var/
While I wanted to enter :
sudo chown -R USER var/
Since then, I can't access to my database.
My Symfony App says me :
An exception occured in driver: SQLSTATE[HY000] [1049] Unknown database 'pics'
And using doctrine, trying to create a new database, I have this error :
SQLSTATE[HY000]: General error: 13 Can't get stat of './pics' (Errcode: 13 - Permission denied)
I don't know how my database could be deleted like this.
Can somebody help me ?
If you updated the user on /var, then the /var/lib/mysql directory is owned by the wrong user, and the mysqld process cannot write to that directory (and possibly not read it).
You can likely restore permissions for the database by:
cd /var/lib
chown -R mysql:mysql mysql
(Note: assuming the use of the default process owner and default directory locations)
I would likely then restart the mysql process.
However, you may have multiple other issues, including /var/run not having all of the correct owners, and thus while the system may be semi-stable at the moment, a reboot could fail very badly.
While one can, as a comment noted, by-pass the issue by allowing full read-write via a chmod 777, that simply opens the system in a way that is not secure. By losing the permission sets, you would have added another layer of problems.
The correct approach is to fix the ownership of all the directories in the /var hierarchy. Possibly comparing against a known good system would provide the correct owners. But for the database the above will give access again.
After reading lots of questions regarding php scandir() I haven't found one that answered my question. If this is a duplicate, please let me know where the answer is before marking me down.
Problem:
If I do
var_dump(scandir("/"));
Then I get the contents of the system root folder: bin, installs, nvme, var, etc, etc... 😊
If I do
var_dump(scandir("/nvme"));
Then I get false and an error that var/www/public_html/nvme doesn't exist.
So then if I do
var_dump(scandir("../../../../../../../"));
I can see the system root folder
but if I do
var_dump(scandir("../../../../../../../nvme"));
then I get a permission denied error.
I tested that I can scan each directory between the public_html and the root directory, but the moment I try to scan forward a directory then I run into errors. All the directories on the way back are owned by the same user as the nvme directory I'm trying to scan. Using file_get_contents throws the same error.
In SElinux I gave apache permission to read and write to the nvme folder. I'm running on Centos 7 with SElinux enabled.
Why can't I can a up from root on a different directory path?
EDIT:
My specific error was that I hadn't completed setting the SElinux context.
Previously I had run
semanage fcontext -a -t httpd_sys_content_t "/nvme(/.*)
but after that I still needed to run
restorecon -v "/nvme"
so that the new context was actually implemented. Now var_dump(scandir("/./nvme")); and var_dump(scandir("../../../../../../../nvme")); both work.
This question already has answers here:
PHP mkdir: Permission denied problem
(15 answers)
Closed 6 years ago.
I'm trying to create directory on my local apache server with php.
I tried
<?php mkdir("folder"); ?>
and
<?php exec("sudo mkdir folder"); ?>
When I try to execute them in browser nothing happens.
But I can execute them from terminal by using sudo. (I also modified sudoers file so it won't prompt for password in second code)
When I don't use sudo I get this error
PHP Warning: mkdir(): Permission denied in /var/www/html/mscr/add.php on line 2
I've also tried this and this .
So I can execute almost everything but directory operations in browser.
I want to be able to create, delete and edit directories in browser.
Thank you!
Sounds like Apache doesn't have permission to create the folder. Either give Apache ownership of the folder (where you're trying to create a new one)
sudo chown www-data /var/www/html/mscr
or set the folder permissions to 777
sudo chmod 777 /var/www/html/mscr
Warning this will make everything within the mscr folder executable. To get around this most CMS will create a subfolder which is set to 777 so something like /var/www/html/mscr/uploads
<?php mkdir("folder", 777, true); ?>
I had my Laravel 3 application running on a different server. I wrapped it up and sent it to my new server. Unpacked it, and while I am trying to display the Laravel application on the new server, I receive this error:
Unhandled Exception Message:
file_put_contents(/var/www/customer_area/storage/views/13f378cf44cd9253eb03394b5a7fd914):
failed to open stream: Permission denied
Location:
/var/www/customer_area/laravel/blade.php on line 63
I have already read through this question several times where others have solved a similar problem by changing permissions on 'storage/directories' to '775'. I even changed permissions on the entire 'var/www' directory to '777', and I still have the error.
Something that I noticed is that there is no '13f378cf44cd9253eb03394b5a7fd914' in the storage/views folder. There are five other files in the folder, but not that one.
Assuming you are running apache on linux, look into recursive chgrp www-data and chown www-data on the folders
Just modify file/folder permissions
Assuming you are in root folder, run one of these commands
chmod -R 0777 storage // for L3
chmod -R 0777 app/storage // for L4
I have recently installed FC13 and am attempting to write a mechanism in my PHP code that caches gathered data into a specific directory (for our purposes here, let's call it /var/www/html/_php_resources/cache).
I copy my files over to the /var/www/html directory and then run chown -R apache:apache /var/www/html/* and chmod a+w /var/www/html/_php_resources/cache on the new data. For right now I am just using the global write permission for convenience. I will tweak the permissions later.
When I attempt to use the chmod or mkdir PHP functions I wind up with:
Warning: chmod(): Permission denied in /var/www/html/_include/php/CacheInit.php
or
Warning: mkdir(): Permission denied in /var/www/html/_include/php/CacheInit.php
Now, when I disable SELinux everything works just fine. The problem is that I would prefer not to disable SELinux and actually get the permissions set up correctly so that I can port it over to servers where someone does not have such explicit control.
As an example: my personal site host allows me to set read/write permissions on directories but will not allow for SELinux policy changes.
FYI:
uname -r = 2.6.34.7-56.fc13
*php -version * = PHP 5.3.3
rpm -qa | grep httpd = httpd-2.2.16-1.fc13
Does anyone have any suggestions?
I had the same problem, trying to mkdir from php. Not so much information on google but this is what I found and I guess this is the correct solution. One have to label the dir in which apache should create directories.
Label should be "httpd_sys_script_rw_t" and I found that info here: http://docs.fedoraproject.org/en-US/Fedora_Core/5/html/SELinux_FAQ/index.html#id672528
Here's how to label the dir: chcon -R -t httpd_sys_script_rw_t <dir>
Reference somewhere here: http://www.centos.org/docs/5/html/Deployment_Guide-en-US/rhlcommon-chapter-0017.html
Hope this help someone out there.