Question

Block Storage with Wordpress No Longer Web Writable in Ubuntu 20.04?

Posted July 5, 2021 228 views
WordPressBlock Storage

I have previously set up my wordpress installation successfully, with a mount at /mnt/MNTNAME and a symlink in my wordpress web directory ../public_html/wp-content/uploads. This was in Ubuntu 18.04. All was well, able to upload media in wordpress without issue.

I am working on an upgrade to the server, and migrated the install, and wasn’t able to figure out why on the new server, everything works except media uploads in wordpress.

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

After many hours of investigation, I think I’ve finally narrowed it down. Since the /mnt/ folder is outside of the web-writeable ../public_ html, the error comes up. As soon as I move the mnt into /public_ html, it works. This was not the case before. Any suggestions on how I can keep the previous setup and still get uploads to work with /mnt/ outside of the web writeable directory?

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.

×
Submit an Answer
1 answer

Hello,

It sounds like that you might have SELinux enabled. To check if this is the case run the following command:

getenforce

If SELinux is enabled, you could allow the Apache service to write to that specific directory with the following command:

chcon -R -t httpd_sys_rw_content_t /mnt/path

Alternatively, you could manually mount the disk to your uploads directory directly, as per the instructions here:

https://docs.digitalocean.com/products/volumes/how-to/mount/

Regards,
Bobby

  • Hi,

    getenforce is not installed. Doesn’t seem like SE Linux is?

    Anyway, the solution you recommended is what I had settled on - directly mounting to the uploads directory. Only problem, can only use the mount for one website on the server.

    Thanks for the reply.

    • Hi there,

      As you don’t have SELinux installed, I think that you could also adjust this behavior in your /etc/apache2/apache2.conf file directly.

      Mainly this section here:

      # Sets the default security model of the Apache2 HTTPD server. It does
      # not allow access to the root filesystem outside of /usr/share and /var/www.
      # The former is used by web applications packaged in Debian,
      # the latter may be used for local directories served by the web server. If
      # your system is serving content from a sub-directory in /srv you must allow
      # access here, or in any related virtual host.
      <Directory />
              Options FollowSymLinks
              AllowOverride None
              Require all denied
      </Directory>
      
      <Directory /usr/share>
              AllowOverride None
              Require all granted
      </Directory>
      
      <Directory /var/www/>
              Options Indexes FollowSymLinks
              AllowOverride None
              Require all granted
      </Directory>
      

      To grant access to another directory, you could add an extra rule after the first 3 rules, like this:

      <Directory /some/other/path/>
              Options Indexes FollowSymLinks
              AllowOverride None
              Require all granted
      </Directory>
      

      Then run a config test with:

      sudo apache2ctl configtest
      

      And if you get Syntax OK restart Apache:

      sudo systemctl restart apache2
      

      Alternatively, you could mount your block storage to /var/www/some_folder and you should be able to use your symlink approach as normal.

      Let me know how it goes.
      Regards,
      Bobby