Setup a Dev Server for PHP, MySQL and Ruby on Rails: New Premium Tutorial
plusvideos

Setup a Dev Server for PHP, MySQL and Ruby on Rails: New Premium Tutorial

Tutorial Details
Download Source Files

In this Premium tutorial and screencast, you’ll learn how to turn that old computer you have lying around into a full-featured test bed for your websites. We’ll set up a typical LAMP server with Ubuntu Server 10.10, using Apache 2, PHP 5 and MySQL 5.5 and add in support for your Ruby on Rails 3 apps!

Become a Premium member to read this tutorial, as well as hundreds of other advanced tutorials and screencasts.


Join Net Premium

NETTUTS+ Screencasts and Bonus Tutorials

For those unfamiliar, the family of Tuts+ sites runs a premium membership service. For $19 per month, you gain access to exclusive premium tutorials, screencasts, and freebies from Nettuts+, Psdtuts+, Aetuts+, Phototuts+, Audiotuts+, Vectortuts+, and CgTuts+ For the price of a pizza, you’ll learn from some of the best minds in the business. Become a Premium member to read this tutorial, as well as hundreds of other advanced tutorials and screencasts.

Dan Harper is danharper on Themeforest
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • Jonas

    With the current price of small VPSes there’s rarely a point in using an old computer you have lying around. A VPS with 256 MB RAM is more than enough to power a PHP website with a relatively high number of hits.

    With a VPS it’s easy to start over with a fresh install, try out new Linux distributions, and so on.

    • http://www.cmnddsgn.com Luke

      Not necessarily, if you are just doing a intranet or local server then using an old computer is well worth it. You cut out the price of a VPS and don’t have to rely on an external network to connect.

    • http://www.danharper.me Dan Harper
      Author

      The idea isn’t really to replace a professionally-hosted production server with one in your own home. It’s more in the way of having a small server in your own home to mess around with.

      Maybe you’re a Windows user and really want to learn how to manage a UNIX environment so you can manage your production server through SSH, or you want to try out Ruby/Rails (which can be a royal pain in the ass to get working correctly under Windows). Or maybe you just want a small little project you can play around with.

      Also, most home internet connections don’t have anywhere near enough upstream bandwidth to handle anything more than a tiny website.

    • # Fez

      I agree with Jonas 100%.

  • http://www.diigital.com Mike

    A couple of questions:
    1) Is it PHP 5.3 that gets set up?
    2) Would it be easy to setup Ubuntu as a virtual machine on Windows 7 in either Virtual Box or MS Virtual PC, instead of on another physical machine?

    • Jonas

      If you’re okay with loading OSes one at a time (instead of first loading Windows, then loading Ubuntu Linux in a window), you can download Wubi (http://www.ubuntu.com/desktop/get-ubuntu/windows-installer), an Ubuntu installer for Windows that will install Ubuntu in such a way that you decide on bootup whether you want to start Windows or Linux.

      • http://www.diigital.com Mike

        Thanks, but I’d want to have the Windows environment there too (at the same time).

    • Brian McSweeney

      It isn’t difficult to run Ubuntu as a VM, but you really shouldn’t, especially for a server. If you want to run your homebox as a server, you might as well set up an apache server on Windows.

    • http://www.dafreelancejobs.com Yas

      Hi Mike,

      It is really easy to run Ubuntu as a VM in Windows.

      I’m using a VMWare virtual machine with Windows 7 as a host an Ubuntu 10.10 as a guest. In fact, I do all my PHP development in that VM. And also has another VM with Windows XP for all .Net development. This way, I keep my host OS clean and also can transfer my full development environment on a thumb drive, wherever I want.

      I’ve also tried VirtualBox and MS Virtual PC for creating virtual machines and used them for a while, but I like VMWare most as it is very vast (almost like you are working on the host, and not in a VM). Also you can copy/paste text/files from host to VM and backwards. You can make snapshots of the VM and restore it if something goes wrong. And more, as it is a commercial software and is the leader in that market.

      However VirtualBox and MS Virtual PC are also viable options and are free.

    • http://www.danharper.me Dan Harper
      Author

      The latest version of PHP 5 is installed, whichever one is in the Ubuntu repositories when you install PHP. I just checked, PHP 5.3.3

      In the screencast I’m installing Ubuntu in a Virtual Machine (via Parallels Desktop for Mac), so yeah, just as easy (in fact easier, as it’s quicker installing from your hard disk than a CD). It’s probably best to install on a physical machine if you’re doing anything more than just messing around.

  • http://www.cmnddsgn.com Luke

    Can we purchase this tutorial on the Tutorials Marketplace?

    • http://www.danharper.me Dan Harper
      Author

      I’m uploading it over there right now. I’ll put a link up once it’s been approved.

  • crk

    You could get smth from http://www.turnkeylinux.org/, You have a ready to go server in a matter of seconds!

  • http://krike.cmstutorials.org krike
    • http://www.danharper.me Dan Harper
      Author

      Screencast format, removed unnecessary steps, simplified some steps, bit more explanation of what each package achieves and added support for Git, Ruby (through RVM) and setting up Rails apps.

      If you don’t care for a screencast format or Rails support, that article will do just fine (I believe people were running into problems at the end of step 5 because of updates in Ubuntu & Apache, though.)

      • http://krike.cmstutorials.org krike

        Very nice, thank you for the info :)

  • Ingo Fahrentholz

    Nice Tutorial, but I’m not sure if there’s a firewall setup included ?
    May an explaination of CVS setup also would have been nice.

    But anyway :)

    • http://www.danharper.me Dan Harper
      Author

      Yeah sorry, I probably should have included a firewall section. Check out the Ubuntu Server documentation for a guide to setting one up: https://help.ubuntu.com/10.10/serverguide/C/firewall.html (“sudo ufw enable” to turn on ‘Uncomplicated Firewall’ then “sudo ufw allow 22″ to open port 22 (SSH)).

      We do install Git as a VCS, but if you want to use CVS, there’s a guide in the Ubuntu Documentation for that, too: https://help.ubuntu.com/10.10/serverguide/C/cvs-server.html

      • http://IngoFahrentholz Ingo Fahrentholz

        Hum, I should have seen that u have installed GIT :) But thanks for your efforts searching an guide for CVS and Firewall setup that’s nice.

        Regards Ingo

  • CharleyW

    Maybe this flew by and I missed it, but – which version of Ubuntu did you install – Server or Desktop? If Server, 32 or 64-bit?

    TIA.

    • http://danharper.me Dan Harper
      Author

      I mentioned right at the beginning when we go to Ubuntu.com – Ubuntu Server 10.10. I had the 32-bit as I also wanted to install it on an older system, but 64-bit should work too.

      • Chintan

        Eek, Ubuntu server D:
        I never liked it, much prefer CentOS or anything else RH based. Ubuntu’s great for a desktop though (:

  • Marcos Cerutti

    Hi Dan!
    Really nice tutorial, thank you very much indeed!

    I just would like to know, how to run php along rails without the need to point to the port used by mongrel or webrick.

    Cheers

  • http://www.exposecreative.net Mischa Colley

    Hey Dan,

    thoroughly enjoyed this tutorial. Very clearly explained and got me up and running very quickly. Loving being able to get some experience working over ssh etc . . . I noticed you worked on a Mac for this tutorial and was wondering if there are an plans or any chance you could do a similar tutorial re OS X? Or if you have a good tutorial to point to? I am very interested in getting a development environment set up on the Mac that has PHP and RoR working side-by-side. The idea of using the built in software packages in OS X is very appealing. I have been following along with this tutorial http://blog.danielsenhwong.com/2011/01/setting-up-ruby-on-rails-in-os-x/ but have become a little lost …

    • http://danharper.me Dan Harper
      Author

      Hey, glad to hear you enjoyed the tutorial.

      I actually am planning on doing a OS X version at some point soon, whenever I reinstall the OS so I can start from scratch and work out the most efficient way of setting everything up (I don’t want to use an AIO installer like XAMPP or MAMP).

      • http://www.exposecreative.net Mischa Colley

        Great to hear. I used to use MAMP but no longer wish to use it as it doesn’t give me enough control. I have now managed to get everything working ok but there are still a few kinks to smooth out. Would be great to see a write up of your experience / set up when you get the chance.

  • curt nakai

    First, thanks for such the informative screencast! I’ve got a question in regards to accessing the server in vm from other computers within (or outside) the local network. I am able to access the Unbuntu VM Guest from the host machine. But I can’t access this from any other machines on the LAN.

    For Example : My virtual machine Ip is 192.168.79.32(NAT)

    Which I’m able to access from my host machine : http://192.168.79.32:8005

    But if I try the same from another machine on the Lan I couldn’t. Even I couldn’t ping 192.168.79.32 from LAN.

    An ideas on where I can start?

    • http://www.danharper.me Dan Harper
      Author

      Try playing around with the network settings in your VM software, you want the VM to appear to be on the local network.

  • Allen

    Thanks for the tutorial, I never would have got any of this without it. How to view a webpage on my host machine was confusing for me. You didn’t really explain it; however, I was able to figure it out. Entering ifconfig, my ip address was 10.2.0.15 which wouldn’t bring up anything inside of a web browser. For anyone wondering who might also be using Oracle VirtualBox, I had to go to Settings, Network, and then select Host-Only from the dropdown list. Then after booting up the server again my ip changed to a 192.168… number and I was able to view the index.html file.

  • http://www.fuentedance.com σχολη χορου

    I use WAMP for my home trials but this is a really cool alternative, anyway i didn’t manage to follow the instructions. Anyway VERY NICE!!!