How should I setup permissions for Wordpress?

So, I’m trying to setup Wordpress on Caddy with permissions which allow me to normally run the site.

I have set up caddy and php on port 9000 (probably going to change or firewall for security reasons).
My site directory is NOT owned by root, but instead by my local user and it’s hosted in my home folder so that I don’t have to invoke root every time I make a tiny change.
I’ve also setup MySQL.
I have given every file in the site directory, 755 permissions.
Whenever I try to install addons, they complain about permissions access and want my ftp password.
Whenever I try to install themes, they want an FTP password. I read on the Wordpress site that this usually stems from lack of permissions.

I tried making everything in my folder 777 but it still wants access to my ftp server. What’s going on?

WordPress uses PHP to interact with files, is your PHP-FPM running as the correct user?

chmod 777 should work around the problem, but it’s a terrible way to go…

I’ve already tried that. I guess that when PHP modfies a file, it makes it root? In that case, I need to change php over to my user or give the entire directory to root. I was just hoping there was another way than for root to have everything.

Yeah, check your www.conf for the user and group settings and change them to the user who has access to the files. I think normally its www-data.

Could you solve your permission problems? I have the problem that I can’t change the theme within the admin panel of the wordpress site. Plugins work fine. Group and User is www-data.

@Tobias, what exactly happens when you attempt to change the theme? Are you able to use the admin panel to install new themes? You say plugins are fine, does that mean you can (de)activate plugins without any problems?

Just to be extra sure with your file permissions, you can cd to the webroot and use the following commands:

sudo chown -R www-data:www-data .
sudo find . -type d -exec chmod 755 {} \;
sudo find . -type f -exec chmod 644 {} \;

@Whitestrake When I click on “upload theme” in the admin panel nothing happens. It’s not possible to upload a theme. Yes plugins I can upload, install and deactivate without a problem. Yes that are exactly my permissions for wordpress. What could it be that I can’t upload a theme? When I look into development tools there are errors like that:
load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:22 Uncaught TypeError: a(…).mouseup is not a function
at load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:22
at load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:22
at load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:22

load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:8 Uncaught TypeError: c is not a constructor
at Function.a.widget (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:8)
at load-scripts.php?c=0&load[]=hoverIntent,common,admin-bar,jquery-ui-position,wp-pointer,underscore,b…:32
at load-scripts.php?c=0&load[]=hoverIntent,common,admin-bar,jquery-ui-position,wp-pointer,underscore,b…:32
at load-scripts.php?c=0&load[]=hoverIntent,common,admin-bar,jquery-ui-position,wp-pointer,underscore,b…:32

load-scripts.php?c=0&load[]=hoverIntent,common,admin-bar,jquery-ui-position,wp-pointer,underscore,b…:25 Uncaught TypeError: Cannot read property ‘hasClass’ of undefined
at HTMLDocument. (load-scripts.php?c=0&load[]=hoverIntent,common,admin-bar,jquery-ui-position,wp-pointer,underscore,b…:25)
at HTMLDocument.dispatch (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:1)
at HTMLDocument.r.handle (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:1)
at Object.trigger (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:1)
at Object.a.event.trigger (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:1)
at HTMLDocument. (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:1)
at Function.each (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:1)
at a.fn.init.each (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:1)
at a.fn.init.trigger (load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,jquery-ui-widget,jquery-ui-core,jquery…:1)
at Object. (load-scripts.php?c=0&load[]=hoverIntent,common,admin-bar,jquery-ui-position,wp-pointer,underscore,b…:25)

Unfortunately your problem has nothing to do with Caddy, PHP, or permissions, I’m afraid.

The issue you’re seeing is with JavaScript. It’s going to be a lot more difficult to diagnose - I’ve seen it happen before with bad WordPress core upgrades, sometimes with different plugins requiring different versions of jQuery, sometimes with theme issues.

The scripts presumably need jQuery to bind some scripted function (like a file selector?) to the mouse click event, but fail because of the load issues. So nothing happens at all.

The best way to go about resolving it is to disable all plugins, revert to a default theme like twenty seventeen, and test for the issue again. If it’s gone, change your theme back, re-test. Then re-enable a plugin and re-test, one by one.

The best place to get further assistance on this issue will be the WordPress support forums.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.