<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BlueScripts &#187; tutorials</title>
	<atom:link href="http://bluescripts.net/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://bluescripts.net</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 07 Jul 2010 16:42:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Setting up a Development Machine With PHP, Lighty, Ruby, and Python</title>
		<link>http://bluescripts.net/2009/02/setting-up-a-development-machine-with-php-lighty-ruby-and-python/</link>
		<comments>http://bluescripts.net/2009/02/setting-up-a-development-machine-with-php-lighty-ruby-and-python/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 16:13:42 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[tutorials]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[lighttpd]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://bluescripts.net/?p=144</guid>
		<description><![CDATA[After getting my new mac book pro I had an extra laptop sitting around&#8230; 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 wget http://www.lighttpd.net/download/lighttpd-1.4.20.tar.gz gunzip lighttpd-1.4.20.tar.gz tar -xvf lighttpd-1.4.20.tar [...]]]></description>
			<content:encoded><![CDATA[<p>After getting my new mac book pro I had an extra laptop sitting around&#8230; 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.</p>
<p>Step 1: Install Lighty</p>
<div class="console">wget http://www.lighttpd.net/download/lighttpd-1.4.20.tar.gz</p>
<p>gunzip lighttpd-1.4.20.tar.gz</p>
<p>tar -xvf lighttpd-1.4.20.tar</p>
<p>cd lighttpd-1.4.20</p>
<p>./configure</p></div>
<p>Here is a list of errors / fixes encountered while doing this from a bare-bones net install. Run ./configure after each one to see what else is broken / needs to be installed.</p>
<table class="errors" border="0" cellspacing="3" cellpadding="2" width="100%">
<tbody>
<tr>
<td width="50%"><strong>Error</strong></td>
<td width="50%"><strong>Fix</strong></td>
</tr>
<tr>
<td valign="top">configure: error: no acceptable C compiler found in $PATH</td>
<td valign="top">yum install gcc</td>
</tr>
<tr>
<td valign="top">configure: error: pcre-config not found, install the pcre-devel package or build with &#8211;without-pcre</td>
<td valign="top">yum install pcre*</td>
</tr>
<tr>
<td valign="top">configure: error: zlib-headers and/or libs where not found, install them or build with &#8211;without-zlib</td>
<td valign="top">yum install zlib*</td>
</tr>
<tr>
<td valign="top">configure: error: bzip2-headers and/or libs where not found, install them or build with &#8211;without-bzip2</td>
<td valign="top">yum install bzip*</td>
</tr>
</tbody>
</table>
<p>Copy the lighttpd conf to somewhere easy to find:</p>
<div class="console">cp doc/lighttpd.conf /home/lighttpd.conf</div>
<div class="console">make<br />
make install</div>
<p>Now onto PHP:</p>
<div class="console">yum install php</div>
<p>That&#8217;s done easily enough. Verify it&#8217;s installed:</p>
<div class="console">root@localhost lighttpd-1.4.20]# php -v<br />
PHP 5.1.6 (cli) (built: Jul 16 2008 19:53:00)<br />
Copyright (c) 1997-2006 The PHP Group<br />
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies</div>
<p>Verify python&#8217;s installed:</p>
<div class="console">[root@localhost lighttpd-1.4.20]# python<br />
Python 2.4.3 (#1, May 24 2008, 13:47:28)<br />
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2<br />
Type &#8220;help&#8221;, &#8220;copyright&#8221;, &#8220;credits&#8221; or &#8220;license&#8221; for more information.<br />
&gt;&gt;&gt;</div>
<p>(hit ctrl+d to exit the python interpreter)</p>
<p>Install MySQL:</p>
<div class="console">yum install mysql*</div>
<p>( I just install them all as this is a dev server anyways )</p>
<p>Everything went okay so now onto Ruby</p>
<div class="console">yum install ruby*</div>
<p>Everything went okay, and all the software is installed. Now it&#8217;s time to configure them.</p>
<p><strong>First lets get PHP working with Lighty.</strong></p>
<div class="console">nano /etc/php.ini</div>
<p>hit CTRL+V to page down real quick&#8230;. at the bottom of the file add:</p>
<div class="console">cgi.fix_pathinfo = 1</div>
<p>Save the file and exit.</p>
<p>First:</p>
<div class="console">whereis php-cgi</div>
<p>It should be in /usr/bin/php-cgi</p>
<p>Second:</p>
<div class="console">adduser dev</div>
<div class="console">echo &#8221; &gt;&gt; /home/dev/index.php</div>
<p>Now lets open lighttpd.conf</p>
<div class="console">nano /home/lighttpd.conf</div>
<p>Un-comment the fastcgi, rewrite, and redirect lines.</p>
<p>Lets change the document root to be /home/dev/</p>
<p>Lets also make sure we change the user of Lighty:</p>
<div class="console">## change uid to  (default: don&#8217;t care)<br />
server.username            = &#8220;dev&#8221;</p>
<p>## change uid to  (default: don&#8217;t care)<br />
server.groupname           = &#8220;dev&#8221;</p></div>
<p>Now scroll down and add this to the bottom:</p>
<div class="console">fastcgi.server = ( &#8220;.php&#8221; =&gt; ((<br />
&#8220;bin-path&#8221; =&gt; &#8220;/usr/bin/php-cgi&#8221;,<br />
&#8220;socket&#8221; =&gt; &#8220;/tmp/php.socket&#8221;<br />
)))</div>
<p>Exit and save the file.</p>
<p>Lets try starting Lighty:</p>
<div class="console">lighttpd -f /home/lighttpd.conf<br />
2009-01-27 15:02:20: (log.c.84) opening errorlog &#8216;/var/log/lighttpd/error.log&#8217; failed: No such file or directory<br />
2009-01-27 15:02:20: (server.c.888) Opening errorlog failed. Going down.</div>
<div class="console">mkdir /var/log/lighttpd<br />
touch /var/log/lighttpd/error.log; touch /var/log/lighttpd/access.log; chown -R dev:dev /var/log/lighttpd;</div>
<p>Start lighty again and you&#8217;re all set!</p>
<p>Now lets see if PHP worked&#8230;. browse to your dev server&#8217;s ip and you should see the php info page, and all is well.</p>
<p><strong>Now lets get Ruby working</strong><br />
Now lets get Ruby-FCGI</p>
<div class="console">wget http://sugi.nemui.org/pub/ruby/fcgi/ruby-fcgi-0.8.6.tar.gz; gunzip ruby-fcgi-0.8.6.tar.gz ; tar -xvf ruby-fcgi-0.8.6.tar;<br />
cd ruby-fcgi-0.8.6<br />
ruby install.rb config</div>
<p>This fails so lets check for errors:</p>
<div class="console">[root@localhost ruby-fcgi-0.8.6]# cat ext/fcgi/mkmf.log<br />
have_header: checking for fcgiapp.h&#8230; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; no</p>
<p>&#8220;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 &#8211;param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wall -fno-strict-aliasing  -fPIC  conftest.c -o conftest.i&#8221;<br />
conftest.c:1:21: error: fcgiapp.h: No such file or directory<br />
checked program was:<br />
/* begin */<br />
1: #include<br />
/* end */</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>have_header: checking for fastcgi/fcgiapp.h&#8230; &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; no</p>
<p>&#8220;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 &#8211;param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables -Wall -fno-strict-aliasing  -fPIC  conftest.c -o conftest.i&#8221;<br />
conftest.c:1:29: error: fastcgi/fcgiapp.h: No such file or directory<br />
checked program was:<br />
/* begin */<br />
1: #include<br />
/* end */</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p></div>
<p>Fix:</p>
<div class="console">wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz; gunzip fcgi-2.4.0.tar.gz; tar -xvf fcgi-2.4.0.tar; cd fcgi-2.4.0<br />
./configure<br />
make<br />
make install</div>
<p>Now lets try ruby again!</p>
<div class="console">ruby install.rb config<br />
ruby install.rb setup<br />
ruby install.rb install</div>
<p>Done <img src='http://bluescripts.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Now install gem: wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz</p>
<p>Gunzip, tar -xvf it and then compile it:</p>
<p>run
<div class="console">ruby setup.rb</div>
<p>That should install Gem for you.</p>
<p>Next you need to install Rails, which can be done very easily now</p>
<div class="console">gem install rails</div>
<p>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. </p>
<p>First: start a project</p>
<div class="console">cd /home/<br />
mkdir ruby<br />
cd ruby<br />
rails demo
</div>
<p>That creates your first demo project.</p>
<p>Now lets make a controller:</p>
<div class="console">ruby script/generate controller hello<br />
      exists  app/controllers/<br />
      exists  app/helpers/<br />
      create  app/views/hello<br />
      exists  test/functional/<br />
      create  app/controllers/hello_controller.rb<br />
      create  test/functional/hello_controller_test.rb<br />
      create  app/helpers/hello_helper.rb
</div>
<p>Start the development server:</p>
<div class="console">ruby script/server<br />
=> Booting Mongrel (use &#8216;script/server webrick&#8217; to force WEBrick)<br />
=> Rails 2.2.2 application starting on http://0.0.0.0:3000<br />
=> Call with -d to detach<br />
=> Ctrl-C to shutdown server<br />
** Starting Mongrel listening at 0.0.0.0:3000<br />
** Starting Rails with development environment&#8230;<br />
** Rails loaded.<br />
** Loading any Rails specific GemPlugins<br />
** Signals ready.  TERM => stop.  USR2 => restart.  INT => stop (no restart).<br />
** Rails signals registered.  HUP => reload (without restart).  It might not work well.<br />
** Mongrel 1.1.5 available at 0.0.0.0:3000<br />
** Use CTRL-C to stop.
</div>
<p>Browse to http://yourserverip:3000/hello<br />
Error:<br />
 MissingSourceFile in HelloController#index</p>
<p>no such file to load &#8212; sqlite3</p>
<p>RAILS_ROOT: /home/ruby/demo</p>
<p>To fix:</p>
<p>Hit Ctrl+C to stop the web daemon, then:</p>
<div class="console">cd config<br />
nano database.yml
</div>
<p>Change it to read something like: </p>
<div class="console">development:<br />
  adapter: mysql<br />
  encoding: utf8<br />
  database: ruby<br />
  username: root<br />
  password: PASSWORD
</div>
<p>Now to install Ruby MySQL:</p>
<div class="console">
gem install mysql &#8212; \<br />
&#8211;with-mysql-include=/usr/include/mysql \<br />
&#8211;with-mysql-lib=/usr/lib64/mysql
</div>
<p>Now try running the server again</p>
<div class="console">ruby script/server</div>
<p>and browse to http://yourserverip:3000/hello and you should get another error:<br />
Unknown action</p>
<p>No action responded to index. Actions:</p>
<p>To fix, first exit the web server (Ctrl+C), then:</p>
<div class="console">cd app<br />
cd controllers<br />
nano hello_controller.rb<br />
# Change file to look like this:<br />
class HelloController < ApplicationController<br />
   def index<br />
      render :text => &#8220;Hello World&#8221;<br />
   end<br />
end
</div>
<p>Save and exit, and then:</p>
<div class="console">cd ../../;<br />
ruby script/server</div>
<p>Browse to http://yourserverip:3000/hello</p>
<p>And voila, Rails! You should see: &#8220;Hello World!&#8221;</p>
<p>I did however find a simpler way to run this using Mongrel:</p>
<div class="code">gem install mongrel</div>
<p>Wait a few for it to install and then just change to your demo directory:</p>
<div class="console">mongrel_rails start -d</div>
<p><strong>Now to setup a Python (via Django)</strong></p>
<div class="console">wget http://www.djangoproject.com/download/1.0.2/tarball/<br />
tar -xzvf Django-1.0.2-final.tar.gz<br />
cd Django-1.0.2-final<br />
python setup.py install</p>
<p>cd /home/<br />
mkdir python<br />
cd python<br />
django-admin.py startproject demo<br />
cd demo<br />
python manage.py runserver 0.0.0.0:8000
</p></div>
<p>Browsing to http://yourserverip:8000/ you should see:</p>
<p>It worked!<br />
Congratulations on your first Django-powered page.</p>
<p>You&#8217;re now all set up with one server that can serve PHP, Python, and Ruby pages.</p>
<p>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.</p>
<p>Please leave a comment if you spot a bug / error somewhere!</p>
]]></content:encoded>
			<wfw:commentRss>http://bluescripts.net/2009/02/setting-up-a-development-machine-with-php-lighty-ruby-and-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
