Step-by-step guide to deploy WordPress on DreamCompute


In this tutorial we are going to install WordPress on a DreamCompute instance, including both the application itself and the database it uses. We’ll install and configure all necessary components without making use of automatic configuration management systems.

This example will use an Ubuntu virtual machine, but you can use whichever flavor of linux you prefer. As long as you can install Apache, PHP, and database software, WordPress will be able to run.

Whichever machine type you pick, remember it’s better to boot volume backed instances as they are permanent as opposed to ephemeral disks.

Installing LAMP

While you certainly can install everything on it’s own, the LAMP stack for Ubuntu is perfect for WordPress. If necessary, you can follow the directions on how to configure LAMP but the overview is as follows:

[user@server]$ sudo apt-get install lamp-server^

This is interactive, so you’ll be asked ‘are you sure?’ in some places, and in others it will want a password for SQL. Make up a secure password for SQL and save it as you will need this later to set up SQL for WordPress.

After it runs, you’ll want to add mod_rewrite so WordPress can make pretty pages:

[user@server]$ sudo a2enmod rewrite

Finally restart apache:

[user@server]$ sudo service apache2 restart

At this point, your server will be accessible via its IP address.

Create a User

While it’s not required to make a separate user ID for WordPress, it’s strongly recommended for security. Having a user who only has access to the one website will limit the havoc caused should that account be hacked. This also limits the danger caused by rogue plugins or themes. The server itself will be safe, containing the damage just to that user account.

To do this, we make a folder for the website:

[user@server]$ sudo mkdir /var/www/

Then give your user access to that directory. This is so that you can install the WordPress site, later you will change ownership of that directory to www-data so Apache can access it.

[user@server]$ sudo chown -R $USER /var/www/

Add SSH Access

WordPress users often need SSH access in order to do extra configuration with WordPress. By default, this is disabled, so you will need to edit your config using a text editor, such as vi, emacs, or nano (this one is easiest for beginners).

[user@server]$ sudo vi /etc/ssh/sshd_config

Look for the setting of PasswordAuthentication, change it to “yes”, and save your file. Remember to restart SSHD once you’ve done this.

[user@server]$ sudo service sshd restart

Will this make your server less secure? Not significantly. As this new account only has access to itself, it can only hack itself.

Add Your Domain

There are a few steps to set up your domain. First you’ll need to Setup DNS for DreamCompute for all your domains.

Next you’ll want to configure VirtualHosts so your server knows how to handle the domain.

To do this, you need to make a .conf file:

[user@server]$ sudo touch /etc/apache2/sites-available/

It’s recommended you name the file after your domain, so you can always know what file is for what domain.

Edit that file and put this in:

<VirtualHost *:80>
    DocumentRoot /var/www/
    <Directory /var/www/>
            AllowOverride all

    ErrorLog ${APACHE_LOG_DIR}/
    CustomLog ${APACHE_LOG_DIR}/ combined

Once the site is added, we’ll need to enable it via a command called a2ensite (if you want to disable, it’s a2dissite):

[user@server]$ sudo a2ensite

This will prompt you to pick what site you want to enable. Type it in, hit enter, and you’ll be told what’s next.

Your choices are: 000-default default-ssl
Which site(s) do you want to enable (wildcards ok)?
Enabling site
To activate the new configuration, you need to run:
  service apache2 reload

Remember this command. It’s a fast way to enable sites without having to rename or mess with files. Finally bounce your apache service so it reads the changes:

[user@server]$ sudo service apache2 reload

Create the Database and Users

WordPress absolutely requires a database. You’ll want to create one

[user@server]$ mysql -u root -p

Remember the password we set earlier? That’s what it’s for.

Your command prompt will be mysql> so let’s make the database:

mysql> CREATE DATABASE examplecom_wordpress;
mysql> GRANT ALL ON examplecom_wordpress.* TO examplecom@localhost IDENTIFIED by 'PASSWORD';

Remember to change PASSWORD to an actually secure password.

You can check this by running the following command:

[user@server]$ mysql -u examplecom -p examplecom_wordpress

Install WP-CLI

While this is optional, we strongly recommend this. DreamHost includes WP-CLI on all servers due to its usefulness. To install, log in as your default user (not the web user we created earlier) and run the following:

[user@server]$ cd ~
[user@server]$ curl -O

Check that it works:

[user@server]$ php wp-cli.phar --info

And if it does move it so everyone can use it!

[user@server]$ chmod +x wp-cli.phar
[user@server]$ sudo mv wp-cli.phar /usr/local/bin/wp

That will make it accessible for all users.

Install WordPress

If you’ve installed WP-CLI, then all you have to do is this:

[user@server]$ wp core download

If you go to now you’ll get that 5 minute install page.

Of course since you have wp-cli you can also do this:

[user@server]$ wp core config --dbname=examplecom_wordpress --dbuser=examplecom --dbpass=PASSWORD
[user@server]$ wp core install --url= --title=DreamComputePress --admin_user=YOURUSERNAME --admin_password=PASSWORD --skip-email

If you use secure passwords like cWG8j8FPPj{T9UDL_PW8 then you MUST put quotes around the password.

I chose to skip-emails since I’m making it right there.

Finally you must change ownership of the WordPress site to www-data and the group to www-data as well so that the Apache webserver can access the files:

[user@server]$ chown -R www-data:www-data /var/www/

Miscellaneous Stuff

The following will make WordPress run even better, but aren’t required.

Make sure apt has the latest and greatest.

[user@server]$ sudo apt-get -y update

Make PHP Better

If you use a lot of media, install these to improve how PHP processes images.

[user@server]$ sudo apt install php-imagick php7.0-gd

Run a restart of apache when you’re done:


If WordPress can’t save files, you probably forgot to change ownership of the WordPress site to www-data.

[user@server]$ sudo chown -R www-data:www-data /var/www/

If that still doesn’t work, try this:

[user@server]$ sudo chgrp -R www-data /var/www/
[user@server]$ sudo chmod -R g+w /var/www/

If pretty permalinks don’t work, make sure you installed rewrite:

[user@server]$ sudo a2enmod rewrite && sudo service apache2 restart

And make absolutely sure you have AllowOverride set to All in your Virtual Host:

<Directory /var/www/>
    AllowOverride all

It won’t work without it.

Did this article answer your questions?

Article last updated .