Hello Everyone Welcome to Master2Teach Step by Step guide.
Today in this video, we are going to learn how to store
the WordPress media files in the S3 bucket of AWS.
Please don’t forget to like, share, and subscribe to the channel. Please
feel free to leave a comment in the comment section below.
Ok, here I’m already login to the AWS console. We are starting from S3. In S3,
before creating an s3 bucket, navigate to block public access settings for this account.
In block public access settings, click on the edit button.
Here uncheck the first two checkboxes and check the last two checkboxes.
Click on Save changes. Type Confirm to confirm it.
Now it's time to create the s3 bucket to store all the media files of the WordPress site.
In the buckets section, create a new bucket. Give an appropriate name of the bucket.
Select your current region. I’m from Nepal so my nearest region is Asia Pacific Mumbai. You can
select your own but make sure it should be the correct region. ACLs disable recommended, fine.
Block public access settings, checked the option same as previous.
Unchecked the two options and checked the last two options.
Acknowledge public access.
Bucket versioning - Fine.
Tags - not necessary for now. Default encryption, Fine.
Create Bucket.
Here is a bucket, ok here is a new s3 bucket created.
Now, moving to the next step, that is creating an IAM user. Navigate to the IAM page.
Before creating a new user, let’s create a separate policy for it.
Create Policy.
This is a visual editor. Open the JSON tab.
Paste the policy code over here. You can find this code in the description
below as well as on the site master2teach.com.
We need to mention the bucket name over here. Copy the bucket name, and paste it. Here as well.
Click the Next tag button. Tags are not necessary for now. Next: Review.
Provide an appropriate name for the policy.
Describe the policy so that it can help in
the future to understand for what purpose this policy was created.
Let’s create it.
The policy master2teach policy has been created.
Ok, Let’s move further.
Navigate to the user's page.
Click the add users button to add a new user who can access our s3 bucket.
Provide an appropriate name for it.
In the select AWS access type, checked the access key programmatic access.
Next - Permission.
Select the attach existing policies directly option.
Search for the policy which you have just created before. Here it is mine, select it.
Next: tags
We are escaping tags for now. Next Review. Seems all fine.
Create user.
Ok, there is the access key id and secret access key which we need to
configure in our WordPress site to give access to our s3 bucket.
Please don’t forget to save it properly coz we can’t view it again as we close this page.
Ok, now it's time to move to the WordPress site.
I’m working on my site for now Lokanthali.com
Let’s install a fresh WordPress site.
Here is the WordPress dashboard page. Currently, I'm working on the default theme.
Navigate to the Plugin menu, and add a new plugin.
Search plugin wp offload — here it is, wp offload media lite for Amazon s3.
Install now –
Activate it as well.
Open the plugin setting page.
You must set your storage provider access credentials to enable bucket access.
Let’s process it.
Select Provider - we are using Amazon s3
Connection method - define access keys in the wp-config.php file.
Here is a code that we need to add to our wp-config file.
Let’s copy it and navigate to the wp-config file.
I’m going to edit it live over here from the file manager. Edit.
Scroll down, and paste the code over here.
Add any custom values between this line and the stop editing line.
We need to replace the * with the access key id and secret access key.
Copy it, and paste it over here.
Again Copy it, and paste it over here.
Great, Done - Save changes.
Ok Great, navigate back to settings, here the page will refresh automatically.
It's processing.
Ok, refresh the page.
Great
Select the bucket.
Copy the bucket name and paste it over here.
Copy it, and paste it.
Save bucket settings.
Here both block all public access and object ownership are disabled.
Which should be disabled and if we try to enable it, it will not be allowed to do so.
Let's check it.
Could not change block all public access status for a bucket.
Ok, let’s keep it disabled for now.
We are not storing any media files locally. So enable remove local media option as well.
Save changes.
Add prefix to bucket path.
In the s3 bucket, — here wp-content and uploads prefixes will be added.
Similarly, the year and month folders will be added to the s3 bucket.
Same as the object version to the bucket path.
Here the media path will look like this.
Ok, let’s move ahead. In check in delivery settings.
I'm using HTTPS on the site so let’s enable the force HTTPS option as well.
Save changes.
Here it is.
Ok now let’s check whether it is all fine or not by uploading images to the media.
Open the Media library and add new. Select files. Here is my picture, let’s try it.
Uploading in progress.
Here it goes. Let’s check the path of the image.
The path of the image is in the local system, not in the s3 bucket.
Let’s delete it and go for the solution.
Navigate to the wp offload media lite plugin setting, and check all settings.
Seems all fine.
What we have to do over here is, we have to enable
both - block all public access and object ownership for once and disable it again.
Update changes, — could not change it.
For that, we have to assign the current IAM user to the s3 bucket full access once.
Let’s do that.
Navigate to the IAM page on AWS.
We have all done with these keys, we can leave them now. Open IAM
Click in the user,--- open it.
Click on the add permission button. Again select the same option - attach
existing policies directly and search for s3.
Here is amazon s3 full access - checked it.
Next review -
Add permissions
Here it goes. Ok, navigate back to the offload setting.
Let’s refresh once before we process ahead.
Ok, let’s enable both security settings.
Ok settings locked, requesting refresh the page.
Here are the warnings.
Let’s disable it again.
Unchecked, — Unchecked
Update bucket security.
Ok all done now. Seems all good now. Let’s check by refreshing
the page as well if we get any warnings. Ok Fine.
Let’s check by uploading images to the media library.
Select files
I’m uploading the same image. Open
Uploading in progress.
Here it goes. Let’s check the path of the image.
Ya, you can see the file URL in the s3 bucket which we created before.
Great Job. Let’s check in the new tab. Ya, it’s all good.
Also, let’s check in the s3 bucket. Refresh the page.
Ok, a wp-content folder is created. Let’s check the full path.
Bucket —
Master2teach Bucket — wp content – uploads – year – month – object key – images as objects.
Also, let’s check if the images are uploaded to a local server or not.
Wp- content – uploads – year – month – it's empty.
These folders were created when we tried them before.
In this way, we can set up and manage to store all
media files of the WordPress site in the AWS s3 bucket.
Let’s review the offload plugin setting once.
Make sure you have selected the correct region.
Enable the removal of local media and all these.
In delivery settings, both options are enabled.
Navigate to the edit option of Amazon s3 Provider and connection methods are both ok.
In the bucket, make sure you input the correct bucket name over here.
And last but not least option security,
make sure both are disabled and make sure you have once enabled it and again disable it.
Once all is working fine, you can remove the amazons3fullaccess permission to IAM users.
Detach from the user.
Refresh and confirm.
Ok, it's removed now.
Moving back to the WordPress site. Refresh once.
All is fine here. Navigate to the media library. Let’s remove it first.
Ok, Add new, select files.
Select it again,---- uploading….
Check the path, ok it’s an s3 bucket.
In this way, we can upload and store all media files to store in the AWS s3 bucket over here.
I hope you learn from this video tutorial. Please don’t forget to like,
share, and subscribe to the channel if you haven’t already. Thank you for
watching. See you all soon on the next video tutorials. Bye