In this tutorial, I'll guide you through creating a preconfigured server instance running WordPress (or other LAMP-based application) that you can repeatedly clone and transfer to clients. I use Digital Ocean's image feature to sell my WordPress Quickstart and a few LAMP-based apps like Simplify Email and Simple Monitor. Partly because of this feature, Digital Ocean has become my web host of choice this year.
For Digital Ocean, a snapshot is a copy of a specific cloud-based server instance at a certain point in time. It allows you to copy instances and transfer them to customers via email. This makes it quick and easy to get started with preconfigured server images and application stacks.
For example, I offer a preconfigured, pre-optimized version of WordPress that I call a "Quick Start." It is a version of WordPress that comes pre-installed with a set of super useful plugins and is also pre-optimized with W3TC and Varnish caching, as described in my Tuts tutorial “Optimizing WordPress with Varnish and W3 Total Cache”. When I transfer a copy of this image to a client, it's the fastest, simplest, best-configured version of WordPress I can offer. This process makes launching a new WordPress website incredibly easy. In this tutorial, I'll show you how to build your own images in Digital Ocean to share with clients.
start using
If you want to try this using a LAMP application, you can find my guide to registering and setting up a universal instance on Digital Ocean here. If you want to use WordPress, you can follow the steps below. I'll walk you through creating a droplet, installing WordPress, adding themes and plugins, taking snapshots, cloning snapshots, and transferring them to clients. I have published a more detailed WordPress installation guide over at Digital Ocean.
Create your Droplet
First, let's create a water droplet. Click the Create button:
I named mine image.publishingwordpress.com
but you can name yours anything generic. I will use 512 MB image size:
Take note of the region you selected, as your client will only be able to instantiate your image in the same region - however, you can also transfer it before sending to the client if needed The area of ??the snapshot.
Click on the Applications tab and select LAMP on Ubuntu 14.xx:
Digital Ocean will start creating your Droplet:
When completed, you will see this page:
You will also receive an email as shown below:
Now you can visit your domain registrar and modify your DNS records to point your domain or subdomain to the new IP address. In my case, I pointed the A record for image.publishingwithwordpress.com
to 198.199.117.46
. Obviously, yours will be different.
You do not need to wait for DNS propagation before you can start configuring your instance. Log in via SSH using your IP address. You need to change the password you received in the email:
Let’s update the picture:
sudo apt-get update sudo apt-get dist-upgrade sudo reboot
I also recommend installing the following components, which we will utilize in WordPress and various plugins:
sudo apt-get install zip php5-curl sudo a2enmod rewrite
Opening Apache mod_rewrite
will allow the use of permalink addresses in WordPress, which is more user-friendly and enhances SEO.
I recommend also running mysql_secure_installation
:
mysql_secure_installation
To run this script, you need to write down your MySQL root password, which will be displayed when you log into the instance.
如果您使用每月 5 美元的 512MB RAM Droplet,您需要為 WordPress 創(chuàng)建一個交換文件正確操作,否則系統(tǒng)會耗盡內(nèi)存并反復(fù)崩潰:
dd if=/dev/zero of=/swapfile bs=1M count=1024 mkswap /swapfile swapon /swapfile
然后我們將添加到 fstab
文件以告知系統(tǒng)有關(guān)交換文件的信息:
sudo nano /etc/fstab
添加這一行:
/swapfile swap swap defaults 0 0
每月 10 美元的 1 GB 實例可以毫無問題地運行 WordPress。
現(xiàn)在,我們準備安裝 WordPress:
安裝 WordPress
創(chuàng)建一個具有 Apache Web 服務(wù)器權(quán)限的 www 目錄:
sudo mkdir /var/www sudo chown www-data:www-data /var/www cd /var/www
下載最新版本的 WordPress,展開存檔并設(shè)置權(quán)限:
cd /var/www sudo wget http://wordpress.org/latest.tar.gz sudo tar -xzvf latest.tar.gz sudo chown -R www-data:www-data wordpress
現(xiàn)在讓我們在 MySQL 中創(chuàng)建 WordPress 數(shù)據(jù)庫。記下您的用戶名和密碼:
mysql -u root -p create database wordpress; grant all privileges on wordpress.* TO "your-mysql-username"@"localhost" identified by "your-mysql-password"; flush privileges; exit;
讓我們?yōu)?WordPress 創(chuàng)建 Apache 配置文件:
cd /etc/apache2/sites-available sudo nano 000-wordpress.conf
粘貼并自定義以下虛擬主機配置:
<VirtualHost *:80> ServerName yourdomainname.com DocumentRoot /var/www/wordpress DirectoryIndex index.php <Directory /var/www/wordpress/> AllowOverride All Order Deny,Allow Allow from all </Directory> </VirtualHost>
為 WordPress 啟用 Apache 站點并禁用默認 Ubuntu 站點:
sudo a2dissite 000-default.conf sudo a2ensite 000-wordpress.conf sudo service apache2 reload
訪問您的網(wǎng)站,使用上面的數(shù)據(jù)庫設(shè)置通過網(wǎng)絡(luò)用戶界面配置 WordPress。選擇頭銜和登錄名時,請選擇通用的,并記下登錄名。
使用您的通用憑據(jù)登錄,您應(yīng)該會看到儀表板:
由于這是您將復(fù)制和傳輸?shù)耐ㄓ脠D像,因此用戶將需要 WordPress 來更新網(wǎng)站 URL為了他們自己。讓我們編輯 WordPress 配置文件以包含重定位標志。您會希望您的客戶在儀表板常規(guī)設(shè)置中編輯其網(wǎng)站 URL 后禁用此功能。
sudo nano /var/www/wordpress/wp-config.php
現(xiàn)在,添加以下行:
define(‘RELOCATE’,true);
當用戶在儀表板中更新其站點 URL 時,WordPress 將更新整個數(shù)據(jù)庫。完成一次后,客戶端可以注釋掉或刪除此行。
我還建議添加 FS_DIRECT
標志以簡化插件安裝:
define('FS_METHOD', 'direct'); // for automatic plugin installation
安裝主題
出于演示目的,我將安裝新的簡單 Minnow 主題。您可以通過搜索來安裝:
如下所示:
接下來,我們將安裝我們希望客戶擁有的任何插件。
安裝插件
您想安裝哪些插件取決于您。我在這里保留了推薦插件的列表。讓我們繼續(xù)安裝 Yoast SEO 插件,它對我來說是一個支柱。我使用它是因為它有助于搜索引擎優(yōu)化和生成站點地圖。
您可以訪問添加新插件頁面并搜索它來安裝并激活它:
此時,您可以進行任何您希望與下游所有客戶共享的常見 WordPress 配置。例如,您可能會安裝更多主題和插件。您可以打開永久鏈接。您可以配置一些基本的主題設(shè)置。這完全取決于你。
當您克隆即將發(fā)布的快照并將其傳輸?shù)侥目蛻舳藭r,您自定義的任何內(nèi)容都將被復(fù)制。您的客戶將需要自定義和配置您選擇不更新的任何內(nèi)容。
拍攝快照
當您完成所有常見的安裝和配置后,我們可以繼續(xù)為您的 Droplet 拍攝快照。 Digital Ocean 要求我們關(guān)閉實例電源。最好從命令行控制臺執(zhí)行此操作。
sudo poweroff
訪問 Digital Ocean 的 Droplet 頁面,然后單擊快照選項卡。我通常為快照選擇一個名稱,該名稱指示克隆的連續(xù)數(shù)量,例如wp-image-000
。然后,點擊拍攝快照。
Digital Ocean 可能需要幾分鐘時間來創(chuàng)建您的快照。
圖像完成后,Digital Ocean 將自動重啟您的 Droplet。
復(fù)制圖像
要創(chuàng)建更多圖像副本,您只需重復(fù)上述步驟即可。從命令行關(guān)閉 Droplet 電源。再拍一張快照。這有點耗時,但相當簡單。
在下一個教程中,我將向您展示如何使用 Digital Ocean API 來自動執(zhí)行此過程。
Digital Ocean does not charge for snapshot storage (except for small amounts). You can choose whether to destroy the original Droplet to avoid monthly fees. If you do this, you can always recreate it from the snapshot when you need it again.
Transfer to client
To transfer the snapshot to the client, visit the Image page:
Click on the leftmost profile icon to specify the email address of the Digital Ocean account holder you want to transfer to:
Within a few minutes, the snapshot will appear on the Pictures page of your client account. They need to approve the image before it can be accepted into their account.
It's important to remember that your customers can only accept snapshots from trusted users because it's easy for someone to install malware on the image before the snapshot is created and transferred. Digital Ocean may provide a trusted snapshot system in the future.
Create Droplet from Snapshot
Creating a Droplet from a snapshot is very simple. Simply visit the Create Droplet page, select the area where the image will be created, and click the My Snapshots tab. You can then select the image used to instantiate the droplet.
Clients can customize the hostname if desired, but all other settings will remain the same.
In other words, they will log into the instance using the same administrative username and password as the original snapshot, not the new snapshot Digital Ocean sends them. They will also initially use your client admin WordPress dashboard login and password. It would be better for them to change all server, MySQL and WP dashboard passwords after configuring the Droplet.
Once they create the droplet from the snapshot, they must configure their DNS to point their site URL of choice to their droplet's IP address. Also, they need to edit their domain’s WordPress Apache virtual host and restart Apache.
I find this WordPress quickstart to be the fastest way for me to help my clients get started with their new website. You can also use this method with any LAMP application, such as streamlined email.
What did you learn
Now that you know how to build a cloud-based application instance (such as WordPress), you can repeatedly clone the instance and transfer it to the client. In an upcoming tutorial, I'll show you how to use the Digital Ocean API to automate the process of cloning a snapshot.
I hope you found this article interesting and useful. Please feel free to post your questions and comments below. You can also contact me on Twitter @reifman or email me directly. Please follow my Tuts Instructor page for future articles in this series.
Related Links
-
Digital Ocean API
- WordPress Quick Start
- Recommended WordPress plugins
- WordPress Codex
The above is the detailed content of Create marketable application images for Digital Ocean resale. 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
