Permission issue uploading files for WordPress - php

I am running a Ubuntu self-managed VPS. I've installed wordpress and have assigned a user dev to have full write and access permission through the group www-data. Now when I go to install a theme through wordpress I receive a section that ask me for FTP credentials. I assume this is because wordpress finds it is unable to write to wp-content? I went ahead and assigned a chmod 757 to the wp-content directory and it worked but gave me an error message: The uploaded file could not be moved to wp-content/uploads/2015/09.
I have checked who owns what and so far everything seems to be owned by dev user and belongs to group www-data.
Any suggestions?

Chmod 757 makes it so that the group only has read and execute permissions. It is better to have it set to 775. I suspect you also didn't chmod recursively to include all subdirectories. Try this: chmod -R 775 wp-content.
After chatting, we also had to do chown -R www-data wordpress and that fixed the problem.

Related

Laravel root permission messed up

I have this Laravel project on my Ubuntu machine, and i accidentally gave chmod -R 777 to Ubuntu root. I did manage to cancel it, but it was to late. Now, like half of my root is green.
I have nothing useful on this machine except that Laravel project, and I have no problem with re-installing it. Is there a way to rebuild it? If not, when i backup my project, how to give it normal permission?
I've been through this before
Just run
sudo chmod 0644 -R * in your application's root directory
it will set the default permission level to -rw-r--r-- (0644). As new laravel application comes with this permission level.
and you need to give write permission to storage folder and its files so run
sudo chmod 0755 storage and sudo chmod 0755 storage/* -R
You are good to go now. and for more about file and its permission level, I would recommend you to go through this https://askubuntu.com/questions/638796/what-is-meaning-of-755-permissions-in-samba-share it will help.
When you reinstall the project it will gain the regular permissions. Remember that you only have to give 777 permissions to the "storage" folder.
And as far as I know, there is no way to set your Ubuntu files as they were before.
Just change and update permissions of public/ folder inside your Laravel app/ folder to 0775, and then change permissions of files inside public_html/ folder to 0644. Also what is worth of noticing is user:group. What server and how do you run PHP handler?

PHP permission error on writing to a file in Linux CentOS

I have installed linux centos 7 on a VmWare in Windows.
There are two users in the linux: root, sample
I have created a laravel project with user "sample" (logged in as sample), but when I try to run the project with user root (logged in as root), it throws a permission error that cannot write to the file (file_put_content()). I have tried
chmod 777 /var/www/html/laravel
Or even I have tried to change the permission of the write-access of the file to root using right-click->properties->permission, but to no avail.
The only possible solution has been to delete the file and re-create it with user root. Now, what is the solution? I though user root is privileged to do anything. But it seems it is not the case. What is the solution? How should change this issue?
Try chmod 777 -R /var/www/html/laravel/ ,-R is recursive

Unable to create directory wp-content/uploads/2014/07. Is its parent directory writable by the server?

Hi anyone can help me for this issue , I have developed a site and it is hosted on my development server but now my client wants to move it to his own production server, and my client doesn't have access to his cpanel for this server. I only have the ftp access, so I have added his database in my own development server, while in development I used my amazon s3 for storing the images , when I push to production I loss the amazon plugin . I can't able to install the plugin , so I moved to upload once again to those images through WordPress, now I face this error while uploading an image : Unable to create directory wp-content/uploads/2014/07. Is its parent directory writable by the server? , and change the ftp file permission access to 755 and changed the uploads file permission to 777 , Still I am not able to upload the images, can some one help me for this issue.
This is a problem of the Apache permissions. I had this problem and i broke my mind for many days to understand what was happening.
The correct way (USE IT):
(the solution that i used, and worked)
You need to give Rewrite permissions to the Apache.
For Ubuntu:
Run via ssh: chown -R www-data:www-data /var/www/the/wordpress/directory
For Centos:
Run via ssh: chown -R apache.apache /var/www/the/wordpress/directory
The Wrong Way (I don't recommend it, but works...)
You can change the permissions to 777 in all the paths that Wordpress need to change. wp-content/plugins recursively on folders to solve install/update problems, and wp-content/uploads recursively on folders to solve upload media problems.
Never use it because you are giving permissions to anyone change your files. A open way for the crackers that don't like you.
run these command to provide proper file permissions
Add existing 'ubuntu' user to 'www-data' group
sudo usermod -a -G www-data ubuntu;
Set the ownership of the files/directories
sudo chown -R www-data:www-data /var/www/html/;
Set group ownership inheritance
sudo chmod g+s /var/www/html/;
Set the permissions of the files/directories
sudo find /var/www/html/ -type d -exec chmod 755 {} ;
sudo find /var/www/html/ -type f -exec chmod 644 {} ;
Give write permissions to the group (for editing files via FTP)
sudo chmod -R g+w /var/www/html/;

Proper group ownership & permissions to the Laravel app/storage folder on vagrant?

I have successfully set up a Vagrant environment to put my laravel application with all its dependencies, as well as configuring the web server as required. I set this up using ubuntu.
The problem that I have is the app/storage folder. I noticed that the first time I loaded the site, it gave me an error with permissions. I then ran a:
chmod -R a+rwx app/storage
... And that made me load my file properly. When I refreshed, I got a blank screen.
I ran chmod once again, and I had access to my mainpage once again.
I tested my routes only to come with the problem that my application randomly crashed. Running chmod yet again solved this.
I came to the conclusion that my problem is related with group ownership and not so much permissions themselves, because files are being created constantly on the app/storage folder and they are not being created with permissions.
How can I add write permissions to the app/storage folder so everytime new files are made, will have the permissions I need?
Try setting your config.vm.synced_folder as following in the Vagrantfile:
config.vm.synced_folder "/local/folder", "/vagrant/folder", :owner => 'vagrant', :group =>'www-data', :mount_options => ['dmode=775,fmode=775']
You must run chmod -R 755.
Hope this helps.
Bye.

Allow creation of folder on apache2 in Ubuntu Server

I'm creating a site which I'm going to host on an Ubuntu Server. I have a user registration form on my site, which creates a user and a folder for that user (if filled out correctly). The form in handled by PHP and I'm running Apache 2 on the server. When I run the code on my laptop the folder is created, but when I run the same code on the server the folder is not there. I guess that it has something to do with permisssion. How can I tell apache that the code should have write permission in a specific folder called "users" located in /var/www/mysite/public/users/ ???
Try using chmod command that provides folder permission. Something like
chmod 777 -R foldername
If security is not an issue I would suggest:
chmod 775 -R /var/www/
chown -R [your_user]:www-data /var/www/
So both apache2 (www-data) and you can edit folders and files inside /var/www (or /var/www/html if this is your folder).
Notice that this may have issues with git and other tools that capture folder permissions (eg with git you may commit files with 775).

Categories