Wordpress & unable to create directory on Rocky 9

I am tryting to take wordpress for a test drive on Rocky 9 and have not figured how to solve the problem I am getting when trying to install a new theme.

I get the error unable to create directory

I have the directories owned and grouped by apache apache as -

/var/www/html/wordpress/wp-content/themes
drwxrwxr-x

The totorials I viewed so far have not given me help

Has anyone been able to get wordpress working on Rocky 9

Greg

It’s likely permissions and selinux. I would ensure that apache (or whatever you’re using as your web front end, like nginx) owns the directory enough to write to it. If that doesn’t help, it may be selinux, which you will need to investigate a bit using audit2why and audit2allow.

As an aside too, you can get wordpress by doing the following:

dnf install epel-release -y
dnf install wordpress

I haven’t tried to manage an installation this way in a while, but I recall it being easier to manage.

Your directory need to have SELinux httpd_sys_rw_content_t permission, check it with ls -lZ.

This is a good entry point :

You need to be careful with this. Only allow ‘rw’ on e.g. ‘wp-content’, but not on any of the wp core or includes. Once you enable it, you are allowing rogue plugins to create back doors on your server, so in addition, you should restrict wp uploads to not allow running php. Further to that, disallow file mods in wp-config.php, otherwise you could get unexpected sudden plugin updates with no change control. Never update anything from the wp-admin ui, copy the theme and plugins manually. Backup old plugin, delete old plugin, copy new plugin. That way you can easily roll back any changes.

I appreciate everyone’s help

The first installation I performed for worpress was using -

When I read your post and realized that wordpress was in epel I created another guest on our hyoervisor and using the above link except for the installation of wordpress which was installed via epel.

I did have to make selinux addition with ‘semodule -X 300 -i my-phpfpm.pp’

Unfortunately I am getting the same errors of not being able to create a directory in trying to add new themes as well as the plugins.

Any help any of you can give me will be appreciated !!!

Greg Ennis

Thank you
Setting the /usr/share/wordpress/wp-content with httpd_sys_rw_content_t permission
fixed the problem with both the themes and plugins.

Thank you!!
Greg