Adding a website to DreamCompute

Overview

There are several steps you must take to add your website to DreamCompute. Make sure you follow the steps below in order.

All steps assume you're running commands under the default user of your instance.

 

Step 1 — Create an instance

You must first launch a new instance. You can do this in the DreamCompute dashboard, or by using the OpenStack CLI. View the following articles for instructions:

Step 2 — Point your DNS to the new instance

You must now log into your DreamHost panel. There you can adjust the DNS on your domain to point to your DreamCompute instance.

Step 3 — Install Apache or LAMP on the instance

Log into your instance using the Key Pair and the default user assigned to it. Install Apache based on what image you choose to create the instance from. Below shows how to do this on Ubuntu.

Otherwise, if you know you'll need a database and PHP, it may be a better idea to install LAMP instead:

Step 4 — Create a new user

Create a new user for the website. Make sure to assign the user sudo privileges, then log in as the new user.

The remaining commands in this article assume you're logged in as the new user you just created.

 

Step 5 — Add SSH access

Depending on the permissions your user may need, you may want to enable SSH for the user. This allows the user to log into the instance via SSH, as opposed to security keys.

 

Step 6 — Add your domain

In the following examples, username would be your Shell user and example.com your website.

Make a folder for the website under your new username.

[user@instance]$ sudo mkdir /home/username/example.com

Configure VirtualHosts so your instance knows how to handle the domain. To do this, you need to make a .conf file.

[user@instance]$ sudo touch /etc/apache2/sites-available/example.com.conf

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

Edit that file:

[user@instance]$ sudo vim /etc/apache2/sites-available/example.com.conf

Then put the following inside it. Make sure to change any example.com URLs to your actual site and the DocumentRoot to the location of the website under your username.

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com
    ServerAdmin admin@example.com
    DocumentRoot /home/username/example.com
    <Directory /home/username/example.com>
            AllowOverride all
            Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined
</VirtualHost>

Once the VirtualHost is added, the site will need to be enabled with a command called a2ensite.

[user@instance]$ sudo a2ensite example.com
Enabling site example.com.
To activate the new configuration, you need to run:
  service apache2 reload

Finally reload your Apache service so it reads the changes.

[user@instance]$ sudo service apache2 reload

Step 7 — Enable userdir

Run the following under your default user:

[user@instance]$ sudo a2enmod userdir
[user@instance]$ sudo service apache2 restart

This enables the userdir module. You can now view it in the following directory:

[user@instance]$ ls -la /etc/apache2/mods-enabled

Edit the following file:

[user@instance]$ sudo vim /etc/apache2/mods-enabled/userdir.conf

In that file you'll see these lines:

UserDir public_html
<Directory /home/*/public_html>

Remove the public_html part so it just looks like this for each:

UserDir /home/*/
<Directory /home/*/>

Save the file and restart Apache.

[user@instance]$ sudo service apache2 reload

If you view your site now, you'll see it resolving on the DreamCompute instance.

Step 8 — Adding a Let's Encrypt certificate

View the following article for instructions on using Certbot to install a Let's Encrypt certificate:

Once installed, visit your site, and you should see it resolving from your user's /home directory. 

Editing site files with an FTP client

When site permissions are set to user:user, your FTP client can update files normally. However, depending on your website's functionality, it may need to communicate directly with Apache. For example, if you have a CMS site such as WordPress, you should keep file permissions set as user:www-data to allow WordPress to communicate with the instance.

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?