Question

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

I’ve attempterd to change the permissions for wp-content and **uploads ** to “www-data:www-data” but any time I do this it will switch from “root” to “www-data” and then I’m unable to connect to the site and it will switch to https.

Solution

sudo systemctl restart apache2

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
January 30, 2025

Heya, @spencerblackler

Yes! Restarting Apache (systemctl restart apache2) is often necessary after changing file permissions because Apache may need to reload configurations or reset cached permissions. When you change ownership of wp-content/uploads, Apache might still be referencing old permissions.

Regards

KFSys
Site Moderator
Site Moderator badge
January 31, 2025

Heya,

Thank you for sharing the solution. In that light, here is a useful list of when you need and you don’t to restart Apache:

When You Need to Restart Apache:

  1. Configuration Changes (apache2.conf or httpd.conf)

    • Any modification in the main Apache configuration file requires a restart for the changes to take effect.
  2. Virtual Hosts Changes (/etc/apache2/sites-available/*.conf or /etc/httpd/conf.d/*.conf)

    • If you add, remove, or modify virtual host files, a restart ensures the new settings are applied.
  3. Enabling/Disabling Modules (a2enmod, a2dismod)

    • When enabling (a2enmod) or disabling (a2dismod) modules, Apache must be restarted for changes to take effect.
  4. Certificate Renewals (Let’s Encrypt, SSL/TLS Updates)

    • If you update SSL certificates (/etc/letsencrypt/live/...), you need to restart Apache to use the new certs.
  5. Changing PHP Configuration (php.ini)

    • If PHP runs as an Apache module (mod_php), changes to php.ini require an Apache restart.
  6. Changing Apache MPM Settings (mpm_prefork, mpm_event, mpm_worker)

    • Modifications to Apache’s Multi-Processing Modules require a full restart.
  7. Updating Apache Packages (apt update && apt upgrade or yum update)

    • After updating Apache or related dependencies, a restart ensures that the new binaries are loaded.
  8. Applying New Firewall Rules (e.g., UFW, iptables, SELinux changes)

    • If you’ve adjusted firewall rules affecting Apache (e.g., blocking/unblocking ports), restarting can help ensure proper operation.

When You Do Not Need to Restart Apache:

  1. Modifying .htaccess Files

    • Apache reads .htaccess dynamically, so changes apply immediately without a restart.
  2. Updating Website Content (HTML, CSS, JS, Images, etc.)

    • Static file changes do not require an Apache restart.
  3. Updating PHP Files (if running PHP-FPM)

    • If PHP is managed by PHP-FPM, you can restart only php-fpm instead of Apache.
  4. Changing Environment Variables (if using SetEnv in Apache configs)

    • Use systemctl reload apache2 (Ubuntu/Debian) or systemctl reload httpd (CentOS/RHEL) instead of a full restart.
  5. Minor Logging Changes (loglevel adjustments in .htaccess)

    • Logging level changes in .htaccess apply immediately without restarting.
  6. Database Changes (MySQL/PostgreSQL Updates)

    • Apache does not need to be restarted unless database connection settings in Apache config files are modified.
  7. Changes to JavaScript Frameworks (React, Vue, Angular)

    • Since these are frontend changes, Apache is not affected.
Bobby Iliev
Site Moderator
Site Moderator badge
February 2, 2025

Hey Spencer!

What I could suggest is:

1️⃣ Set the correct ownership with:

sudo chown -R www-data:www-data /var/www/html/wp-content/uploads

2️⃣ After that restart Apache with:

sudo systemctl restart apache2

After this, try uploading again. If the issue persists, let me know! 🚀

- Bobby

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.