Adding a website to DreamCompute

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 Debian, Ubuntu, Fedora, and CentOS.

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 server via SSH, as opposed to security keys.

Step #6 — Add your domain

Make a folder for the website under your new username.

[user@server]$ 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@server]$ 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@server]$ 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@server]$ 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@server]$ sudo service apache2 reload

Step #7 — Enable userdir

Run the following under your default user:

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

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

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

Edit the following file:

[user@server]$ 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@server]$ 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

If you now add a 'Let Encrypt' certificate it will be installed on your domain without further configuration. The configuration file will also show under:

/etc/apache2/sites-available/

If you visit your site now, 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 the Apache server.

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 server. View the following article for further details on how to configure a WordPress website:

Did this article answer your questions?

Article last updated PST.