I have a new instance and everything was going fine, I have the site installed and transferred over my database and uploaded most my wordpress file to the server.
But towards the end of my upload, files stopped being uploaded and I keep getting the message
***Error: Directory /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/2017/01: no such file or directory
Command: cd "/opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/2017"
Response: New directory is: "/opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/2017"
Command: mkdir "01"
Error: mkdir /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/2017/01: permission denied
Command: mkdir "/opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/2017/01"
Error: mkdir /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/2017/01: permission denied***
I've tried changing the permissions to 755 or 644 but get this error
***Status: Setting permissions of '/opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/2017/07' to '644'
Command: chmod 644 "07"
Error: set attrs for /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads/2017/07: permission denied***
Video file transfer: https://www.screencast.com/t/d8BbFnxkp
Video permission fail: https://www.screencast.com/t/2XBr6zwqd
I'm just puzzled why the other transfers worked
Thanks for your help.
I found this solution that appears to work.
sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads
sudo chmod -R 775 /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads
Then, you can try to upload and check if it works. If it doesn't, you can try doing this instead:
sudo chown -R daemon:daemon /opt/bitnami/apps/wordpress/htdocs/wp-content/uploads
In my case I had this problem while publishing my application from JetBrains Rider to Ubuntu server via SFTP. As there is no way to use sudo, the easy solution was to set publish folder ownership for user, specified in ssh connection for SFTP.
sudo chown -R username:username /var/www/your-app-publish-folder
Or, if you are already logged in under this user on server:
sudo chown -R $USER:$USER /var/www/your-app-publish-folder
Related
I'm setting up laradock (Setup for Multiple Projects) following the official documentation from the Laradock in my local machine.
After installation I installed the laravel through workspace container bash. I did configured the config file for the app in nginx/sites/ directory and in /etc/hosts file.
While visiting the development url I'm getting the following error message:
The stream or file "/var/www/laravel-api/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied
This worked for me:
chown -R www-data:www-data "project foldername"
If you are still facing the issue even after changing the permission and owner of file, just check for the OS of you Linux server.
Login to your server
$ ssh user#server-ip
check your OS running on linux server
$ cat /etc/os-release
//output
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
If it is CentOS, you need to disable Security-Enhanced Linux (SELinux) if enabled.
Check for SELinux status
$ sestatus
If it is enabled, then
$ setenforce Permissive
Or
$ sudo setenforce 0
Have a good day!
you have to enter the workspace first by typing "docker-compose exec workspace bash"(without quotes)
To give a write permission to a single file,
chmod -R 777 /var/www/laravel-api/storage/logs/laravel.log
or
chmod -R 777 /var/www/laravel-api/storage/logs
or
sudo chmod -R 777 /var/www/laravel-api/storage/logs/laravel.log
when the same error appears but different folders or files, do the same thing only change the folder name
example :
chmod -R 777 /var/www/laravel-api/storage/logs
chmod -R 777 /var/www/laravel-api/storage/framework/views
chmod -R 777 /var/www/laravel-api/storage/framework/sessions
If you aren't running your application as root on your web server, then it wont have write access based on the permissions you've provided.
Checked from workspace container bash. storage/logs/ directory has drwxr-xr-x 2 root root 4096 Aug 1 07:37 logs
The error is complaining about permission denial for opening in append mode - it doesn't have permission to write to the file, only root does.
What you need to do is make your web server group the owner of the storage directory:
chown -R www-data:www-data /var/www/laravel-api/storage/
The www-data can be switched out for whatever group your web server is associated with.
To avoid completely repeating an amazing and complete answer, I recommend you give this answer a read:
How to set up file permissions for Laravel?
Give group write access to /storage/logs/
sudo chmod g+w storage/logs
You need to run the following command. It works for me:
step 1:
sudo chmod -R +rwX .
step 2:
sudo chown -R $(whoami) .
I got the following error when entering my site on a production server:
The stream or file "/var/app/current/storage/logs/laravel-2019-11-22.log" could not be opened: failed to open stream: Permission denied
I tried running the following commands and got Permisions denied in the terminal:
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan optimize:clear
I ran chmod -R 775 storage/logs/ and composer dump-autoload and I was able to get onto the home page of my site without any errors. After surfing around the site a bit more I was getting the same error in various areas and not in others:
Again same error
The stream or file "/var/app/current/storage/logs/laravel-2019-11-22.log" could not be opened: failed to open stream: Permission denied
I deleted the following files and ran php artisan cahce:clear:
/bootstrap/cache/packages.php
/bootstrap/cache/services.php
/bootstrap/cache/config.php.php
The only other advice I've seen is run:
sudo chmod -R 777 storage/*
Which seems like a bad idea on a production server, but seems to be upvoted answer. Should I just give my storage director 777 permissions and why? Is there another way of fixing this?
Edit:
I'm trying to do this as stated here:
// set current user as owner and the webserver user as the group
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
// set directory permission to be 775
chmod -R 775 storage
chmod -R 775 bootstrap/cache
but when I run sudo chown -R $USER:www-data storage I get this error:
chown: invalid group: ‘myusername:www-data’
Alright I got the answer:
AWS AMI uses webapp as the web user, not apache or ec2-user as the file shows. In that case, the webapp user has no access rights over those files.
sudo chown $USER:webapp ./storage -R
find ./storage -type d -exec chmod 775 {} \;
find ./storage -type f -exec chmod 664 {} \;
Using the console, go to your synced folder (vagrant)
sudo chown -R $USER:www-data storage
chmod -R 775 storage
I am trying to chown a directory via an NPM script. The script looks like the following:
chown -R 755 www-data root#XXX.XXX.XXX.XX:/var/www/test.com
But the message I get back is: chown: www-data: No such file or directory even though this exists. Any ideas much appreciated.
chown operates locally, not on remote servers. In your example, chown is attempting to operate on ./www-data and ./root#XXX.XXX.XXX.XX:/var/www/test.com, which don't exist in the directory of wherever you were when you executed the command.
You will need to execute chown as a command through ssh:
ssh root#XXX.XXX.XXX.XX chmod -R 755 /var/www/test.com/
Fixed this with following script.
ssh root#XXX.XXX.XXX.XX chmod -R 755 /var/www/test.com/
(I needed to login to the server first).
I am getting this issue for sessions even when I have given 777 and required user and group to the folders in storage.
ErrorException in Filesystem.php line 81: file_put_contents(/var/www/html/business/storage/framework/sessions/2b184c1b05d6d2af943d9a4e48875301321a56ec): failed to open stream: Permission denied
How can I get rid of this issue?
at HandleExceptions->handleError('2',
'file_put_contents(/var/www/html/business/storage/framework/sessions/2b184c1b05d6d2af943d9a4e48875301321a56ec):
failed to open stream: Permission denied',
'/var/www/html/business/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php',
'81', array('path' =>
'/var/www/html/business/storage/framework/sessions/2b184c1b05d6d2af943d9a4e48875301321a56ec',
'contents' =>
'a:5:{s:6:"_token";s:40:"Dyi8ML8zxaQJOEiVvqBpqk3noLDJTkIdqiC67qs9";s:9:"_previous";a:1:{s:3:"url";s:29:"http://XXXXX:8333";}s:22:"PHPDEBUGBAR_STACK_DATA";a:0:{}s:9:"_sf2_meta";a:3:{s:1:"u";i:1470895812;s:1:"c";i:1470895812;s:1:"l";s:1:"0";}s:5:"flash";a:2:{s:3:"old";a:0:{}s:3:"new";a:0:{}}}',
'lock' => true))
I had a problem like that and doing the following solved it for me
chmod -R gu+w storage
chmod -R guo+w storage
php artisan cache:clear
Got it from the answer here
if you try
chmod -R gu+w storage
chmod -R guo+w storage
php artisan cache:clear
and it still doesn't work.
you have two ways:
Disable your SELinux (i really don't recommend this way, unless you are on training or learning)
Configuring SELinux Policies for Apache Web Servers
i want to break down every steps for confirguring selinux policies
assumption: you've already installed all database like mysql, postgresql, or others. you've installed web server
install semanage with command "yum provides /usr/sbin/semanage"
install policycoreutils-python with command "yum install -y policycoreutils-python"
create policies:
a. sudo semanage fcontext -a -t httpd_sys_content_t "/var/www/html/webapp(/.*)?"
b. sudo semanage fcontext -a -t httpd_log_t "/var/www/html/webapp/logs(/.*)?"
c. sudo semanage fcontext -a -t httpd_cache_t "/var/www/html/webapp/cache(/.*)?"
Allowing ReadWrite Access:
a. sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/webapp/storage(/.*)?"
ACCESS YOUR WEBAPP
b. restorecon -Rv /var/www/html/webapp
Giving 777 to the folder session works for me.
chown -R www-data:www-data project_folder
sudo service apache2 reload
chmod -R gu+w storage
chmod -R guo+w storage
php artisan cache:clear
This worked for me for my laravel 8 application.
First run this command in your Laravel app folder
sudo composer update
After that run the following in order
sudo chown -R $USER:www-data storage
sudo chown -R $USER:www-data bootstrap/cache
sudo chmod -R 775 storage
sudo chmod -R 775 bootstrap/cache
run the following command
docker-compose exec <your webserver container name> sh OR bash(if it uses bash)
then
ls -l /var/www/storage/framework/views/ | grep 7369b96b4 (this number is part of the file name you are trying to see it permission) you will see something like this -rw-r--r--
the run
chmod 777 var/www/storage/framework/views/7369b96b436adb2109e56fbb8ed7ba805568c985.php(the full file name)
reload the page
Goto project root folder and run the following command
sudo chmod -R 777 storage/* bootstrap/cache/*
Go to the session folder and make the permission like 755. It's worked for me.
I have an Ubuntu server on Amazon, I installed everything for working with it (php, mysql, phpmyadmin, apache..), The problem is that I cant move around or edit files using the FTP.
I get the error message:
Permission denied.
Error code: 3
Error message from server: Permission denied
from my WINSCP.
The only way I can trancefer/edit file is using 'putty' with the sudo/nano command.
I found a lot of information about this on google, but there are no updated soulution I can find. Linux isn't my usual work-space.
How do I get the permissions working for the WINSCP ?
A lot of answers say to change permissions on /var/www/ ... however AWS shortcuts out of the WWW folder and into the /var/app/current/ directory. If all else fails try:
sudo chown -R -v ec2-user /var/app/current/
On Ubuntu image in AWS, default user is ubuntu. Instead of using system folders like /var/... better to use /home/your_folder. Then change the ownership using {chown} command. For eg.
$ sudo chown -R -v ubuntu /home/your_folder/
This will change the ownership of 'your_folder' and contents inside it from 'root' user to 'ubuntu'. Then Winscp should be able to upload/delete/create files using SFTP/FTP etc..
I had the same issues. The solution is: You can solve this by changing WordPress ownership type:
sudo chown -R www-data:ubuntu /var/www/wordpress
Then, Change the right permission for the particular files and directories, type command
sudo find /var/www/wordpress/ -type d -exec chmod 755 {} \;
sudo find /var/www/wordpress/ -type f -exec chmod 644 {} \;
Apart from this, set the following important files to chmod 600 so that only the owner can fully read and write access to these files:
sudo chmod 600 /var/www/wordpress/wp-config.php
sudo chmod 600 /var/www/wordpress/.htaccess
Then everything will work. You will be able to access your wordpress files
for me using free tier from cloud providers will not give you root access, to fix this you have to change folder permission from SSH or try this solution
OS: windows 10 Pro
Open WinSCP instead of SFTP you select SCP go to advance settings click on SCP/Shell and change the shell option to sudo su -
Now you will be able to get permission.
Change file permision by command chmod 777 /var/app/current/ and transfer files to the directory