何時(shí) WordPress 最初只是一個(gè)博客平臺(tái),但它不斷發(fā)展成為一個(gè)完整的內(nèi)容管理系統(tǒng),為用戶提供創(chuàng)建和發(fā)布內(nèi)容的能力。 發(fā)布精彩的網(wǎng)站和博客。插件數(shù)據(jù)庫(kù)是最大的數(shù)據(jù)庫(kù)之一 并且還在不斷增長(zhǎng)。最大的 WordPress 引擎的簡(jiǎn)單性對(duì)我來(lái)說(shuō)很有吸引力。它需要非常 建立并運(yùn)行由 WordPress 驅(qū)動(dòng)的博客幾乎不需要什么。
說(shuō)起來(lái)簡(jiǎn)單, 最小并不意味著不能根據(jù)自己的喜好進(jìn)行修改或 要求。您可以將 WordPress 驅(qū)動(dòng)的網(wǎng)站變成照片博客、 專業(yè)的在線作品集、新聞網(wǎng)站、在線社區(qū),甚至是 在線電子商務(wù)商店。使用時(shí)您僅受想象力的限制 WordPress!
開(kāi)發(fā)人員有時(shí)是控制狂。好的,大多數(shù) 他們是控制狂。他們想要控制每一件小事 這涉及到他們的應(yīng)用程序或網(wǎng)站的制作。話雖如此,WordPress 提供多種選項(xiàng),以便您可以在任何方面擴(kuò)展它 方向取決于你的喜好。您可以使用以下方式為您的網(wǎng)站創(chuàng)建插件 WordPress API。
創(chuàng)建插件后,您可以將其托管在 WordPress 中 插件存儲(chǔ)庫(kù)。除此之外還有主題存儲(chǔ)庫(kù),您可以在其中提交 您自己創(chuàng)建的主題。您可以創(chuàng)建自定義帖子類型、分類法和 特定于您的應(yīng)用程序或網(wǎng)站的元數(shù)據(jù)。說(shuō)到應(yīng)用程序,您可以輕松地 管理用戶、數(shù)據(jù)庫(kù)和 HTTP 請(qǐng)求。這就是我們要研究的內(nèi)容 本教程。
我們將在 Google App Engine 中為我們的 WordPress 網(wǎng)站設(shè)置一個(gè) Cloud SQL 實(shí)例。這將允許我們的網(wǎng)站使用 Google 的服務(wù)器,這將影響我們的 WordPress 網(wǎng)站或博客的加載時(shí)間??傮w結(jié)果將是快速加載時(shí)間和順利處理訪問(wèn)您的網(wǎng)站或博客的流量。
什么是 Google App Engine?
根據(jù) Google 的說(shuō)法:
“谷歌 App Engine 是一種平臺(tái)即服務(wù) (PaaS) 產(chǎn)品,可讓您構(gòu)建 并在 Google 的基礎(chǔ)設(shè)施上運(yùn)行應(yīng)用程序。應(yīng)用引擎 應(yīng)用程序易于構(gòu)建、易于維護(hù)并且易于根據(jù)您的需要進(jìn)行擴(kuò)展 流量和數(shù)據(jù)存儲(chǔ)需要改變?!?p>由于我們正在與 Google 打交道,因此我們將能夠使用 Big G 的基礎(chǔ)設(shè)施。本質(zhì)上,我們將使用相同的服務(wù)器來(lái)托管我們的 WordPress 網(wǎng)站或博客,因此我們可以說(shuō)我們正在使用 Google托管 Blogger 以外的其他內(nèi)容。
設(shè)置 Google App Engine
要使用 Google App Engine,我們需要一臺(tái)可以運(yùn)行本地服務(wù)器和 Python 的計(jì)算機(jī)。您需要首先在您的計(jì)算機(jī)上設(shè)置本地服務(wù)器。這將來(lái)會(huì)有幫助,因?yàn)槟梢栽趯⒕W(wǎng)站發(fā)布到網(wǎng)上之前測(cè)試更新。要設(shè)置完整的本地服務(wù)器以使用 Google App Engine,我們需要來(lái)自互聯(lián)網(wǎng)的以下軟件。
最重要、最明顯的是 Google App Engine 軟件開(kāi)發(fā)工具包 (SDK) for PHP (SDK),以及使用 MySQL 服務(wù)器的本地服務(wù)器。您還應(yīng)該運(yùn)行安裝 Python 的。獲取要在本地服務(wù)器上使用的 WordPress 的全新副本,或者您也可以下載附件,其中包含準(zhǔn)備好為 WordPress 啟用 Google App Engine 的所有文件。
步驟 1
注冊(cè) Google Cloud Platform,因?yàn)槲覀冃枰?Cloud SQL 實(shí)例。設(shè)置實(shí)例很容易。您需要在中創(chuàng)建一個(gè)新項(xiàng)目 the Google Developers Console. So we'll set up a test project for 本教程。
輸入必要的詳細(xì)信息后,轉(zhuǎn)到 存儲(chǔ) > Cloud SQL > 新實(shí)例。輸入實(shí)例名稱,然后按住 因?yàn)槲覀儗⑹褂孟嗤拿Q來(lái)連接到 WordPress。您需要啟用計(jì)費(fèi)功能,以便您 可以連接到該實(shí)例。
步驟 2
下一步
我們將繼續(xù)設(shè)置本地服務(wù)器,以便我們可以運(yùn)行 WordPress
谷歌應(yīng)用程序引擎。為此,您需要?jiǎng)?chuàng)建三個(gè)文件: aap.yaml
,
cron.yaml
和 php.ini
。在此過(guò)程中,下載最新版本的 WordPress 并將其解壓到您的硬盤上。將解壓出來(lái)的文件夾和
將三個(gè)文件放在一個(gè)新文件夾中,并將其命名為 App Engine
。這些文件的代碼如下。
應(yīng)用程序.yaml
application: name_of_project_id version: wpfromstarterproject runtime: php api_version: 1 handlers: - url: /(.*\.(htm$|html$|css$|js$)) static_files: wordpress/\1 upload: wordpress/.*\.(htm$|html$|css$|js$) application_readable: true - url: /wp-content/(.*\.(ico$|jpg$|png$|gif$)) static_files: wordpress/wp-content/\1 upload: wordpress/wp-content/.*\.(ico$|jpg$|png$|gif$) application_readable: true - url: /(.*\.(ico$|jpg$|png$|gif$)) static_files: wordpress/\1 upload: wordpress/.*\.(ico$|jpg$|png$|gif$) - url: /wp-admin/(.+) script: wordpress/wp-admin/\1 secure: always - url: /wp-admin/ script: wordpress/wp-admin/index.php secure: always - url: /wp-login.php script: wordpress/wp-login.php secure: always - url: /wp-cron.php script: wordpress/wp-cron.php login: admin - url: /xmlrpc.php script: wordpress/xmlrpc.php - url: /wp-(.+).php script: wordpress/wp-\1.php - url: /(.+)?/? script: wordpress/index.php
Cron.yaml
cron: - description: wordpress cron tasks url: /wp-cron.php schedule: every 2 hours
PHP.this
google_app_engine.enable_functions = "php_sapi_name, gc_enabled" allow_url_include = "1" upload_max_filesize = 8M
在 app.yaml
中
文件,將 your-project-id
更改為我們剛才創(chuàng)建的,然后保存
它。
步驟 3
啟動(dòng)
MySQL 命令行客戶端。它會(huì)要求您輸入密碼。我將我的設(shè)置為
當(dāng)我安裝MySQL服務(wù)器時(shí),輸入“root”,所以我輸入“root”并按Enter。
我們將使用控制臺(tái)為我們創(chuàng)建一個(gè)數(shù)據(jù)庫(kù)。輸入代碼 創(chuàng)建數(shù)據(jù)庫(kù) wp_database;
,其中 wp_database
是我們要?jiǎng)?chuàng)建的數(shù)據(jù)庫(kù)的名稱。
現(xiàn)在我們的
數(shù)據(jù)庫(kù)已創(chuàng)建,我們希望 WordPress 使用它。
導(dǎo)航到提取的 WordPress 副本并打開(kāi) wp-config.php
。輸入數(shù)據(jù)庫(kù)和用戶名的詳細(xì)信息。此外,您還必須將 define('DB_HOST', 'localhost');
替換為以下代碼段。
if(isset($_SERVER['SERVER_SOFTWARE']) && strpos($_SERVER['SERVER_SOFTWARE'],'Google App Engine') !== false) { define('DB_HOST', ':/cloudsql/YOUR_PROJECT_ID:wordpress'); }else{ define('DB_HOST', 'localhost'); }
Replace your_project_id
?with your Cloud SQL Instance ID name, and save 它。
步驟 4
執(zhí)行 Google App Engine 啟動(dòng)器,啟動(dòng)時(shí)按 Control-Shift-N 或轉(zhuǎn)到文件
然后點(diǎn)擊添加現(xiàn)有應(yīng)用程序...瀏覽到我們命名為“App”的文件夾
Engine”,然后點(diǎn)擊確定。Google App Engine 將讀取 app.yaml
文件并加載
來(lái)自它的數(shù)據(jù)。
按綠色按鈕運(yùn)行應(yīng)用程序引擎。等一下 稍等片刻,然后單擊瀏覽按鈕。第一次瀏覽時(shí) 您的應(yīng)用程序,它將向您呈現(xiàn)著名的 WordPress 五分鐘安裝頁(yè)面。添加 在用戶名和密碼等詳細(xì)信息中。另外你可能不想要 搜索引擎對(duì)其進(jìn)行索引,因此請(qǐng)取消選中該框。
現(xiàn)在您已準(zhǔn)備好開(kāi)始創(chuàng)建您的 應(yīng)用。創(chuàng)建應(yīng)用程序后,返回 Google App Engine Launcher,選擇您的項(xiàng)目并點(diǎn)擊部署按鈕。你會(huì) 要求輸入登錄詳細(xì)信息。輸入您的電子郵件 ID,并使用密碼作為密碼 Google 應(yīng)用密碼生成器。
部署應(yīng)用程序后,現(xiàn)在您可以使用 http:// 訪問(wèn)您的應(yīng)用程序<project_id>.appspot.com/wp-admin/install.php</project_id>
。只需幾步,我們就完成了。登錄到 App Engine 并單擊您最近部署的 WordPress 項(xiàng)目。我們想要為我們的應(yīng)用程序激活云集成,以便我們可以從 WordPress 中上傳媒體。
點(diǎn)擊左側(cè)邊欄中的應(yīng)用程序設(shè)置,向下滾動(dòng)到底部,直到看到創(chuàng)建,然后點(diǎn)擊將其激活。您將看到一條新消息,表明云集成服務(wù)已啟動(dòng)。
步驟 5
最后一個(gè)
要做的就是安裝適用于 WordPress 的 Google App Engine 插件
本地。安裝插件后,激活它?,F(xiàn)在您將看到一個(gè)新鏈接
在 WordPress 的設(shè)置選項(xiàng)卡下。導(dǎo)航到 App Engine 并填寫(xiě)
必要的信息。確保您的默認(rèn)存儲(chǔ)桶名稱顯示
(envato-tutorial.appspot.com
)。之后,點(diǎn)擊保存按鈕,您就可以了
走吧。
結(jié)論
您可能想要保留 WordPress 的本地副本 安裝。由于安全原因,您的網(wǎng)站是靜態(tài)的 您無(wú)法在 Google App Engine 上更改主題或安裝插件 由 WordPress 提供支持的網(wǎng)站。所以你能做的就是安裝主題和插件 本地,然后使用 Google App Engine 再次部署 WordPress 啟動(dòng)器。
如果你 按照步驟操作,一切順利,給自己一個(gè)機(jī)會(huì) 在背面。不,說(shuō)真的,好好犒勞一下自己吧。我們現(xiàn)在做了什么 將幫助您的博客或網(wǎng)站快速加載并支持上傳 圖片和其他媒體到博客文章。事實(shí)上你已經(jīng)給你的博客 利用大 G 令人難以置信且強(qiáng)大的基礎(chǔ)設(shè)施的優(yōu)勢(shì)。現(xiàn)在起 打開(kāi),您的博客將優(yōu)雅地處理其傳入流量。
The above is the detailed content of Host WordPress website on Google App Engine. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

The main reasons why WordPress causes the surge in server CPU usage include plug-in problems, inefficient database query, poor quality of theme code, or surge in traffic. 1. First, confirm whether it is a high load caused by WordPress through top, htop or control panel tools; 2. Enter troubleshooting mode to gradually enable plug-ins to troubleshoot performance bottlenecks, use QueryMonitor to analyze the plug-in execution and delete or replace inefficient plug-ins; 3. Install cache plug-ins, clean up redundant data, analyze slow query logs to optimize the database; 4. Check whether the topic has problems such as overloading content, complex queries, or lack of caching mechanisms. It is recommended to use standard topic tests to compare and optimize the code logic. Follow the above steps to check and solve the location and solve the problem one by one.

Miniving JavaScript files can improve WordPress website loading speed by removing blanks, comments, and useless code. 1. Use cache plug-ins that support merge compression, such as W3TotalCache, enable and select compression mode in the "Minify" option; 2. Use a dedicated compression plug-in such as FastVelocityMinify to provide more granular control; 3. Manually compress JS files and upload them through FTP, suitable for users familiar with development tools. Note that some themes or plug-in scripts may conflict with the compression function, and you need to thoroughly test the website functions after activation.

Methods to optimize WordPress sites that do not rely on plug-ins include: 1. Use lightweight themes, such as Astra or GeneratePress, to avoid pile-up themes; 2. Manually compress and merge CSS and JS files to reduce HTTP requests; 3. Optimize images before uploading, use WebP format and control file size; 4. Configure.htaccess to enable browser cache, and connect to CDN to improve static resource loading speed; 5. Limit article revisions and regularly clean database redundant data.

The most effective way to prevent comment spam is to automatically identify and intercept it through programmatic means. 1. Use verification code mechanisms (such as Googler CAPTCHA or hCaptcha) to effectively distinguish between humans and robots, especially suitable for public websites; 2. Set hidden fields (Honeypot technology), and use robots to automatically fill in features to identify spam comments without affecting user experience; 3. Check the blacklist of comment content keywords, filter spam information through sensitive word matching, and pay attention to avoid misjudgment; 4. Judge the frequency and source IP of comments, limit the number of submissions per unit time and establish a blacklist; 5. Use third-party anti-spam services (such as Akismet, Cloudflare) to improve identification accuracy. Can be based on the website

TransientsAPI is a built-in tool in WordPress for temporarily storing automatic expiration data. Its core functions are set_transient, get_transient and delete_transient. Compared with OptionsAPI, transients supports setting time of survival (TTL), which is suitable for scenarios such as cache API request results and complex computing data. When using it, you need to pay attention to the uniqueness of key naming and namespace, cache "lazy deletion" mechanism, and the issue that may not last in the object cache environment. Typical application scenarios include reducing external request frequency, controlling code execution rhythm, and improving page loading performance.

When developing Gutenberg blocks, the correct method of enqueue assets includes: 1. Use register_block_type to specify the paths of editor_script, editor_style and style; 2. Register resources through wp_register_script and wp_register_style in functions.php or plug-in, and set the correct dependencies and versions; 3. Configure the build tool to output the appropriate module format and ensure that the path is consistent; 4. Control the loading logic of the front-end style through add_theme_support or enqueue_block_assets to ensure that the loading logic of the front-end style is ensured.

To add custom user fields, you need to select the extension method according to the platform and pay attention to data verification and permission control. Common practices include: 1. Use additional tables or key-value pairs of the database to store information; 2. Add input boxes to the front end and integrate with the back end; 3. Constrain format checks and access permissions for sensitive data; 4. Update interfaces and templates to support new field display and editing, while taking into account mobile adaptation and user experience.

The key to adding custom rewrite rules in WordPress is to use the add_rewrite_rule function and make sure the rules take effect correctly. 1. Use add_rewrite_rule to register the rule, the format is add_rewrite_rule($regex,$redirect,$after), where $regex is a regular expression matching URL, $redirect specifies the actual query, and $after controls the rule location; 2. Custom query variables need to be added through add_filter; 3. After modification, the fixed link settings must be refreshed; 4. It is recommended to place the rule in 'top' to avoid conflicts; 5. You can use the plug-in to view the current rule for convenience
