Рет қаралды 16,028
Today in this video, we are going to learn how to store the WordPress media files in the S3 bucket of AWS.
Login to the AWS console.
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.
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. 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.
Create Bucket.
Navigate to the IAM page. Before creating a new user, let’s create a separate policy for it.
Create Policy.
Open the JSON tab.
Paste the policy code.
{
"Version": "2012-10-17",
"Statement": [{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObjectAcl",
"s3:GetObject",
"s3:PutBucketAcl",
"s3:ListBucket",
"s3:DeleteObject",
"s3:GetBucketAcl",
"s3:GetBucketLocation",
"s3:PutObjectAcl"
],
"Resource": [
"arn:aws:s3:::your bucket name",
"arn:aws:s3:::your bucket name/*"
]
}
]
}
Copy the bucket name, and paste it. Here as well.
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.
Create policy.
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.
Select the attach existing policies directly option. Search for the policy which you have just created before. Here it is mine, select it.
Create user.
Copy 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.
Let’s install a fresh WordPress site.
Currently, I'm working on the default theme.
Navigate to the Plugin menu, and add a new plugin. Search plugin wp offload - wp offload media lite for Amazon s3.
Install it - Activate it as well.
Open the plugin setting page.
You must set your storage provider access credentials to enable bucket access.
Select Provider - we are using Amazon s3
Connection method - define access keys in the wp-config.php file.
Copy the code and navigate to the wp-config file.
Paste the code.
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.
Navigate back to settings, here the page will refresh automatically.
Refresh the page.
Copy the bucket name 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.
Could not change block all public access status for a bucket.
We are not storing any media files locally. So enable remove local media option as well.
In check in delivery settings. I'm using HTTPS on the site so let’s enable the force HTTPS option as well.
Save changes.
Check whether it is all fine or not by uploading images to the media.
Open the Media library and add new. Select files.
The path of the image is in the local system, not in the s3 bucket.
Delete the image 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.
Navigate to the IAM page on AWS.
Click on the add permission button.
Again select the same option - attach existing policies directly and search for s3.
Amazon s3 full access - checked it.
Navigate back to the offload setting. Let’s refresh once before we process ahead.
Enable both security settings.
Settings locked, requesting refresh the page.
Warnings. Disable it again.
Update bucket security.
Upload image to the media library.
Check the path of the image.
In this way, we can set up and manage to store all media files of the WordPress site in the AWS s3 bucket.
SUBSCRIBE to our KZfaq channel for more videos: www.youtube.co...
Like us on Facebook: / master2teach
For more content go to master2teach.com/