Adding a WordPress Blog to Your Rails App

If you’re running a rails application with a blog like I was, you we’re probably using something that utilized jekyl. There are some good blogging platforms out there and when I decided to add a blog to my site, I decided to use toto. At the time I thought adding all the html tags myself would be fun and pushing through github was cool but what really ended up happening was that I pushed off writing because it seemed like a chore. And the articles that I did publish were getting less than the expected coverage since publishing with SEO in mind is an extra added layer of work.

Since I’ve been working with WordPress for a decade now, I know it like the back of my hand. And although I have gripes with the platform, the “built for publishing” aspect of it makes it worth switching over. Plus you get tons of SEO juice with a few plugins and configurations. Hopefully, I’ll write a bit more now that I made the switch.

Here’s a quick guide to add WordPress to your rails app in the path /blog:

If you’ve read my post on adding ssl to your rails app and you have a similar nginx configuration, you’ll want to add some rules to use FastCGI to process incoming requests.

If you’ve downloaded php, mysql, and all the wordpress files and added it to a directory separate from your rails files like I did, add the following to your nginx.conf file:

Make sure you add this before your settings to have unicorn handle any of your requests or they will default to unicorn and redirect to your home page if you have a setting in your routes file to redirect since rails is taking over. Define the path of your wordpress files, make sure that index.php files are searched for, and make sure that you FastCGI can find the proper port to call php-fpm (in my case, I had to open /etc/php5/fpm/pool.d/www.conf and look for the listen= which was different from the typically recommended /var/run/php5-fpm.sock path)

Next, deploy your rails app and if you don’t have your cap file set to restart nginx, you’ll have to ssh into your server and run sudo service nginx restart. Then start your unicorn process again (in my case it is /etc/init.d/unicorn_boopis start).

Now you should have the wordpress installation appear in the path /blog on your domain!

Here’s a link to the conf file.

Related Posts

Deploy a Rails App with Heroku It's easy as pie to push a demo version of your rails app to heroku. Follow the simple steps below and you'll be on your way to testing in a subdomain...
Google Sheets Formulas Some google sheeets formulas to manipulate data in the cloud. Items will be added as I make use of new formulas. Index Split cell at a specif...
Data Manipulation Just a bin of macros and sql queries I use to manipulate data in excel or mysql Index Scan Top of Row Till End and return 3 columns Opposite of...
 

David Chun

I'm a full stack developer that builds tools for marketing and managing ecommerce shops. I occasionally consult for startups. If you've got an interesting project, reach out.

 

Leave a Reply

Your email address will not be published. Required fields are marked *