One-Click WordPress on Digital Ocean

Install WordPress site on digital ocean droplet with one click

Digital Ocean is a well-known name in the field of cloud hosting and offers a nice range of cost effective solutions for quickly deploying your website/app to the clouds. You also have a vast number of customized options in the Digital Ocean marketplace, which will deploy the required package without having to run codes manually. If you want to run wordpress, you can select to create a wordpress droplet from the Digital Ocean marketplace and then within minutes, you will have a wordpress installation running on APACHE webserver with mysql database. Most of the heavy work related to installing the webserver and then downloading and installing wordpress is done automatically to help you avoid the manual work, which can otherwise take you around an hour at least or more. The wordpress package also includes certbot which means you can just add your domain and ssl and get the website running.

Digital Ocean One click WordPress Droplet Setup

Once you have created the droplet, you will only need to set up the DNS and the domain configuration for your wordpress installation, where you set your custom domain and add an admin user and password.

First, go to the Digital Ocean Marketplace and select wordpress for your package. or just follow the following link: https://marketplace.digitalocean.com/apps/wordpress

Now, click on create wordpress droplet. You will be redirected back to your account dashboard, where you can select the droplet size and region. Once you have selected these, you need to choose the authentication method, which can be SSH keys or password. If you select password, create a strong one to SSH to your droplet and then click on create droplet. Within a few minutes, the droplet will be created and ready.

Once, the droplet is ready, you can connect to it via ssh.

When you SSH to your wordpress droplet for the first time, you are directed to the wordpress setup. Here, you will need to add your wordpress domain or subdomain in the first step. Since, we are directly in the final stage of wordpress installation, you will need to create the necessary DNS records (A records) for your blog before moving on.

Enter your domain/subdomain when prompted to and then hit enter. You will receive the following message:

“Enabling conf block-xmlrpc.

To activate the new configuration, you need to run:

  systemctl reload apache2

Now we will create your new admin user account for WordPress.”

When you have submitted your domain/subdomain name, the next step is to create the wordpress admin and password.

When prompted, enter the admin email you will use with wordpress.

The system will prompt you to enter a username for your wordpress admin. You can create a new admin here like mywp_admin or something more unique like atx_wpzl.

Now, create and enter a strong password for wordpress login.

The password is not visible. So, after adding the password, hit enter.

Now, enter your blog name. The system will ask you if the information you have just entered is correct. Reply with Y. Your wordpress setup is complete here and the system will prompt you to configure the ssl. You need to make sure that you have already added the DNS records for your domain since the domain needs to be accessible before you can add ssl certificate. You can install ssl now or later using the command certbot –apache.

The system will ask you the following when you are installing ssl certificate:

“Would you like to use LetsEncrypt (certbot) to configure SSL(https) for your new site? (y/n): “

Answer y. Next, the system will ask your for the email for ssl setup. Enter the email and reply yes for the next questions which include the terms of agreement. The system will next ask you to select the domains and subdomains for which you want ssl active. You can select both the www and non www versions from the list offered. It will include both the root domain name that you entered in the first step and its www version. To select both, input nothing and just hit enter.

The certificate installation takes no more than a minute after which you can access your wordpress blog using https.  You do not need to worry about setting the Virtual host file either since it is included in the package and when you provide the domain name, the system automatically creates the vhost file. The default wordpress package by Digital Ocean also includes the fail2ban wordpress security plugin. You can check out and change plugins and themes later when you are logged in.

Overall, the wordpress installation process using one click Digital Ocean wordpress deployment did not take more than 10 to 15 minutes. This is how, you can easily deploy a wordpress website on Digital Ocean.

Here are a few commands you may find useful.

– Check the status of Apache webserver:

$ sudo systemctl status apache2

– To restart Apache server:

$ sudo systemctl restart apache2

– To check out the vhost file for your wordpress site:

$ sudo nano /etc/apache2/sites-enabled/000-default.conf

The virtual host file on your server can be used to host multiple sites on the same server where each one has its own vhost file. It includes the configurations like server name and the document root or the root folder for the particular site. If you check out the vhost file for your default website using:

$ sudo nano /etc/apache2/sites-enabled/000-default.conf

You will see a virtual host file looking like this:

<VirtualHost *:80>

        ServerAdmin webmaster@localhost

        ServerName example.com

        ServerAlias www.example.com

DocumentRoot /var/www/html

        <Directory /var/www/html/wordpress/>

            Options FollowSymLinks

            AllowOverride All

            Require all granted

        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        CustomLog ${APACHE_LOG_DIR}/access.log combined

RewriteEngine on

RewriteCond %{SERVER_NAME} =example.com [OR]

RewriteCond %{SERVER_NAME} =www.example.com

RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

The last four lines in the virtual host file have been added by the certbot to redirect http traffic to https.

The AllowOverride All in <Directory var/www/html> (root directory), allows you to use the .htaccess file, which you can create and access using:

$ sudo nano /var/www/html/wordpress/.htaccess

You can enable gzip on your website and set browser caching using the .htaccess file as well as use it to set redirects like non www to www or vice versa.

Optional : Install phpMyAdmin


In case, you would like to login to your wordpress mysql database, you can do so using the phpMyAdmin. To do that, you will first need to install the phpMyAdmin.

Download phpMyAdmin 5.2.1 (latest version) with the following command:

$ wget https://files.phpmyadmin.net/phpMyAdmin/5.2.1/phpMyAdmin-5.2.1-english.zip

Now, unzip the file:

$ unzip phpMyAdmin-5.2.1-english.zip

Wait for the command to process and extract the files. Once finished, you can remove the zip file you downloaded with the following command:

$ rm phpMyAdmin-5.2.1-english.zip

Now, so that you can access it using siteurl/phpMyAdmin, move it to phpMyAdmin folder.

$ mv phpMyAdmin-5.2.1-english phpMyAdmin

If you go to your website url and add /phpMyAdmin to the end, you will find yourself on the phpMyAdmin login page.

You can login to the database using the credentials provided in wp-config.php file. To open the file:

$ sudo nano /var/www/html/wordpress/wp-config.php

You can copy the database password from this file. Look for the following line:

$ define (‘DB_Password’,  ‘your_database_password);

Now, you can use the DB_user defined in the wp-config.php file and the password to login to your database via phpMyAdmin. Generally, the name of the database and database user is ‘wordpress’ if you have used the oneclick deployment.

Once inside the database, you will see the database for your wordpress installation listed in the left sidebar. Click on it to expand it and check out the tables in your database.

Optional: Install WP-CLI

The WP-CLI or the wordpress command line interface is a great tool for managing your wordpress installation. You can do several things with the help of the cli and without the need to login to the wordpress dashboard each time. From managing themes to plugins and the wordpress database, you can do it all with the help of the cli.

Installing WP-CLI is very easy and can be done with just a few lines of code. First, you need to download the wp-cli.phar file.

$ wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Now, check if it works using:

$ php wp-cli.phar –info

Its output will look like the following:-

root@my-wordpress:~# wp –info

OS:     Linux 5.15.0-67-generic #74-Ubuntu SMP Wed Feb 22 14:14:39 UTC 2023 x86_64

Shell:  /bin/bash

PHP binary:     /usr/bin/php8.2

PHP version:    8.2.4

php.ini used:   /etc/php/8.2/cli/php.ini

MySQL binary:   /usr/bin/mysql

MySQL version:  mysql  Ver 8.0.32 for Linux on x86_64 (MySQL Community Server – GPL)

SQL modes:      ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION

WP-CLI root dir:        phar://wp-cli.phar/vendor/wp-cli/wp-cli

WP-CLI vendor dir:      phar://wp-cli.phar/vendor

WP_CLI phar path:       /root

WP-CLI packages dir:

WP-CLI cache dir:       /root/.wp-cli/cache

WP-CLI global config:

WP-CLI project config:

WP-CLI version: 2.7.1

However, you cannot type wp-cli.phar each time to execute a command. So, make the file executable and move it somewhere in your PATH.

$ chmod +x wp-cli.phar

$ sudo mv wp-cli.phar /usr/local/bin/wp  

Now, type wp –info and you will again see the same output as in the previous step. You have installed WP-CLI and can use it now to run wordpress commands.

Note: Instead of running wp-cli commands as the root user, you should create a new user.

To add a new user, run the following command:

$ sudo adduser <username>

Enter a strong password. Now, run the following command:

$ sudo nano /etc/ssh/sshd_config

Inside the sshd_config file, scroll down to find the following line and comment it out:

# PasswordAuthentication no

Add below it or uncomment if it is already there:

PasswordAuthentication yes

Now, poweroff and then power on your droplet. Type poweroff to shutdown the droplet. Now, go back to the dashboard and turn it on back.

SSH again to the droplet as the root user and add the new user you just created to sudo group.

$ sudo usermod -aG sudo <username>

Change ownership to the new user:

$ sudo chown -R <newuser> /var/www/html

This will allow the new user to create directory and install wordpress themes and plugins. Now, switch to the new user:

$ su <newuser>

Change directory to the root directory.

$ cd /var/www/html

For example, I will install the yoast plugin using the wp-cli. Run the following command to install yoast:

$ wp plugin install wordpress-seo –activate

(Note if you are not inside the root folder, the command will not work. You will need to provide the path to wordpress at the end of the command in that case like –path=/var/www/html)

The output of the above command will look like the following:

newuser@my-wordpress:/var/www/html $ wp plugin install wordpress-seo –activate

Installing Yoast SEO (20.4)

Downloading installation package from .

Using cached file ‘/home/newuser/.wp-cli/cache/plugin/wordpress-seo-20.4.zip’…

Unpacking the package…Installing the plugin…Plugin installed successfully.

Activating ‘wordpress-seo’…Plugin ‘wordpress-seo’ activated.

Success: Installed 1 of 1 plugins.

I will install the generatepress theme also using the wp-cli:

$ wp theme install generatepress –activate

newuser @my-wordpress:/var/www/html$ wp theme install generatepress –activate

Installing GeneratePress (3.3.0)

Downloading installation package from .

Unpacking the package…Installing the theme…Theme installed successfully.

Activating ‘generatepress’…Success: Switched to ‘GeneratePress’ theme.Success: Installed 1 of 1 themes.

In this wazy, you can use the wp-cli to install, activate, update and delete themes and plugins and for many more similar tasks even creating and updating new users, categories, tags etc.