Setting up a Development Machine With PHP, Lighty, Ruby, and Python
After getting my new mac book pro I had an extra laptop sitting around… so why not turn it into a little low power development box My goal is to get LigHTTPD, Ruby on Rails, PHP, MySQL, and Python to work together with lighty.
Step 1: Install Lighty
tar -xvf lighttpd-1.4.20.tar
|configure: error: no acceptable C compiler found in $PATH||yum install gcc|
|configure: error: pcre-config not found, install the pcre-devel package or build with –without-pcre||yum install pcre|
|configure: error: zlib-headers and/or libs where not found, install them or build with –without-zlib||yum install zlib|
|configure: error: bzip2-headers and/or libs where not found, install them or build with –without-bzip2||yum install bzip*|
Everything went okay so now onto Ruby
First lets get PHP working with Lighty.
Lets change the document root to be /home/dev/
Lets also make sure we change the user of Lighty:
change uid to (default: don’t care)
server.groupname = “dev”
Lets try starting Lighty:
Now lets see if PHP worked…. browse to your dev server’s ip and you should see the php info page, and all is well.
Now lets get Ruby working Now lets get Ruby-FCGI
“gcc -E -I. -I/usr/lib/ruby/1.8/i386-linux -I/root/tmp/ruby-fcgi-0.8.6/ext/fcgi -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wall -fno-strict-aliasing -fPIC conftest.c -o conftest.i” conftest.c:1:21: error: fcgiapp.h: No such file or directory checked program was: /* begin / 1: #include / end */
have_header: checking for fastcgi/fcgiapp.h… ——————– no
“gcc -E -I. -I/usr/lib/ruby/1.8/i386-linux -I/root/tmp/ruby-fcgi-0.8.6/ext/fcgi -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector –param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wall -fno-strict-aliasing -fPIC conftest.c -o conftest.i” conftest.c:1:29: error: fastcgi/fcgiapp.h: No such file or directory checked program was: /* begin / 1: #include / end */
Now install gem: wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz
Gunzip, tar -xvf it and then compile it:
That should install Gem for you.
Next you need to install Rails, which can be done very easily now
When initially doing this I ran into an issue of Rails complaining (specifically when running the ruby script/server command) about not being able to find the specific database information.
First: start a project
That creates your first demo project.
Now lets make a controller:
Start the development server:
Browse to http://yourserverip:3000/hello Error: MissingSourceFile in HelloController#index
no such file to load – sqlite3
Hit Ctrl+C to stop the web daemon, then:
Change it to read something like:
Now to install Ruby MySQL:
Now try running the server again
and browse to http://yourserverip:3000/hello and you should get another error: Unknown action
No action responded to index. Actions:
To fix, first exit the web server (Ctrl+C), then:
Change file to look like this:
class HelloController < ApplicationController def index render :text => “Hello World” end end
Save and exit, and then:
Browse to http://yourserverip:3000/hello
And voila, Rails! You should see: “Hello World!”
I did however find a simpler way to run this using Mongrel:
Now to setup a Python (via Django)
cd /home/ mkdir python cd python django-admin.py startproject demo cd demo python manage.py runserver 0.0.0.0:8000
Browsing to http://yourserverip:8000/ you should see:
It worked! Congratulations on your first Django-powered page.
You’re now all set up with one server that can serve PHP, Python, and Ruby pages.
This is by no means a programming tutorial, I was simply showing how to get the basics set up for people to start quickly learning PHP, Python (web programming), and Ruby on Rails.
Please leave a comment if you spot a bug / error somewhere!