当前位置:网站首页>Open a new ecological posture | use the wrodpress remote attachment to store it in COS
Open a new ecological posture | use the wrodpress remote attachment to store it in COS
2022-06-27 20:58:00 【cloud storage】
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 /< 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 —
边栏推荐
- 分享下我是如何做笔记的
- "Good voice" has been singing for 10 years. How can the Chinese language in the starry sky sing well in HKEx?
- #夏日挑战赛# OpenHarmony HiSysEvent打点调用实践(L2)
- Question brushing notes - tree (easy) - updating
- The meta universe virtual digital human is closer to us | Sinovel interaction
- Grasp the detailed procedure of function call stack from instruction reading
- 教程|fNIRS数据处理工具包Homer2下载与安装
- Leetcode 1381. Design a stack that supports incremental operations
- 1029 Median
- Univision hyperinsight: Nuggets' $16.494 billion "gold hoe" in the observable market?
猜你喜欢

实现字符串MyString

CSDN 技能樹使用體驗與產品分析(1)

muduo

pfSense Plus22.01中文定制版发布

CocosCreator播放音频并同步进度

"Good voice" has been singing for 10 years. How can the Chinese language in the starry sky sing well in HKEx?

灵活的IP网络测试工具——— X-Launch
I haven't thought about the source for some time. After upgrading to the latest version 24, the data encryption problem is repeatedly displayed

OpenSSL client programming: SSL session failure caused by an obscure function

NVIDIA三件套环境配置
随机推荐
大促场景下,如何做好网关高可用防护
Massive data attended the Lanzhou opengauss meetup (ECOLOGICAL NATIONAL trip) activity, enabling users to upgrade their applications with enterprise level databases
Oracle 架构汇总
Summary of redis big key problem handling
At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions
Sharing | intelligent environmental protection - ecological civilization informatization solution (PDF attached)
Leetcode 989. Integer addition in array form (simple)
When developing digital collections, how should cultural and Museum institutions grasp the scale of public welfare and Commerce? How to ensure the security of cultural relics data?
最佳实践:优化Postgres查询性能(下)
UOS提示输入密码以解锁您的登陆密钥环解决办法
本周二晚19:00战码先锋第8期直播丨如何多方位参与OpenHarmony开源贡献
众昂矿业:新能源或成萤石最大应用领域
[array]bm99 clockwise rotation matrix - simple
数据仓库体系之贴源层、历史层
一场分销裂变活动,不止是发发朋友圈这么简单
Database index
ABAP-CL_ OBJECT_ Collection tool class
Unity3d button adapts the size according to the text content
实现字符串MyString
[STL programming] [common competition] [Part 1]