Ho do I fixe permission denied when trying to upload a file to my wordpress server using file zila - wordpress

please can anyone help with a solution? am getting an error message that says permission denied anytime I try to upload files to my (LEMP) server using File Zila. I have tried changing the file permission in File Zilla to 777 but still does not work.

if you have SFTP then follow below steps:
sudo chmod -R o+rw /var/www/html /* Location for folder or file */
chmod -R 755 /var/www/html/ /* Location for folder or file */

If you are trying to give the {user} as well as the www-data both access to the website directory try this
//without {}
sudo usermod -a -G www-data {userName}
#This adds user to www-data group
//set permissions for user group www-data
sudo chgrp -R www-data /var/www/html
//followed by
sudo chmod -R g+w /var/www/html
this will enable {user} to use SFTP with the FileZilla or other programs to read and write files in the directory without sudo

Related

Amazon AWS EC2 Openlitespeed Permissions for SFTP

I setup SFTP on the EC2 Instance with Openlitespeed via Filezilla and it connects but I could not upload, delete or move files.
I then tried the solution suggested on this post:
Amazon AWS Filezilla transfer permission denied
So for UBUNTU,
sudo chown -R ubuntu:ubuntu /var/www/html
sudo chmod -R 755 /var/www/html
This solved that problem but now wordpress is asking for FTP details to install a plugin and the config.php and .htaccess is no longer writable (enabling/disabling litespeed cache plugin).
So this has reset the permission for wordpress as well. Does anyone have the solution how to fix the wordpress permissions on the server?
Thank you in advance.
you need to match the user that runs OLS/LSPHP
run grep -i "user" /usr/local/lsws/conf/httpd_config.conf to get the user that runs OLS , which I assume it should be www-data
then you need to chown -R www-data:www-data /var/www/html
after that, do :
find /var/www/html -type d -exec chmod 0755 {} \;
find /var/www/html -type f -exec chmod 0644 {} \;
to restore the file perm to 644, and dir perm to 755, as its previous status that ditrubted by your chmod -R 755 command.

Nginx permissions with wordpress

I am trying to set up wordpress on digitalocean with nginx. I am running into permissions issues though. When I upload a file or try to install a plugin I get the cannot create in directory warning. So I came across the post Here that says I need to give nginx access to the folder. So I executed the following:
sudo chown -R www-data:www-data /path/to/folder
sudo chmod -R 755 /path/to/folder
This works except now I cannot add and delete files with filezilla. Obviously because the permissions to the folder are no longer with the me the user they are now with www-data.
So my question is what is the correct way to configure nginx to work with wordpress and still allow me to upload and delete files with ftp.
When using digital ocean droplets you will probably be using sftp access to your server.
Try the following commands in your terminal when logged in.
Add your currently logged in user to the www-data group:
sudo usermod -aG www-data $USER
Then change your vhost directory and all files and subdirectories to be owned by www-data group:
sudo chown -R www-data:www-data /var/www
Set the proper permissions so you can upload files via sftp, manage files via command-line, and upload plugins and media directly in WordPress:
sudo chmod -R 774 /var/www
Hope this helps
Saskia

WordPress File Access Permission

I am trying to upload an image to set a background image for my theme, but I get this error:
Unable to create directory wp-content/uploads/2018/05. Is its parent directory writable by the server?”
I tried to change the access permissions with the help of these blogs:
https://www.digitalocean.com/community/questions/setting-permissions-for-wordpress
https://gist.github.com/Adirael/3383404
But nothing has helped me, and now I also get a 500 error page.
I'm stuck here, can anybody help?
-----------Comment-----------
Output Image for ps -ef| grep httpd
I executed this command
find . type f -exec chmod 644 {} \;
and the 500 error page is not being displayed now. I am able to view my web page. But I am still unable to upload a background image. (same error appears "Unable to create directory wp-content/uploads/2018/05. Is its parent directory writable by the server?")
The following command will fix your issue
sudo chmod -R 777 wp-contents/uploads/
If you're using Bitnami Lamp then run the following commands in your SSH terminal:
sudo chown -R bitnami:daemon /opt/bitnami/apache/htdocs
sudo chmod -R g+w /opt/bitnami/apache/htdocs
sudo chmod 440 /opt/bitnami/apache/htdocs/wp-config.php
sudo chmod 440 /opt/bitnami/apache/htdocs/.htaccess
and if you're using Bitnami WordPress then run the following commands in your SSH terminal:
sudo chown -R bitnami:daemon /opt/bitnami/apps/wordpress/htdocs
sudo chmod -R g+w /opt/bitnami/apps/wordpress/htdocs
sudo chmod 440 /opt/bitnami/apps/wordpress/htdocs/wp-config.php
sudo chmod 440 /opt/bitnami/apps/wordpress/htdocs/.htaccess
The recommended permissions are:
Directories: 775
Files: 640
wp-config.php and.htacess: 440
Thanks
Maybe is already solved, but can help other users with similar issues.
I made a Shell Script on Debian10 to solve permissions issues.
After running it, I make the folder accesible on the Apache2.conf too (WordPress can't Upgrade or Upload Media if not)
What it does:
Set new Owner on all Files and (Sub)Directories ( user:group )
Set Permissions: 755 to Directories and 644 to Files
wp-config.php : Preventing world access for "wp-config.php", leaving it accesible to WordPress (660)
Allow WordPress to manage the "wp-content" (Directories to 755 & Files to 664)
Privatize "wp-content" (Set 755)
Link:
https://github.com/ieselisra/wordpress_fix_permissions_debian10/

What to set permissions to when developing a wordpress site locally

I've setup a domain through apache virtual hosts and set the permissions on the public_html directory as $USER:$USER. I also have wordpress installed in public_html/wp
When trying to add a local image to the media part of the site, wordpress threw an error saying it did not have permission to create the required folder to store the image. The directories are set to 755 and files to 644 so I assumed it was the ownership that needed to change. So I ran
sudo chgrp -R www-data /var/www/virtual-host-site.dev/*
So my ownership looked like $USER:www-data however, this still didn't give wordpress rights, so I tried
sudo chown -R www-data:www-data /var/www/virtual-host-site.dev/*
which fixed the problem. But then as a user, I have no write access to the directories. I thought adding $USER to the group www-data
sudo usermod -a -G www-data $USER
would give $USER rights like www-data, but this doesn't seem to be the case.
How do I keep my folders as 755 and files as 644 while allowing both $USER and wordpress write access to the application directories?
Thanks.
So I resolved this by changing my dev directory to www-data:www-data and changing my themes folder to $USER:www-data with the command
sudo chown -R $USER:www-data wp/wp-content/themes

To copy files each minute at /var/www without sudo

How can you copy a folder to /var/www without sudo?
My folder codes has the following permissions at /var/www
4 drwxr-xr-x 8 root root 4096 2009-08-09 03:01 codes
I can only sudo cp -r ~/Dropbox/codes/ /var/www to copy the files.
I cannot copy them without sudo.
Owning /var/www yourself might conflict with other options on your system. On my Debian system I would do this
sudo addgroup www
sudo adduser nr www # add myself to the www group
sudo chgrp -R www /var/www # make files in the group
find /var/www -type f -exec chmod g+w '{}' ';' # make each file group writable
find /var/www -type d -exec chmod g+ws '{}' ';' # make each directory group writable and sticky
If the directory is group writable and sticky, all files created in /var/www will be writable by anyone in the www group, no matter who or what creates them there. (Caveat: they have to be created by "normal" means; cp -a can circumvent the group sticky bit.)
Because Unix is insanely stupid about group membership, for your membership to be honored you will have to log in again, e.g., ssh localhost or log out and log back in. A nuisance.
What about adding the cron job to the root user. It's not a great idea, but it will get around the problem?
I also find it interesting that your www directory would have only root permissions and be owned by root. Usually they are owned by an apache user or have other permissions such that apache can access them.
Edit You probably don't want to edit the crontab file directy. But something similar to the following command should work:
sudo crontab -e -u root
You may not need the -u root but it's good so sudo doesn't confuse crontab.
Edit 2 You can change permissions with the chmod and chown commands:
sudo chmod 755 /path
sudo chown user:user /path
Be very very careful when using this. You can completely screw up the OS by changing permissions on the wrong files or folders. You'll probably want to add the -R option which will apply the permissions or owner recursively, but again, be very careful.
sudo chown yourusername /var/www
And you'll become the new owner of /var/www.

Resources