WordPress knowledge sharing

Enable the detailed process of dynamic and static image text separation of AliCloud OSS object storage website

AliCloud OSS object storage It is a static file storage space launched by AliCloud. If you are using Wordpress, a php dynamic program, you can improve the running speed of ECS by storing static pictures in OSS and dynamic programs in AliCloud ECS Static and dynamic separation of website The purpose is to make users open websites faster and reduce waiting time. In this article, Weiaisi Blog shares the process of setting AliCloud OSS object storage.

This article is applicable to wordpress programs, where the domain name is in HiChina, and AliCloud CDN and AliCloud OSS are used. If you have one item that does not meet the above conditions, you need to manually add and set some content. In fact, it is not troublesome, just press the mouse and keyboard several times, and it is easy for you to understand the principle.

For new students, there are many strange nouns involved in this, and the process is also complicated. Just follow the operation.

1、 AliCloud OSS object storage operations

1、 Click me to open On the AliCloud OSS object storage management console, click the+on the left to start creating buckets, also called buckets.

Bucket name: It can be written casually and can be distinguished. At the same time, this name is also the prefix of CDN accelerated domain names;

Region: If you choose the same region as Alibaba Cloud ECS, you will be charged if you are not in the same region (please ignore local tyrants);

Storage type: standard storage;

Read and write permissions: for accelerating website images, select public reading;

Implementation log query: open the log if you want to study it according to personal needs. It is useless for most small websites.

2. Enter object storage on the AliCloud management console and add an img secondary domain name prefix to the pictures that OSS will store. This is called a custom domain name. Remember to turn on the following AliCloud CDN acceleration and automatically add CNAME records.

Then go to Alibaba Cloud to analyze and see that the system automatically adds cname resolution to the secondary domain name img, which is quite convenient. This function is only available when the domain name is placed on HiChina (also under Alibaba Cloud, and the service has been opened). If the domain name is not available, add it manually.

3. On the object storage console, create two folders: wp content and uploads. The attribute is public read. The image files and folders to be uploaded later are placed under uploads.

4. At this time, go to the/wp content/uploads/folder of the website and download all the contents to the local. If you use the pagoda panel, it is much easier. In the background file management of the pagoda panel, check the uploads folder, and click Compress on the far right. Download the compressed package locally to save time.

The non visual panel can be compressed and downloaded manually.

At this time, I knew the importance of the server bandwidth. Lao Wei tested that the server bandwidth was 1M, and it took too many pictures half an hour to download to the local.

5. Get Access account password

Click me to log in Alibaba Cloud, access control in the upper right corner.

Enter RAM management and create a new user.

Login Name: used to distinguish different Access accounts;

Display Name: describes what the Access is used for;

Check Programmed Access to automatically generate the Access account password.

The finally obtained AccessKey ID and password must be saved to another place. This is displayed only once, and will not be seen again after closing this page.

Question: Some people on the network said that they should authorize three permissions. Old Wei has tested that they can use them without authorization. If you cannot use it without adding authorization, please send a work order to ask Alibaba Cloud customer service.

6. After decompression, upload the contents of uploads to the bucket

A、 How to upload when the number of files is small

Here, Lao Wei encountered a problem. If he used the web side (not recommended, but the OSS browser in the back) to upload the folder directly, Alibaba Cloud would automatically ignore the folder and directly upload the image files, but this would confuse the path order of the folder where the files are located.

The WordPress program will classify pictures by default according to the year of uploading. In this case, all images in/wp content/uploads/2017/will be uploaded to/wp content/uploads/by Alibaba Cloud object storage, and the/2017/folder will be automatically ignored.

The solution is to manually create a corresponding folder in the object store, and then upload it one by one.

Therefore, if there are few files, you can upload them on this webpage. If there are many files (more than 100), the browser will easily get stuck. Old Wei got stuck many times during the test. If there are many files, use the OSS browser software below to upload them.

In the actual test, OSS browser can upload unlimited files (limited by the OSS capacity), while the webpage can only upload 100 files at a time. Note this difference.

B、 Upload a large number of files with OSS browser

Click me to open On the download page, find the client of the corresponding platform to download. After decompression, find and open the installation free green program OSS browser. AccessKey and AccessKeySecret are required for login. Check Remember Key, and leave the rest blank to log in.

Old Wei OSS browser is strongly recommended , you can upload folders directly, and the speed is also fast, which is much better than the web side.

2、 AliCloud OSS plug-in settings

1. Wordpress downloads AliCloud OSS plug-ins in the background. The setting interface is as follows:

AccessKey and AccessKeySecret: These two data have been obtained;

Region/data node: the same region as Alibaba Cloud ECS. Checking intranet can save traffic costs;

Bucket name and bucket domain name: obtained from AliCloud OSS object storage;

Storage path: wp content/uploads/

Tip 1: Bucket domain name can use the accelerated domain name provided by OSS or user-defined domain name. User defined domain names need to manually go to Alibaba Cloud resolution to add CNAME records and apply for SSL certificates with one click. The advantages of using AliCloud for domain name, CDN, ECS and object storage can be seen here. Many settings are automatically added by the system.

Tip 2: Alibaba Cloud OSS plug-ins are all developed by individuals, and there are many different versions. Ask Du Niang to search for one, and the settings are similar. Don't change what you don't understand in the plug-in. There will be mistakes. Remember

After saving, open the web page to test, and check whether the image address prefix is the bucket domain name or custom domain name set above.

3、 Published Article Picture URL Replacement

OSS plug-ins only work on pictures published later. The URLs of previously published pictures still need to be replaced. You can use URLs to replace plug-ins for batch operations.

Weieis Blog reminds you that safety comes first with thousands of data. Website does not back up, webmaster tears Be sure to back up in advance! Backup! Backup! It is important to say three times that we have backup, which is the premise for us to dare to struggle!

Choose one of the following three methods

Plug in 1: WordPress batch replacement url plug-in Velvet Blues Update URLs installation

Plug in II Search&Replace Plug in WordPress Find and Replace Website Link

Manual database replacement: Wordpress domain name replacement, database batch domain name replacement process record

In fact, the whole process can be understood as follows: copy a copy of WordPress pictures into object storage, and then use the OSS plug-in to link the uploaded pictures with OSS. ECS is responsible for processing dynamic files such as php, and OSS is responsible for processing static files such as pictures. This is called dynamic static separation. The advantage is that ECS is more efficient and faster.

Finally, we conclude that Alibaba Cloud OSS object storage has been completed in combination with Alibaba Cloud CDN and Alibaba Cloud ECS. This involves a lot of server proper names and complex operation processes. You can just follow them when you operate. After completion, you may slowly understand what the whole process means in the second and third operations, and form this thinking framework in your mind to deepen the understanding of object storage and Alibaba Cloud products.

Like( four )
Article name: Detailed Process of Opening AliCloud OSS Object Storage Website for Dynamic and Static Image Text Separation
Article link: https://www.vpsss.net/14231.html
Copyright notice: The resources of this website are only for personal learning and exchange, and are not allowed to be reproduced and used for commercial purposes, otherwise, legal issues will be borne by yourself.
The copyright of the pictures belongs to their respective creators, and the picture watermark is for the purpose of preventing unscrupulous people from stealing the fruits of labor.