Add a wordpress installation to an existing droplet that is currently running a rails app,

Posted December 12, 2014 5.4k views
Ruby on RailsWordPress

So that the Wordpress site is on a subdomain?

I have seen ways to do this using Heroku but I’m specifically looking for a simple way to add a blog to my rails app hosted at digitalocean and I want to use Wordpress.


edited by AHA

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

There are a number of different ways this can be done. It partially depends on how you’ve set up your Rails app. If you aren’t already doing so, you’ll need to put Nginx or Apache in front of the app as a reverse proxy. This will then be used to direct requests to the correct domain.

Our Rails One-Click application uses Nginx. Using that as a base, you’re Nginx configuration would look something like:

server {
    listen   80;
    root /home/rails/public;
    index index.htm index.html;

    location / {
        try_files $uri/index.html $uri.html $uri @app;

    location ~* ^.+\.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|flv|mpeg|avi)$ {
        try_files $uri @app;

     location @app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://app_server;

server {
    listen 80;

    root /var/www/html;
    index index.php index.html index.htm;

    location / {
        # try_files $uri $uri/ =404;
        try_files $uri $uri/ /index.php?q=$uri&$args;

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;

The key thing to remember is that you must set the server_name correctly for both server blocks.

This tutorial will walk you through the WordPress specific bits like setting up the database:

by Justin Ellingwood
WordPress is the most popular CMS (content management system) in the world. It can be used to get your site or blog off the ground quickly and it provides a nice interface for adding content and modifying the site's design. In this guide, we'll walk through how to install WordPress on Ubuntu 14.04 with an Nginx web server.