How To Install WordPress on Debian 10 Cloud Server

How to install WordPress on Debian 10 cloud server

There are many things you can do with your own private cloud server. At some point or another, you might want to install the WordPress content management system. WordPress is ideal for managing websites of all sizes, from a 3-page informational site to a blog with thousands of posts. WordPress can handle just about anything you throw at it. In this article, you will learn how to install WordPress on your private cloud server or VPS system.

If you don’t need cPanel, don't pay for it. Only pay for what you need with our scalable Cloud VPS Hosting.

check markCentOS, Debian, or Ubuntu check markNo Bloatware check markSSH and Root Access

Installing WordPress From Scratch

In order to install WordPress on your Debian cloud server you will follow along with the basic “5-minute install” that the WordPress organization recommends. However, since this WordPress is going to be installed on your own private cloud server, you will need to install a few additional server-side software applications. But, basically, the process works like this:

  • Install PHP as a server-side scripting language. This is the language that WordPress is written in, so it is a requirement. PHP will interpret the WordPress code and present complete pages in the browser, as well as facilitating the database connection.
  • Install MariaDB. The WordPress content management system uses a database to store your content. In this article, you will be installing MariaDB as the relational database software that will handle the storage and retrieval of your content.
  • WordPress core files. You will need to download the WordPress core files from WordPress.org. These are basically the plain text program files that run the WordPress application.
  • Database connection. You will lastly need to connect the core files to the database by editing one of the core files.

We will cover all of these steps in detail below, but this gives you the complete road map you will follow. If any of these procedures seem murky to you, you should contact support or managed hosting.

WordPress Installation Requirements

In order to have a working WordPress installation on your cloud server, you will need some additional software. For installing this software, you will be using the apt package manager. To run installation commands with apt you will need “root” or sudo access. By default, you have root access to your cloud server, so we will be using that for the WordPress installation process.

Logging Into Your Server As The Root User

You can log into your server from your terminal emulator once you have added a public key to the server. Follow along with our full guide to learn how to add your public key to a cloud server. Then you will be able to use a basic SSH login command on your terminal app:

ssh root@<server IP address or primary domain>

For example:

ssh [email protected]

Server Software

Apache comes pre-installed on your cloud server with Debian. So part of your work is already done. All that is left for you to do is install PHP and MariaDB as the necessary database software.

Install MariaDB

Follow along below to learn how to install MariaDB as the database storage software that will be used by WordPress.

Log into your server as the root user following the steps listed above.

apt install mariadb-server

For some background information on this command, note that the apt is the package manager, install is the primary instruction, and mariadb-server is the program we wish to install. We will be using this command more later, so now you know a little more about it.

At this point, it is recommended that you run the following command to secure your new MariaDB installation:

mysql_secure_installation

Follow the prompts to secure your installation. It is of major importance to secure your databases and disallow any external access.

To check and make sure that the MariaDB server is running, you can use this command:

systemctl status mariadb

Install PHP

Now it’s time to install the PHP scripting language. This is the language that WordPress uses to run properly on your system. While you are still on the command line in your server, go ahead and run this command to install PHP and the necessary modules:

apt install php libapache2-mod-php php-mysql

Now you should have PHP and the necessary modules for WordPress installed. To check your PHP installation version, you can optionally run this command:

php -v

Create A Database and Database User for WordPress

The next series of commands will create a database and database user for the WordPress installation. Log into your MariaDB command prompt:

mysql -u root -p

You will know you are logged in successfully when you see your default terminal prompt replaced by the MariaDB prompt:

MariaDB [(none)]> 

Create the database with the following command, of course replacing <database name> with the name of the database you want to create. For example, “wordpress_database,” “website,” or whatever name you prefer:

CREATE DATABASE <database_name>;

Now, create the database user. Every database requires a user with appropriate privilege to access the database. Be sure to replace the values “username” and “password” with your desired username and a very secure password. Also make note of these values somewhere, because we will need them again when we install and configure WordPress.

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

With the following command, you will grant all necessary privileges to the user created above. This gives the user the power to create records and tables and populate the database with content. (Note, this will add privileges to perform these operations on every database for the user listed. So you can also use this user to administer other databases, if that is something you might require.)

GRANT ALL PRIVILEGES ON * . * TO 'username'@'localhost';

Run the following command to apply your changes to MariaDB:

FLUSH PRIVILEGES;

Exit MariaDB by pressing Ctrld.

We now have a running PHP installation and MySQL server, with a database and database user. We are nearing completion of this process.

Restart Apache

At this point, it is recommended that you restart the Apache web server:

systemctl restart apache2

Completing The WordPress Installation

In this the final stage of the installation process, you are going to download a fresh copy of the WordPress source files, connect them to your database, and get started with a brand new WordPress site.

Remember that every website has a “document root,” basically a file path that indicates to the Apache web server where the public website files reside. For this tutorial, we are going to use the default directory that comes with our operating system: /var/www/html/.

Use the cd command to “change directory” to the default web root:

cd /var/www/html

You can download the latest WordPress source package with the following command:

wget http://wordpress.org/latest.tar.gz

You have just downloaded an “archive” file, which is very much like a zipped file, it’s one file that has compressed multiple files together. So you can “unarchive” it using the tar command as follows:

tar xfz latest.tar.gz 

This creates a “wordpress/” directory with all of the WordPress source files inside. But we want those files in the /var/www/html/ directory, so you can use the following command to move the WordPress files back one directory, effectively emptying the new “wordpress/” directory:

mv wordpress/* ./

You can use the rm command to remove the ‘latest’ archive file:

rm -f latest.tar.gz

You will also want to erase the default Debian Apache index file:

rm index.html

Now, you will just need to edit the wp-config.php core file, which contains the database connection information. WordPress needs the proper credentials in order to connect to the database and make changes. This means you must provide the name of the database, the database user, and password. I would recommend first that you make a copy of this file:

cp wp-config-sample.php wp-config.php

WordPress comes with a configuration sample file. That is what you copied above. And you will be editing the copy that you made, wp-config.php. It’s good to save the sample file in case you need a base file to copy from in the future.

You can use any text editor to edit this file, but for simplicity I will demonstrate with the nano text editor:

nano wp-config.php

Remember before when you noted the database name, user, and password information? It’s time to use that information again. You will be changing the following values highlighted in bold:

define( 'DB_NAME', 'database_name_here' );

/** MySQL database username */
define( 'DB_USER', 'username_here' );

/** MySQL database password */
define( 'DB_PASSWORD','password_here' );

For the nano text editor, once you have made your changes you will press Ctrlx to exit the editor, and answer yes to save your changes.

That’s it. Now for the fun part, go to your favorite web browser and type in your primary domain. You will be prompted to run the WordPress installation process. Here you will fill in a name for your site, and the primary admin user login information. Type in all of that information, and proceed.

Remember, the login information you put here is separate from your database username and password. You are creating a WordPress user account here that you will use only to log into your WordPress site for the purposes of administration, content creation, and other functions. You will be prompted to log into the WordPress dashboard when done.

Congratulations! You have just installed WordPress on your own cloud server running Debian 10. If you have any questions about this procedure be sure to drop them below.

CM
Christopher Maiorana Content Writer II

Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.

More Articles by Christopher

Was this article helpful? Join the conversation!