My office (underneath the desks) is a mess of cables. I have a dual monitor setup for my mac pro, usually having documentation (or a video) on the second screen, and coding going on in my main 28" HANNS-G. I love developing rails applications on my mac because of the tools I have available to me and how easy it is to access them. However I wanted to keep running applications on linux (since thats where they end up going) and doing some other specific linux things.
I have all my programs / apps in a directory called /apps/ and I wanted to use Nginx and the passenger gem to handle everything.
I want to do all my development on my Mac and running the applications on linux. I have a spare Dell Vostro 200 that used to be my gaming desktop that now has CentOS installed on it.
Goals: Lets say I have an application called foobar . When (on my mac) I go to foobar.dev, it should go to my linux box and load the foobar app from nginx+passenger .
To keep everything in sync, I’m going to use NFS and export the directory from my mac to my linux box. Thankfully on mac it is ridiculously easy to setup NFS.
Replace things in caps like XXX and YOURUSERNAME with your information. Obviously if your network is different or mask, change it. I would not do this on a public server. I did this on my private, firewalled home network.
Just add this to /etc/exports:
You may need to restart NFSD on your mac:
Once your NFS is working you should be able to issue a command:
and you’ll see your export list.
You can then mount this on your linux box:
Next step you should install WEBMIN. You can this in a few different ways, but for CentOS:
Login at https://YOURLINUXIP:10000/. We’re going to setup BIND and the DNS server. You could do this without webmin, but webmin lets you do it in a few clicks, and setting up DNS isn’t one of my strong points.
Navigate to Servers -> Bind DNS Server.
Click on “Create master zone”. Enter “dev” into the domain, so it should look like this:
This will install Nginx for you and configure /opt/nginx/conf/nginx.conf for you as well.
I’ve shrunk my nginx.conf down to this, and modified it to load *.dev as server and host names.
The important line is server_name  ~^(www.)?([-\w.]+).\w+$; This allows you to catch those domains.
My Mac is my database server (it has an SSD and 8 gigs of memory and is backed up, so I keep everything on it). Now I need to let my linux box connect to my mac pro’s mysql instance.
I use SequelPro to do my database management, and you need to run the following queries:
Run the query and you should be all set. You can start Nginx and your applications should start running when you go to foobar.dev or yourappname.dev !
I found this took a bit of time to do (although this tutorial should let you do it in a few minutes) but it saves me from having to worry about start/shutting down thin/mongrel’s and other stuff on my mac.
Let me know if you have any comments or questions!