File Gatteway and Wordpress

0

We have an Ubuntu instance running WordPress using AWS File Gateway. We have an S3 bucket mounted, and communication works. We can read and write files from S3 within the local filesystem using the mount. We created a symlink to the WordPress uploads directory. We can read data without problems.

The problem occurs when we want to write a file to S3. We don't know if S3 or File Gateway is rejecting it. We were unable to write the files under the Apache web-data user to S3.

Therefore, we agreed to create a script that will write the file to a local directory and then send it to the mounted S3 directory using the classic copy command.

We need to solve the problem that WordPress also reads from this directory. So, we need some kind of conditional redirection for storing files to the local directory with the web-data owner for storing data in the upload directory. After the file is written, copy will be run on the S3 bucket, i.e. on its local mount, and after copying, it will be deleted in the local directory.

And it will be preserved in the directory - the symbolic link uploads, where reading works without problems. So the problem is to convince WordPress to store files in a different directory and read them from a different directory...............

The second option would be to convince WordPress, or rather Apache, to store files as the nobody user.

Janos
asked 2 months ago128 views
1 Answer
0

To solve the issue of writing files from WordPress to the S3 bucket mounted via File Gateway, here are a few things you can try:

  • Check the IAM role and policies assigned to the EC2 instance. The instance needs permissions to write objects to the S3 bucket.
  • Verify network connectivity from the instance to S3. Ensure no firewall rules are blocking access.
  • Instead of writing directly to the mounted S3 path, write files locally first then copy them over using cp command. This avoids any permission issues.
  • After copying, the file can be deleted from local to avoid duplicating storage. It will remain accessible via the S3 mount point.
  • The symlink from WordPress to the S3 mount will allow reading files smoothly as before without needing to change WordPress configuration.
profile picture
EXPERT
answered 2 months ago
  • That's nice, but I need to split the write and read directories of uploads in WordPress. I need to have one directory for reading and another for writing. When I create a symlink as the uploads directory in wp with a link to /S3, which I have mounted through file gateway, it doesn't allow me to write a file there, but it reads the files correctly. I need to split it so that writing files from wp goes to a different directory and reading for wp is from a different directory.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions