当前位置:网站首页>Open a new ecological posture | use WordPress remote attachment to store to Cos
Open a new ecological posture | use WordPress remote attachment to store to Cos
2022-06-29 04:45:00 【Cloud storage angel】
Before I read this article , You've probably heard of WordPress 了 , It's using PHP Language development blog platform , Users can support PHP and MySQL Database server set up their own website , Also can put the WordPress As a content management system (CMS) To use .
WordPress Powerful 、 Extensibility is strong , This is mainly due to its numerous plug-ins , Easy to expand functions , Basically a complete website should have the function , All functions can be realized through its third-party plug-ins .
This article will introduce how to realize remote attachment function by using plug-ins , take WordPress The media library attachment of is stored in the Tencent cloud object store COS On , And through Tencent cloud CDN Accelerate , Implement all functions .
One 、 brief introduction
First , Let's learn about saving media library attachments in COS It has the following advantages :
Accessories will have higher reliability ;
When users view the image attachment, they will connect directly COS The server , Does not occupy the downlink bandwidth of your server / Traffic , Faster user access ;
Can cooperate with Tencent cloud CDN Further improve the speed of users to view image attachments , Optimize website access speed .
Two 、 preparation
1、 build WordPress Blog platform .
You can go to WordPress Official page download WordPress And check out the installation guide .
You can also install the server system in Mirror market Select pre installed WordPress The ECS of the blog platform (Cloud Virtual Machine,CVM) Mirror image .
2、 Create a public read private write bucket , The region suggestion and operation of the bucket WordPress Blog platform CVM It's the same place , For creation details, see Create buckets file .
3、 In the bucket list, find the bucket you just created , And click its bucket name , Enter the bucket page .

4、 In the left navigation bar , Click overview , Check the access domain name and record .

3、 ... and 、 Install and configure plug-ins
( One ) Installing a plug-in
stay WordPress backstage , single click plug-in unit > Installing a plug-in , Start installing plug-ins . You can obtain plug-ins and install them in the following two ways :
Background direct search Sync QCloud COS Installation ( Recommended ).
You can also choose from Github Download the latest releases Source code , adopt WordPress Upload and install in the background , Or upload the source code directly to WordPress Plug-in directory
wp-content/plugins, Then enable... In the background .
( Two ) Configuration plug-ins
1、 single click WordPress Left navigation bar settings , Then configure... In the page COS Information about , See the following table for configuration description :
| Configuration item | Configuration values |
|---|---|
| Bucket name | Custom name when creating bucket |
| Bucket area | The region selected when creating the bucket |
| APPID | APPID It is the account you obtained after successfully applying for Tencent cloud account , Automatically assigned by the system , It is fixed and unique , Can be found in Account information View in |
| SecretID、SecretKey | Access key information , You can go to cloud API secret key In order to get |
| Don't upload thumbnails | If checked, the corresponding thumbnail file will not be uploaded , It is not recommended to check |
| Do not keep backup locally | If checked, the source file will not be retained locally , It is not recommended to check |
| Local folder | Local save path , for example wp-content/uploads |
| URL Prefix | The format is <COS Access to the domain name >/< Local folder >, for example https://examplebucket-1250000000.cos.ap-shanghai.myqcloud.com/wp-content/uploads |
2、 When the configuration is complete , Click save .
3、 Upload a new file to test , See attachment details , Check the attached picture URL, Confirm the attached picture URL Point to Tencent cloud COS.

Four 、 Expand
1、 Use CDN To speed up access :
If the bucket needs to be configured CDN Speed up , See also CDN Acceleration configuration file . In the plug-in settings URL Prefix changed to default CDN Acceleration domain name or custom acceleration domain name .
2、 Replace the resource address in the database :
If it's not a newly created site , The database must be the old resource link address , We need to replace the resource address , The plug-in provides a replacement function , Please remember to back up before the first replacement .
Old domain name fill in the original resource domain name , for example https://example.com/
New domain name fill in the current resource domain name , for example https://img.example.com/
3、 Set up cross domain access :
Reference the corresponding resource link in the article , The console will prompt for cross domain errors No 'Access-Control-Allow-Origin' header is present on the requested resource.
The reason is that no header. You need to access... Across domains CORS Add... To the settings HTTP Header To configure . There are two ways to configure :

i. stay CDN Configuration on the console
If all domain names are allowed , The configuration is as follows :
Access-Control-Allow-Origin: *ii. Only your own domain name is allowed to access , The configuration is as follows :
Access-Control-Allow-Origin: https://example.com4、 Set back to source :
If not WordPress Upload resources in the background media library , It is recommended to turn on the back to source setting . After opening , Client first access COS Source file ,COS When you find that you can't hit an object , Return... To the client 302 HTTP Status code and jump to the address corresponding to the source address , At this time, the object is provided by the source station to the client , Make sure to visit .
meanwhile COS Copy the file from the source and save it to the directory corresponding to the bucket ; On the second visit COS Hit the object directly and return it to the client .
5、 ... and 、 summary
In this paper, WordPress Media library attachments for remote to object storage COS This is the end of practice sharing , The follow-up will bring you a series of information about the ecological platform / Plug in related content , in addition , We will also bring you a variety of ecological empowerment activities , Please look forward to !
Information about eco plug-ins and other activities
Welcome to the exchange group , Get the latest information about ecological activities

— END —
边栏推荐
- Experience sharing of system analysts in preparing for exams: phased and focused
- 泰克TDS3054B示波器技术指标
- 笔记本访问台式机的共享磁盘
- Template method pattern
- 从零到一,教你搭建「以文搜图」搜索服务(一)
- February 14 institutional dragon and tiger list and operation of well-known hot money
- Network device setting / canceling console port login separate password
- The people's Bank of China printed and distributed the notice on supporting cross-border RMB settlement of new foreign trade formats
- Iterator pattern
- 1017 a divided by B
猜你喜欢

EEG signal processing - wavelet transform series

How to display all MySQL databases

网传广东一名学生3次考上北大,3年共赚200万元奖金

innography

Technical specifications of Tektronix tds3054b oscilloscope
![[结构力学] 结点承载下影响线与直接承载下影响线不同的原因](/img/a6/fce0bb29cc5c84bc0ef20501617e06.png)
[结构力学] 结点承载下影响线与直接承载下影响线不同的原因

【牛客网刷题系列 之 Verilog快速入门】~ 异步复位的串联T触发器

ROS URDF model is parsed into KDL tree

Apifox: it is not only an API debugging tool, but also a collaboration artifact of the development team

Decorator Pattern
随机推荐
Résultats D - exam de Qinhuangdao au cours des 20 dernières années
BERT和ViT简介
Live broadcast appointment AWS data everywhere series activities
gan semi conductor
【牛客网刷题系列 之 Verilog快速入门】~ 异步复位的串联T触发器
Using assetstudio/unitystudio uabe, etc
Decorator Pattern
Mediator pattern
LabVIEW显示Unicode字符
Research Report on the overall scale, major manufacturers, major regions, products and application segments of semiconductor wafer metal stripping platform in the global market in 2022
Cisco voice card handling configuration
How to test electronic components with a multimeter
波形记录仪MR6000的实时波形运算功能
See how I do it step by step (I)
直播预约|AWS Data Everywhere 系列活动
汉泰示波器软件|汉泰示波器上位机软件NS-Scope,任意添加测量数据
Alibaba microservice component Sentinel
Cipher
Research Report on the overall scale, major manufacturers, major regions, product and application segmentation of the gsm-gprs-edge module of the Internet of things in the global market in 2022
docker 创建的 mysql8 怎么改密码