PhpStorm - Deployment - Cannot Upload New Files - ftp

When I try to create a new file/folder in PhpStorm I get a Permission denied error. However, when I create a new file in a folder that already exists in the root directory of my server I can without any errors.
When I try to create a new file:
[2016-03-07 11:29 AM] Failed to transfer file 'C:\Users\D\PhpstormProjects\example2\test.php': could not write to "sftp://www.example.com/test.php". (Permission denied)
[2016-03-07 11:29 AM] Automatic upload completed in less than a minute: 2 items failed
When I try to create a new folder:
[2016-03-07 11:27 AM] Failed to create folder '/var/www/html/test': could not create folder "sftp://www.example.com/test". (Permission denied)
[2016-03-07 11:27 AM] Automatic upload completed in less than a minute: 1 item failed

You can try this :
chmod -R 777 /var/www
chgrp www-data /var/www
chown -R www-data /var/www
useradd -G {www-data} your_username

The issue solved itself after restart.
PhpStorm support gave this answer:
Please try to run File > Invalidate Caches/Restart > Invalidate and Restart.
If it still fails please send me idea.lof file as described here:
https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files

Prior to deleting, modifying and transferring files, you need to give them the permissions to the data group for the user who will perform the operations.
$ sudo usermod -a -G www-data your_username
$ sudo chgrp -R www-data /var/www/html
$ sudo chmod -R g+w /var/www/html

Checklist:
Make sure you own the files, so if you are in the sudo group then you can do sudo chown -R myusername:sudo /var/www/html/test/. This is to make sure that it will also work for other people in the group.
Make sure that you have write permissions, i.e. read and write access also for the group. You can do this with sudo chmod -R 755 /var/ww/html/test/ (Unfortunately I have found that in practice you sometimes need 777 permissions, but this is not desirable.)
Make sure your deployment path mappings are correct, by going to Settings | Deployment | Mappings, and check that the Deployment path is indeed relative to the root path (under Connection)

After fixing permissions on server you need restart phpstorm. Worked for me on Ubuntu 17.10

Related

Laravel - Every new day I have this error : failed to open stream: Permission denied

i tried by giving permission (775) to bootstrap/cache and storage folder - it works fine on that day but next day it gives error again with new created log file.
The stream or file "/var/www/public_html/myProject/storage/logs/laravel-2021-03-31.log" could not be opened in append mode: failed to open stream: Permission denied in /var/www/public_html/myProject/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:111
i found the solution here:
i have two users on linux server
1 : ubuntu
2 : www-data
i added ubuntu user to www-data group and same as wwww-data to ubuntu group.
so now both users can read there files,
second thing i did is -> i updated app/config/logging.php
and define the permissions (0666) for newly created log file for "daily" and "single".
This might help you:
sudo chown -R www-data:www-data /var/www/{laravel_project_name}
link:
https://dev.to/613596/permission-denied-for-laravel-8-storage-logs-solved-2021-12ld
You have permission issue in your path /var/www/public_html/myProject/storage/logs/.
Try to run the following command
Change the files/directories group to apache/nginx, I used www-data it's the default user of apache on Ubuntu (Use your http server user/group name instead of www-data)
sudo chown :www-data -R /var/www/public_html/myProject/storage/
Now change the file permission once again
sudo chmod 775 -R /var/www/public_html/myProject/storage/
You can also add UID, GID, SID to handle more efficiently

Error in laravel excel export - touch(): Unable to create file /var/folders/ because Permission denied

I install larvel excel and when i try to get the excel it shows the following error
touch(): Unable to create file /var/folders/wg/vbj_bbf14gl7glz__j1xpvg40000gn/T/laravel-excel-62n8RpljR3nr31FGxE96fwrovKEhXPWT because Permission denied
The excel is looking for a path to store the file temporarily before the data is imported. But the filepath leads to the system that maybe of Xampp or any other host that you are using which doesn't provide you the permission to write.
I solved this by going to excel.php file inside config folder and changing the path to
'local_path' => public_path('imported')
Hope this helps.
Add folders to server user-group and setup permissions to STORAGE + BOOTSTRAP/CACHE [on Apache - question did not state server arch]
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
sudo chgrp -R www-data /var/www/html/example/
sudo chmod -R 775 /var/www/html/example/storage

How can I make website with CRUDBooster and Laravel working?

Website based on CRUDBooster and Laravel not working
Tried to change permissions to main directory -r 777
(1/1) UnexpectedValueException The stream or file
"/var/www/storage/logs/laravel.log" could not be opened: failed to
open stream: Permission denied
I'm having this error when I'm trying to access website build with CRUDBooster and Laravel. Already tried to change permissions to 775 and 777 to all folders and subfolders inside but still same error.
Any idea?
Thank you in advance!
You need to give right permissions to storage and bootstrap/cache folders (sudo chmod -R 775 storage and sudo chmod -R 775 bootstrap/cache) and give right group permission to project folder (sudo chown -R $USER:www-data projectFolder). This last one (group permission) is for Apache server7

Laravel 5.5: laravel.log could not be opened: Permission denied

I'm trying to run a simple Laravel command line on my Elastic Beanstalk instance: php artisan queue:work
But I keep getting the following error:
In StreamHandler.php line 107:
The stream or file "/var/app/current/storage/logs/laravel.log" could
not be opened: failed to open stream: Permission denied
I've tried every solution I can find on SO (except the chmod -R 777 advice that seems to trail this question everywhere).
I've tried deleting the existing laravel.log and then using touch to create a new one, and then making sure webapp is the owner.
I've also tried:
sudo chmod -R 755 /var/app/current/storage/
sudo chown -R webapp /var/app/current/storage/
When I list the logs directory, everything looks as I think it should:
-rwxr-xr-x 1 webapp webapp 0 Apr 4 14:38 laravel.log
The storage directory also looks fine:
drwxr-xr-x 6 webapp webapp 4096 Apr 3 19:33 storage
But I'm still getting the above error! Can anyone explain why (not just give a solution).
Thank you
So the simple answer is that I was running the command as ec2-user. As a solution, I could either:
Change the ownership of laravel.log to ec2-user
Run the command as the owner (eg. sudo -u webapp php artisan queue:work)
Switch to root with sudo su to see how it would be run during deployment (ie. as root)
Nothing was especially wrong.
When you log into an EBS instance via ssh, you're logged in as ec2-user.
I don't believe the ec2-user is part of the webapp group which is actually executing PHP & apache/nginx.
Try adding your ec2-user to the webapp group by creating an ebextension in the root of your Laravel project under .ebextensions/ec2user.config
users:
ec2-user:
groups:
- webapp
Prove this is the problem by turning off selinux with the command
sudo setenforce 0
This should allow writing, but you've turned off added security server-wide. That's bad. Turn SELinux back
sudo setenforce 1
Then finally use SELinux to allow writing of the file by using this command
sudo chcon -R -t httpd_sys_rw_content_t storage
And you're off!

Setting read/write permissions on Mongodb folder

I just finished installing MongoDB on OSX and setup a directory structure with sudo mkdir -p /data/db.
When I attempt to run mongod from my user account it returns an error stating that my user account does not have read/write permission to /data/db.
How can I set the proper read/write permissions on my account for /data/db?
Ensure that user account running mongod has the proper directory permissions. You can check which permissions are set like so:
ls -ld /data/db/
If they are set properly they should look something like this..
drwxr-xr-x X user wheel XXX Date Time /data/db/
If the permissions are set incorrectly you will likely see an error similar to this when attempting to run mongod
exception in initAndListen: XXXXX Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
To get the permissions set as they should be you can run the following command
sudo chmod 0755 /data/db && sudo chown $USER /data/db
sudo chmod 777 /data/db/
Should work on Mac. Before running this cmd, permissions look like
drwxr-xr-x X User wheel Date /data/db
after running the cmd
drwxrwxrwx X User wheel Date /data/db
This is what worked for me. I am using a Mac, although you could try if you're using windows.
sudo chmod 777 /data/db
There are three categories of users: owners, those in the group, and everyone else; chmod 777 /path/to/file lets everyone read/write the file, but chmod 775 /path/to/file lets only the owner/group read/write the file. Definitely use chmod 775 /path/to/file if you're developing a web server.
Some useful reading, especially for reasoning behind why 777, 775, and so on are used rather than other numbers: https://www.maketecheasier.com/file-permissions-what-does-chmod-777-means/
None of these suggestions are correct, there's something else wrong with mongodb-org-3.4.16-1.el7.x86_64. It cannot start with a custom db path.
[root#localhost vagrant]# chmod 777 /data/ /data/mongodb
[root#localhost vagrant]# chown mongod:mongod /data/ /data/mongodb
[root#localhost vagrant]# ls -lad /data/mongodb/
drwxrwxrwx. 2 mongod mongod 6 Jul 11 15:24 /data/mongodb/
[root#localhost vagrant]# systemctl start mongod
Job for mongod.service failed because the control process exited with error code. See "systemctl status mongod.service" and "journalctl -xe" for details.
[root#localhost vagrant]# stat /data/mongodb^C
[root#localhost vagrant]# !tail
tail /var/log/mongodb/mongod.log
2018-07-11T15:39:10.786+0000 I STORAGE [initandlisten] exception in initAndListen: 20 Attempted to create a lock file on a read-only directory: /data/mongodb, terminating
2018-07-11T15:39:10.786+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2018-07-11T15:39:10.786+0000 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2018-07-11T15:39:10.786+0000 I CONTROL [initandlisten] now exiting
2018-07-11T15:39:10.786+0000 I CONTROL [initandlisten] shutting down with code:100
[root#localhost vagrant]# rpm -qa | grep mongo
mongodb-org-tools-3.4.16-1.el7.x86_64
mongodb-org-shell-3.4.16-1.el7.x86_64
mongodb-org-server-3.4.16-1.el7.x86_64
mongodb-org-mongos-3.4.16-1.el7.x86_64
mongodb-org-3.4.16-1.el7.x86_64
Just run
sudo chown group:user /data/db
where group is a group of your user
None of the given answers were working for me. I ended up configuring my personal OS user to be the root user, then manually went to the db folder - right clicked to view info - and added myself with read and write permissions.
According to Mongodb University course M103 the permission level will be
sudo chmod 600 /path/to/db

Resources