I am trying to update a WordPress plugin and I receive this error message:
Update failed: Could not create directory. /var/www/html/wp-content/upgrade/akismet.5.3
When I go to Tools > Site Health > Info > File Permissions, I see this:
How can I make those directories Writable? I thought it would by using 755 recursively for /var/www/html/wp-content
, but I already have those permissions and it is still not working.
The problem was the user Apache was running as. To fix it, I opened this file:
/etc/apache2/envvars
, and I commented out a couple of lines, replacing them with the user that I wanted to run Apache as:
# Since there is no sane way to get the parsed apache2 config in scripts, some
# settings are defined via environment variables and then used in apache2ctl,
# /etc/init.d/apache2, /etc/logrotate.d/apache2, etc.
#export APACHE_RUN_USER=www-data
export APACHE_RUN_USER=jmontoya
#export APACHE_RUN_GROUP=www-data
export APACHE_RUN_GROUP=jmontoya
Then I restarted Apache with sudo service apache2 restart
.
I confirmed that Apache was now running as my desired user:
ps axo user,group,comm | egrep '(apache|httpd)'
root root apache2
jmontoya jmontoya apache2
jmontoya jmontoya apache2
jmontoya jmontoya apache2
jmontoya jmontoya apache2
jmontoya jmontoya apache2
jmontoya jmontoya apache2
Everything in /var/www/html/wp-content
also belongs to jmontoya
, which I specified it with chown
. Permissions are properly defined with chmod
.
Now I see what I expected: