Setting Up a Craft Site with Webfaction

May 14, 2015 5 min read

It’s no secret that I’m a fan of Webfaction. For me, the $9.50/month standard service has replaced crappy shared hosts and even some Media Temple DV servers. Webfaction combines the ease of a shared platform—think Media Temple (gs) or your typical $3/month host—with the speed and flexibility of a VPS. The handful of Craft sites I’ve set up on Webfaction fly, with great speed and solid uptime.

If you’re new to Webfaction, there’s a learning curve that can make your first site frustrating to set up. The control panel will undoubtedly be different from what you’re used to, even if it turns out to be really simple. (You may eventually like it, even!) I’ll attempt to help you make sense of things and get your first site up and running in short time.

The key thing to understand is what a Website is in Webfaction’s terms: an Application assigned to one or more Domain Names. This means that to create our Craft site, we’ll set up the pieces and link them together. You can read more about Webfaction’s unique, organized setup in their Applications and Websites guide.

Pros

Cons

What You’ll Need

Getting Down to Business

What we’re going to do is check out our project repository and point a symbolic link to it. The folder structure will end up like this…

~/craft-site
    /.git
    /craft
    /public
~/webapps/craft → ~/craft-site/public

1. Create your Webfaction account, using my referral link if you’re a kind soul, or not if you’re sick of those dirtbags that sprinkle referral links everywhere. Use PayPal or a credit card to plunk down $9.50 and get full access. Choose your username wisely, as it’ll be the basename of your account and used as your site preview URL (i.e. username.webfactional.com).

Screenshot of Webfaction's signup form

You can figure this out.

2. Clone a copy of your Craft site by SSHing into your account (ssh username@username.webfactional.com) and creating a project folder. You’ll start at /home/username, so mkdir craft-site to create /home/username/craft-site. Step into this folder with cd craft-site and then git clone your Craft project here. (Something like git clone git@bitbucket.org:acme/acme-craft.git ..)

Screenshot of cloning project repository from the command line

3. Create a new Application in the Webfaction control panel. You can do this by choosing Domains/WebsitesApplications → and Add new application. Pick a sensible name, choose Symbolic link for the App category, and choose the latest PHP option among the Symbolic link to static/cgi/php5x variants. For Extra info, specify the path of the public folder for your Craft project. In this case, it’d be /home/username/craft-site/public.1

Screenshot of application configuration in the Webfaction control panel

4. Create a new MySQL database under DatabasesDatabasesAdd new database. Pick a name, use MySQL, leave Encoding alone, and create a new user for the database and squirrel away the connection details.

Screenshot of adding a new MySQL database in the Webfaction control panel

5. Import your MySQL dump by using Webfaction’s phpMyAdmin or connecting a desktop client like Sequel Pro through an SSH tunnel.

Screenshot of SQL dump import in phpMyAdmin

6. Add your domains under Domains/WebsitesDomainsAdd new domain. These won’t do anything yet, we’re just telling Webfaction we’ll want to use them. If your website is acme.com, here you’ll want to add acme.com www.acme.com.

Screenshot of adding new domain names in the Webfaction control panel

7. Finally, add a Website from Domains/WebsitesWebsitesAdd new website. Pick another name and skip to domains, where you’ll use the type-ahead field to select the domains you just added in step 5. Choose Add an applicatonReuse an existing application, and pick the one you created in step 3. This is a good time to also assign your preview domain (username.webfactional.com), if you want to take a look at your site before pointing your domains to Webfaction. Save and you’re done!

Screenshot of creating a new Website in the Webfaction control panel

Now that the setup is finished, you’ll want to introduce Craft to your new environment details by editingdb.php and general.php in the craft/config/ directory. I’ll assume you’re already using multi-environment configs and you know how to do this.

Did I miss or fail to illuminate anything in this post? Let me know and I’ll get it updated!


  1. Rather than create a new Application that amounts to a docroot+subfolder, we’re telling Webfaction to point a symbolic link to Craft’s public folder and serve that. Like any CMS that keeps its business end out of the web root, Craft is happy this way and we also get to maintain clean Git pulls without restructuring anything in the hosting environment.

* * *

Updated 10/14/19 pm 6:54pm