tag:blogger.com,1999:blog-73083877210821867402024-02-07T02:07:48.969-08:00Back to the C Languageubuntu server fastcgi gcc lighttpd sqliteExplobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-7308387721082186740.post-89940835525202737052009-10-18T06:28:00.001-07:002009-10-21T02:28:54.576-07:00How to retrieve data passed inside the request header<p align="justify">Usually the browser provide a lot of information inside the header of a http request: not only the requested page, but also cookies, POST or GET variables, the user-agent etc.etc. All this data are stored in an array of strings and are accessible trough an external variable: <em>environ</em>.</p><p align="justify">Taking inspiration from the <em>echo.c</em> example of the <a href="http://www.fastcgi.com/drupal/node/5" target="_blank">development kit</a> I made a simple application that gives back all the information stored inside the header and the body of a request, similar to the <em><a href="http://php.net/manual/en/function.phpinfo.php" target="_blank">phpinfo() function</a></em> present in PHP.</p><p align="justify">If you want to test the program you can download a zip file <a href="http://www.vendercasa.it/download.php?file=info.zip" target="_blank">here</a>. With the C source there is also a HTML file useful to test different types of GET or POST requests, otherwise you can download the full FLUS environment <a href="http://back2c.blogspot.com/2009/10/download-of-flus.html">here</a> where you can test all the example of my blog connecting to the homepage of the server.</p><p align="justify"><strong>Note</strong>: under some conditions some data are passed also in the body section of the request.</p><p align="justify"><strong>References</strong>:<br /><a href="http://www.fastcgi.com/devkit/examples/echo.c" target="_blank">echo.c example of the Development Kit</a><br /><a href="http://www.w3.org/2001/tag/doc/whenToUseGet.html" target="_blank">URIs, Addressability, and the use of HTTP GET and POSTURIs, Addressability, and the use of HTTP GET and POST</a><br /><a href="http://www.w3.org/TR/html401/interact/forms.html" target="_blank">Forms (W3C Reccomendation page)</a></p>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com1tag:blogger.com,1999:blog-7308387721082186740.post-53773558550001565732009-10-09T11:55:00.000-07:002009-10-15T03:41:48.189-07:00How to share data between different HTTP requests<div align="justify">An easy way to share data between different HTTP requests of the same FastCGI is declaring variables outside the main loop of the FastCGI. The following FastCGI, a simple web counter, use this technique to maintain into an integer the count of accesses:<br /><br /></div><div style="PADDING-LEFT: 5pt; COLOR: rgb(0,0,153)">#include "fcgi_stdio.h"<br />int main( int argc, char *argv[] )<br />{ </div><div style="PADDING-LEFT: 50pt; COLOR: rgb(0,0,153)">int c = 1;<br />while( FCGI_Accept() >= 0 )<br />{ <div style="PADDING-LEFT: 50pt; COLOR: rgb(0,0,153)">printf( "Content-Type: text/plain\r\n\r\n" );<br />printf( "%d\n", c ); </div>}<br />return 0; </div><div style="PADDING-LEFT: 5pt; COLOR: rgb(0,0,153)">} </div><p align="justify">Assuming that the source has been named <em>webcounter.c</em> and application has been compiled (see <a href="http://back2c.blogspot.com/2009/05/hello-world-wide-web-part-1-editing-and.html">this post</a>) as <em>webcounter</em> into the <em>/var/fastcgi</em> directory, it’s necessary to add the following lines to the <span style="color:#000099;">/etc/lighttpd/conf-available/10-fastcgi.conf </span>file:</p><p><span style="color:#000099;">fastcgi.server += ( "/fastcgi/webcounter" =>;</span><br /><span style="color:#000099;">((</span><br /><span style="PADDING-LEFT: 50pt;color:#000099;" >"bin-path" => "/var/fastcgi/webcounter",</span><br /><span style="PADDING-LEFT: 50pt;color:#000099;" >"max-procs" => 1,</span><br /><span style="PADDING-LEFT: 50pt;color:#000099;" >"socket" => "/tmp/webcounter.socket",</span><br /><span style="PADDING-LEFT: 50pt;color:#000099;" >"check-local" => "disable"</span><br /><span style="color:#000099;">)))</span><br /></p><p align="justify">then, after restarting lighttpd, we can try the counter at the URL <a href="http://ip-of-your-server/fastcgi/webcounter">http://ip-of-your-server/fastcgi/webcounter</a>.</p><p align="justify"><strong>Only two notes about the configuration file</strong>: the “+” in the first added line before the “=” and the line <em>“max-procs” => “1”</em>, that force lighttpd to execute only one instance of the FastCGI to avoid malfunctions.</p><p><strong>References</strong>: <a href="http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModFastCGI" target="_blank">Structure and options of the FastCGIs’ configuration file</a></p>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-10689170465756145642009-07-23T23:47:00.001-07:002009-07-23T23:53:35.430-07:00Wow, Monkey Island is back!One of my favourite games of ever!<br /><script type="text/javascript" src="http://widgets.clearspring.com/o/4a1c128fff6697d7/4a6958fc9eece96b/4a1c128fff6697d7/2618032c/widget.js"></script>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-21699288175656545532009-06-16T02:49:00.001-07:002009-07-02T23:21:04.480-07:00What you need to develop FastCGIs: my favorite tools<p>Besides an environment for compiling and deploying applications (in my case an Ubuntu Server distribution) there are some other useful tools that can help the developer on writing code and debugging it.<br />Usually, I work on Windows (at the moment I'm trying Windows 7 RC) and I execute the server on a virtual machine in the same PC.<br />My favorite text editor is <a href="http://notepad-plus.sourceforge.net/" target="_blank">Notepad++</a>: free, open, fast and with a lot of useful functions for developers. When I write CSS, HTML, PHP, JS or C code I can't live without it.<br />To upload files to the server there are 2 great FTP/SFTP clients: <a href="http://winscp.net/" target="_blank">WinSCP</a> and <a href="http://filezilla-project.org/" target="_blank">Filezilla</a> and it's hard to decide which is the best.<br />The most difficult step on developing web applications is the debugging stage, in this case we could need <a href="http://www.rwtemple.com/software/HttpSpy" target="_blank">HttpSpy</a>, a simple application that can capture HTTP traffic (it works only with Internet Explorer, but not under Vista), if you prefer more sophisticated tools you can consider <a href="http://www.fiddler2.com/fiddler2/" target="_blank">Fiddler</a> (I prefer simplicity so I use HttpSpy, when possible). </p><p>Another must-have tool is the <a href="http://developer.yahoo.com/yui/compressor/" target="_blank">YUI Compressor</a> that can minimize JavaScript and CSS code.</p><p>There are also a lot of fantastic plug-ins for web developers that can be installed on Firefox:</p><p><a href="http://getfirebug.com/" target="_blank">Firebug</a>: it <em>“allows the debugging, editing, and monitoring of any website's CSS, HTML, DOM, and JavaScript, and provides other Web development tools.”</em> (<a href="http://en.wikipedia.org/wiki/Firebug_%28Firefox_extension%29" target="_blank">Wikipedia</a>) </p><p><a href="https://addons.mozilla.org/it/firefox/addon/2104" target="_blank">CSSViewer</a>: a simple CSS properties viewer</p><p><a href="http://www.sitepoint.com/dustmeselectors/" target="_blank">Dust-me Selectors</a>: useful to find unused CSS selectors</p><p><a href="http://www.mozilla.org/projects/venkman/" target="_blank">Venkman JavaScript Debugger</a>: nothing else …</p><p><a href="http://code.google.com/intl/it-IT/speed/page-speed/" target="_blank">Google Page Speed</a> and <a href="http://developer.yahoo.com/yslow/" target="_blank">Yahoo! YSlow</a>: two tools for speed-up tuning of the web site</p><p><a href="http://tools.seobook.com/firefox/seo-for-firefox.html" target="_blank">SEO for Firefox</a>: a good support for SEO analysis</p><p>If you know other useful tools for web developers let me know, please.</p>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-84270152410279906762009-06-02T01:25:00.000-07:002009-07-04T01:07:24.256-07:00Sorry, but what are FastCGIs?<p align="justify">A friend of mine asked me this question, an easy answer is that they are faster CGIs! Obviously now the question is “What are CGIs?”.</p> <p align="justify">When the web was emerging there was the need to serve not only static pages, but also pages created just in time. The first, primitive answer was the <a href="http://en.wikipedia.org/wiki/Server_Side_Includes" target="_blank">Server Side Include</a> (SSI) technology, useful to accomplish easy tasks, but inadequate to develop complex pages and sites. A better solution was the <a href="http://en.wikipedia.org/wiki/Common_Gateway_Interface" target="_blank">Common Gateway Interface</a> (CGI), a standard protocol for interfacing web servers with any stand-alone application able to write to the <a href="http://en.wikipedia.org/wiki/Standard_streams" target="_blank">standard output</a>. The web server acts as a gateway: it executes the application corresponding to the called URL and sends its standard output to requesting client (the browser) over the TCP/IP connection. So, thanks to CGI, every language capable of writing to the standard output, even bash scripts, could generate dynamic web pages (not only HTML pages, but also images, style files, etc.). As you can see, differently from current languages and environments for the web (PHP, ASP.NET, JSP, etc.), the programmer have to do a hard work: he has to generate the header of the HTTP answer and, in the case of a HTML page, to compile every tag.</p> <p align="justify">The CGI approach to dynamic web pages has other disadvantages: some performance problems, a difficult access to HTTP’s parameters (GET/POST parameters, cookies and other header’s parameters) and the lack of a communication mechanism between application instances. <a href="http://en.wikipedia.org/wiki/FastCGI" target="_blank">FastCGI</a> protocol try to overcome these limits.</p> Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-53019839279335940262009-05-31T11:36:00.000-07:002009-10-09T13:00:38.834-07:00Hello World Wide Web: Part 2, deploying and testing<div align="justify">The binary <em>helloweb</em> is ready, now it's time to deploy it on the lighttpd web server and test it.</div><p align="justify">First, for convenience, we could move it to a directory that we decided to reserve to fastCGIs, for example <em>/var/fastcgi</em>.</p><p align="justify">Second we must instruct lighttpd to recognize <em>helloweb</em> has a fastCGI, so vi must set it up correctly; have a look at the directory <em>/etc/lighttpd</em>, it contains two other directories: <em>conf-available</em> and <em>conf-enabled</em>, the first one contains a collection of possible configuration files for different modules of the web server, the second one those effectively used. All the information about fastCGIs are in the file <em>10-fastcgi.conf</em> and putting a symbolic link inside the <em>conf-enabled</em> directory makes this files actually used (after a web service restart).</p><p align="justify">A common <em>10-fastcgi.conf</em> file looks like this:<br /><br /><span style="color:#000099;">server.modules += ( "mod_fastcgi" )</span><br /><br /><span style="color:#000099;">fastcgi.server = ( "/fastcgi/helloweb" =>;</span><br /><span style="color:#000099;">((</span><br /><span style="PADDING-LEFT: 50pt;color:#000099;" >"bin-path" => "/var/fastcgi/helloweb",</span><br /><span style="PADDING-LEFT: 50pt;color:#000099;" >"socket" => "/tmp/helloweb.socket",</span><br /><span style="PADDING-LEFT: 50pt;color:#000099;" >"check-local" => "disable"</span><br /><span style="color:#000099;">)))</span><br /><br />The line <em><span style="color:#000099;">server.modules += ( "mod_fastcgi" )</span></em> loads the fastcgi module, the rest of the file instructs lighttpd about the usage of the fastcgi created in the <a href="http://back2c.blogspot.com/2009/05/hello-world-wide-web-part-1-editing-and.html">previous post</a>.<br />The instruction <span style="color:#000099;">"/fastcgi/helloweb"</span> informs the web server that an http request of URLs starting with <em>/fastcgi/helloweb</em> must be redirect to the fastcgi specified by the parameter <span style="color:#000099;">"bin-path"</span> (i.e. <em>/var/fastcgi/helloweb)</em>.<br /><br />Once modified the file, we must create a symbolic link to it in the directory conf-enabled:<br /><br /><span style="color:#000099;">ln -s /etc/lighttpd/conf-available/10-fastcgi.conf /etc/lighttpd/conf-enabled/10-fastcgi.conf</span><br /><br />then we must restart the web server:<br /><br /><span style="color:#000099;">/etc/init.d/lighttpd restart</span><br /><br />Now it's time to test the program: point your browser to the URL <a href="http://ip-of-your-server/fastcgi/helloweb">http://ip-of-your-server/fastcgi/helloweb</a> where <em>ip-of-your-server</em> is the ip of the server running lighttpd (if you don't know your ip, simply digit <span style="color:#000099;">ifconfig</span> at the prompt). If everything went well an exciting ""Hello World Wide Web" will appear.<br /><br /><strong>Note</strong>: I had some problem in deploying the fastcgi because initially I put <span style="color:#000099;">"fastcgi.server ="</span> and <span style="color:#000099;">"( "/fastcgi" =>"</span> in two different lines in the configuration file, joining them in a single line made everything working well.</p><p align="justify"><strong>References</strong>: <a href="http://redmine.lighttpd.net/wiki/lighttpd/Docs%3AModFastCGI" target="_blank">http://redmine.lighttpd.net/wiki/lighttpd/Docs%3AModFastCGI</a></p>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-63517697178177944792009-05-19T12:06:00.000-07:002009-10-15T02:03:37.433-07:00Hello World Wide Web: Part 1, editing and compiling<p align="justify">In the last posts we set up the programming environment, the web server is running and finally we are ready to start with the first FastCGI application: what better than a web version of the classic <em>Hello World</em>, for the occasion renamed<em> Hello World Wide Web</em>? Let’s go!<br /><br />First we must include the library fcgi_stdio needed by every FastCGI application:<br /><br /><span style="color:#000099;">#include “fcgi_stdio.h”</span><br /><br />This isn’t the only possibility, the library fcgiapp is an alternative. What are the differences between fcgi_stdio and fcgiapp? The fcgi_stdio library is a layer on top of the fcgiapp library that implement also CGI functionalities, so an application developed with fcgi_stdio can run indifferently in CGI or FastCGI environment without recompilation.<br /><br /><a href="http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/ch2c.htm">According to the official FastCGI site</a> using the library fcgi_stdio is preferable because <em>the fcgi_stdio library offers several advantages:<br /><br />Simplicity: there are only 3 new API calls to learn<br /><br />Familiarity: If you are converting a CGI application to FastCGI, you will find few changes between CGI and FastCGI. We designed our library to make the job of building a FastCGI application as similar as possible to that of building a CGI application: you use the same environment variables, same techniques for parsing query strings, the same I/O routines, and so on.<br /><br />Convenience: the library provides full binary compatibility between CGI and FastCGI. That is, you can run the same binary as either CGI or FastCGI.<br /><br />The fcgiapp library is more specific to FastCGI, without trying to provide the veneer of familiarity with CGI.<br /></em></p>After the #include, as usual for every C program, there is the main() function:<br /><br /><span style="color:#000099;">int main( int argc, char *argv[] ) { ... }</span><br /><p><span style="color:#000000;">that is composed by a while loop waiting for every HTTP requests:</span></p><span style="color:#000099;">while( FCGI_Accept() >= 0 ) { ... }</span><br /><p><a href="http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/apaman.htm">FCGI_Accept</a> <em>function accepts a new request from the HTTP server</em> (i.e. Lighttpd) <em>and creates a CGI-compatible execution environment for the request.</em> </p>Inside this while loop we must put the real program that generate the HTTP answer. An HTTP answer to a GET or a POST request must be composed of a header and the content (differently from other most popular languages for the web it's mandatory to write the header by-hand every time).<br /><br />We can easily send both, header and content, to client writing them to the standard output as any regular CGI application, so in our first example we need only two lines of code:<br /><p><span style="color:#000099;">printf( "Content-Type: text/plain\r\n\n\n" );</span><br /></p><p>for header of the HTTP answer (note that the two new-lines , "\n\n", at the end of the string conventionally mark the end of the header) and<br /></p><span style="color:#000099;">printf( "Hello World Wide Web\n" ); </span><br /><p>that represents what will appear on the browser.</p>That's all.<br /><p>The full code of the example is:</p><p style="COLOR: rgb(0,0,153)">#include "fcgi_stdio.h"<br />int main( int argc, char *argv[] )<br />{ </p><div style="PADDING-LEFT: 50pt; COLOR: rgb(0,0,153)">while( FCGI_Accept() >= 0 )<br />{ <div style="PADDING-LEFT: 50pt; COLOR: rgb(0,0,153)"><br />printf( "Content-Type: text/plain\n\n" );<br />printf( "Hello World Wide Web\n" );</div>}<br />return 0;</div>} <p><span style="color:#000000;">We can save this code with "helloweb.c" and compile it with this command:<br /></span></p><p><span style="color:#000000;"><span style="color:#000099;">gcc -o helloweb -lfcgi helloweb.c</span> </span></p><span style="color:#000000;">In the next post we will examine how to deploy helloweb on the web server.<br /></span><p><span style="color:#000000;">References:</span><br /><a href="http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/ch2c.htm">http://www.fastcgi.com/devkit/doc/fastcgi-prog-guide/ch2c.htm</a><br /><a href="http://support.zeus.com/zws/examples/2005/12/16/hello_world_in_perl_and_c">http://support.zeus.com/zws/examples/2005/12/16/hello_world_in_perl_and_c</a></p>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-71667685823283436642009-05-02T05:54:00.001-07:002009-07-10T00:49:37.228-07:00FastCGI on Ubuntu Server 9.04 and VirtualBox 2.2.0<p align="justify">In the previous posts we have set up a full environment for FastCGI testing based on Ubuntu Server 8.10 running on an old version of VirtualBox (sorry, I don’t remember which version).</p> <p align="justify">The following days the version 2.2.0 of VirtualBox and 9.04 of Ubuntu have been released, so, as soon as possible I retested everything with this new versions and, at the same time, I recorded the four steps of the preparation of the virtual environment and I published them on Youtube.</p> <p>1 - Sun VirtualBox 2.2.0 installation on Windows XP <br /><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/VpYww0MgsXc&hl=it&fs=1"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><embed src="http://www.youtube.com/v/VpYww0MgsXc&hl=it&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> <br /></p> <p align="justify">2 - <a href="http://back2c.blogspot.com/2009/04/preparing-virtual-machine.html">Configuring VirtualBox 2.2.0 for Ubuntu Server 9.04</a> <br /><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/qnrsFN3yRxE&hl=it&fs=1"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><embed src="http://www.youtube.com/v/qnrsFN3yRxE&hl=it&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> <br />Only 2 changes compared with <a href="http://back2c.blogspot.com/2009/04/preparing-virtual-machine.html">the previous installation</a>: <br />- I didn’t need yet to enable PAE/NX <br />- I set the “base memory size” to 128 MByte to avoid “host memory low” crashes during the installation of Ubuntu (I think this problem doesn’t exist yet with the new version 2.2.2 of VirtualBox just released, if you experimented it let me know). <br /> <br />3 - <a href="http://back2c.blogspot.com/2009/04/installing-ubuntu-server-810.html">Installing Ubuntu Server 9.04 on VirtualBox 2.2.0</a> <br /><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/6_Rt3Xsw8FY&hl=it&fs=1"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><embed src="http://www.youtube.com/v/6_Rt3Xsw8FY&hl=it&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object> <br /> <br />4 - <a href="http://back2c.blogspot.com/2009/04/upgrading-system-to-fascgi-needs.html">Updating Ubuntu Server 9.04</a> <br /><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/hFTpYfq_6L4&hl=it&fs=1"><param name="allowFullScreen" value="true"><param name="allowscriptaccess" value="always"><embed src="http://www.youtube.com/v/hFTpYfq_6L4&hl=it&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></p> <p>If you prefer you can download the VDI image of the installation <a href="http://www.vendercasa.it/download.php?file=FLUS.7z">here</a>! <br />(it’s a <a href="http://www.7-zip.org/" target="_blank">7-zip</a> file of about 200 megabytes)</p> Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-25455942745264472012009-04-28T04:45:00.000-07:002009-04-30T04:47:36.660-07:00VirtualBox 2.2.2 released<p><a href="http://www.virtualbox.org/wiki/News" target="_blank">SUN announces new version of VirtualBox</a>.</p><p><a href="http://www.virtualbox.org/wiki/Changelog" target="_blank">Here</a> the ChangeLog.</p>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-18571976514735442052009-04-25T02:40:00.001-07:002009-05-01T10:41:16.156-07:00Ubuntu Server 9.04 is out!<p><a href="http://www.ubuntu.com/news/ubuntu-9.04-server" target="_blank">Canonical announces availability of Ubuntu 9.04 Server Edition</a></p><p>In my opinion the best new thing is the support to cloud computing Amazon's EC2 standard tanks to <a href="http://eucalyptus.cs.ucsb.edu/" target="_blank">Eucalyptus</a>.</p><p>Soon I will update my previous posts with this new version.</p>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-66952403022152405442009-04-21T11:50:00.001-07:002009-10-07T12:35:11.238-07:00Upgrading the system to FasCGI needs<p align="justify">Now it’s time to update the system and to install all is needed by our experiments: Lighttpd, FastCGI and SQLite libraries and so on.</p><p align="justify">First of all we start the virtual system that <strong>must be connected to Internet</strong> (my host system is part of a local network connected to Internet thought a router with a DHCP service that assign the IP address also to the virtualized operating system) , then:</p><ul><li>login (back2c / back2c)<br /><br /></li><li>enter in root mode<br /><strong>sudo -i<br /></strong>(it's necessary to insert the password again)<br /><br /></li><li>update the system<br /><strong>apt-get update<br />apt-get upgrade<br /></strong><br /></li><li>install the GNU C/C++ compiler<br /><strong>apt-get install gcc build-essential<br /></strong><br /></li><li>install Lighttpd<br /><strong>apt-get install lighttpd<br /></strong><br /></li><li>install FastCGI<br /><strong>apt-get install libfcgi-dev </strong><br /><br /></li><li>install SQLite<br /><strong>apt-get install sqlite</strong><br /></li></ul><p align="justify">At this point the system is up-to-date and you can connect the browser of your host system to the Lighttpd server just created: simply insert the IP of the virtual machine as URL in your browser.</p><p align="justify">If you don't know the IP, simply digit <strong>ifconfig</strong> in the command line of your Ubuntu:<br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPQl9Aqjpd_qTqI92R-cwke4fTaUtbh9MQmMajSjtc2MPBAw6_tJU3nxdsOgFaMgXu5WOlWlRC-1f4lThP2UxfQuudbBTgWfJG7k2Azo6RZ1m7WNYARh4wyhif4EfSKxp66rCoiutq5VwL/s1600-h/ifconfig.png"><br /><img style="WIDTH: 200px; HEIGHT: 128px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5327417420946368258" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPQl9Aqjpd_qTqI92R-cwke4fTaUtbh9MQmMajSjtc2MPBAw6_tJU3nxdsOgFaMgXu5WOlWlRC-1f4lThP2UxfQuudbBTgWfJG7k2Azo6RZ1m7WNYARh4wyhif4EfSKxp66rCoiutq5VwL/s200/ifconfig.png" /></a><br />(IPs of the picture are invented)<br /><br />Now, if you can see the welcome page of Lighttpd, our system is ready for the first CGI: in the next post we will experiment a simple “Hello world”. </p>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-68464362853274357552009-04-18T06:39:00.001-07:002009-04-22T12:30:17.408-07:00Installing Ubuntu Server 8.10<p align="justify">In the previous post I prepared the virtual machine to start the ISO of Ubuntu Server 8.10, now it’s time to install the distribution on it!</p> <p align="justify">After starting FLUS (the name that I assigned to the virtual machine just configured) the installation process will start:</p> <p align="justify">- select the language (English) <br />- select "Install Ubuntu Server" <br />- select the language for the installation process (English) <br />- select a country (Italy in my case) <br />- select a keyboard (Italy/Italy in my case) <br />- assign a hostname (I chose "flus") <br />- partition disks ("Guided - use entire disk") <br />- choose the disk now created (SCSI1 / sda) <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkC7WZVaSn5qGvZlNew1rdt1pxn2wHzZFHvCcbGIpVrO2e4BDudkTG7Us5ebVbhLUQnIfMA4Oihd8M27rhrniLGpt4IcnsRBHqvSsDNvRJCInwv0dgolbdgCeTHsrDDP1XPb-gbVr966Sl/s1600-h/us1.png"><img style="width: 200px; height: 169px; cursor: hand" id="BLOGGER_PHOTO_ID_5326026476762322450" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkC7WZVaSn5qGvZlNew1rdt1pxn2wHzZFHvCcbGIpVrO2e4BDudkTG7Us5ebVbhLUQnIfMA4Oihd8M27rhrniLGpt4IcnsRBHqvSsDNvRJCInwv0dgolbdgCeTHsrDDP1XPb-gbVr966Sl/s200/us1.png" /></a> <br />- write changes to the disk <br />- set up user and password (I chose back2c / back2c) and no encrypted directory. <br />- choose no proxy <br />- choose no automatic updates <br />- activate OpenSSH server <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu3cykZNxfdudzU4jv5QuU-2hlb4DO8uNhz1U9KP7ZOkPHPUy9EgXxb_Sf95YMs-7dkR1HaZYs9i8QA2xBfPOP4VJiqbRne41RlB0QtBBfepgRUWJQHexjK52P_lIFrGNaCaArEJb0LSdI/s1600-h/us2.png"><img style="width: 200px; height: 169px; cursor: hand" id="BLOGGER_PHOTO_ID_5326026474486658962" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu3cykZNxfdudzU4jv5QuU-2hlb4DO8uNhz1U9KP7ZOkPHPUy9EgXxb_Sf95YMs-7dkR1HaZYs9i8QA2xBfPOP4VJiqbRne41RlB0QtBBfepgRUWJQHexjK52P_lIFrGNaCaArEJb0LSdI/s200/us2.png" /></a></p> <p align="justify">at this time the installation process will start, once finished we have to remove the cd and reboot (From the menu choice “Devices” then "unmount CD/DVD-ROM”).</p> <p align="justify">That’s all! In the next post we will install on the server all needed packages for our purposes.</p> Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-10949291364891373712009-04-11T06:10:00.000-07:002009-04-15T07:38:55.296-07:00Preparing the virtual machine<div align="justify">Lighttpd and FastCGI are technologies compatible with a wide range of operating systems; at the moment, for our experiments, in my opinion, a good choice is Ubuntu Server, a Linux distribution derived from Debian as the well known Ubuntu Desktop distribution.</div> <br /> <div align="justify">I chose Ubuntu because of some peculiarities:</div> <ul> <li>it's light and text-based <br /></li> <li>it's well supported and updated <br /></li> <li>with <a href="http://en.wikipedia.org/wiki/Advanced_Packaging_Tool">APT</a> you can easily install new software</li> </ul> <div align="justify">If you prefer to follow my blog testing FastCGIs in a different environment make sure that it supports Lighttpd and it has a C/C++ ANSI compiler. <br /> <br />After having downloaded the ISO image of Ubuntu Server 8.10 I preferred to keep Windows and to install Ubuntu in a virtual machine. <br /> <br />If you too prefer to keep your operating system and in the same time experiment Ubuntu Server in a virtual machine, you can download and install <a href="http://www.virtualbox.org/">VirtualBox</a>. <br />After the installation of the right version of VirtualBox for your host system (in Windows is an easy exercise for the “next” generation :-)), you must follow some easy steps to obtain a full working environment ready to experiment FastCGIs. <br /> <br />To set up a virtual machine ready to Ubuntu Server you must follow my instructions: </div> <ul> <li>Run VirtualBox <br /></li> <li>Start a New virtual machine <br /></li> <li>Chose a name for the virtual machine (for example FLUS = FastCGI, Lighttpd, Ubuntu, Sqlite) <br /></li> <li>Set OS Type and Version (Linux / Ubuntu) <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMVeIcvWtq4hswf-B1hCtlMHJ2snpeJDauZRdklVbGetrwNq2QzHHgWfBHipyJjZ0NNJqZFfJLMOyz3p5y-kZqk0jA0MJByxOGH-FE_vNBiuPnLRc4snYJu7zTtu05jWUZf4WHGgOdV9JJ/s1600-h/vm1.png"><img style="width: 200px; height: 178px; cursor: hand" id="BLOGGER_PHOTO_ID_5323430638804832098" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhMVeIcvWtq4hswf-B1hCtlMHJ2snpeJDauZRdklVbGetrwNq2QzHHgWfBHipyJjZ0NNJqZFfJLMOyz3p5y-kZqk0jA0MJByxOGH-FE_vNBiuPnLRc4snYJu7zTtu05jWUZf4WHGgOdV9JJ/s200/vm1.png" /></a> <br /> <br /></li> <li>Create a Virtual Hard Disk: <br />Pressing <em>New</em> a panel titled "Welcome to the Create New Virtual Disk Wizard" will be opened; set "Hard Disk Storage Type" selecting "Dynamically expanding storage" and, if necessary, set "Virtual Disk Location and Size"; press <em>Summary</em> and then <em>Finish</em>. </li> <li>Finish the Wizard</li> </ul> To start the installation of Ubuntu we have only to set up the virtual machine: <br /> <ul> <li>Select the virtual machine just created (FLUS), push “Settings” and adjust some options: <br /> <br />General => Advanced => Enable PAE/NX <br /> <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjpcV74E3CFQHr45aelv_jLs5bw0qFUT2r-VHQ_GG3kgfqA6LQFVWGVZbny0eTrUdrfXVNhajoWdTdBOQ9HIWVTtkRiQhBXBiSGyDSq20qI3nwNasi96GNnOozU-Yr18mmakMei-rg4pHC/s1600-h/vm2.png"><img style="width: 200px; height: 180px; cursor: hand" id="BLOGGER_PHOTO_ID_5323433903337113874" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjpcV74E3CFQHr45aelv_jLs5bw0qFUT2r-VHQ_GG3kgfqA6LQFVWGVZbny0eTrUdrfXVNhajoWdTdBOQ9HIWVTtkRiQhBXBiSGyDSq20qI3nwNasi96GNnOozU-Yr18mmakMei-rg4pHC/s200/vm2.png" /></a> <br /> <br />Network => Adapter 1 => In "Attached to:" select "Host Interface" <br /> <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6s5ZAR8TszcGZcpPyPDeiBMLJH08TLTwo-XGKI3SHhkrv7YMgaJNbKP84qEV9VW7azjynERzDSlC1Cesov6hLhVhvTJ_5ksmYekAKxpyl7SJsKXLeABY2nkAZCUw43gz5W3qPkZa-z728/s1600-h/vm3.png"><img style="width: 200px; height: 180px; cursor: hand" id="BLOGGER_PHOTO_ID_5323433910477830130" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6s5ZAR8TszcGZcpPyPDeiBMLJH08TLTwo-XGKI3SHhkrv7YMgaJNbKP84qEV9VW7azjynERzDSlC1Cesov6hLhVhvTJ_5ksmYekAKxpyl7SJsKXLeABY2nkAZCUw43gz5W3qPkZa-z728/s200/vm3.png" /></a> <br /> <br />CD/DVD-ROM => "Mount CD/DVD Drive" => "ISO Image File" and select the Ubuntu ISO image (ubuntu-8.10-server-i386.iso) <br /> <br /><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6Je8q68-9LNlpYgorlxPVpHD20ZYBKUpyp707wzLw9IdTJ1kxnStUoMrQV3ZEAVMyO7qD2uwyceE-cJo49R746-s2LEm0g6qBWYlL6cDUTQC_A_e3iIMNd2n_C2tgNAwuxogeHV69wfkq/s1600-h/vm4.png"><img style="width: 200px; height: 180px; cursor: hand" id="BLOGGER_PHOTO_ID_5323433911760995474" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh6Je8q68-9LNlpYgorlxPVpHD20ZYBKUpyp707wzLw9IdTJ1kxnStUoMrQV3ZEAVMyO7qD2uwyceE-cJo49R746-s2LEm0g6qBWYlL6cDUTQC_A_e3iIMNd2n_C2tgNAwuxogeHV69wfkq/s200/vm4.png" /></a></li> </ul> <div align="justify">Now the virtual machine is ready to start the installation of Ubuntu Server and of every needed package. We will see how in the next post.</div> Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-23573530954641460132009-03-24T04:03:00.000-07:002009-10-12T05:02:55.433-07:00Why FastCGIs?<div align="justify">I'm developing a site largely based on web services.<br />My first approach was using ASP.NET and C# as the <a href="http://www.vendercasa.it/" target="_blank">current version of the site</a>, but with a bit of json in addition.<br /><br />Using WCF is the better way to <a href="http://explonet.blogspot.com/2008/07/aspnet-web-services-and-json.html" target="_blank">implement a json web service in ASP.NET</a>.<br /><br />Developing a beta version of the site wasn't too hard because Visual Studio is a great IDE (the best IDE in the Universe IMHO) and C# is an amazing language for third millennium people, but at the end of this first easy stuff I encountered some problems: permission denies deploying the site on the server of my provider, unsatisfactory response time and some debugging difficulties.<br />At this point a technology change was mandatory.<br /><br />The priority for this new version of the site was the 'user experience' and 'user experience' without speed is nothing, so which is the fastest technology for dynamics web sites? Easy: FastCGIs written in C language (after assembly, of course, and when I was a teenager I spent a lot of days - and nights - at the keyboard of my ZX Spectrum experimenting the fascinating world of Z80 coding, but at the moment I want to conserve what remains of my brain for as many years as possible). And which is the fastest web server supporting FastCGI? Lighttpd, of course. And why not a bit of SQLite , all running on an Ubuntu server distribution, rigorously text-based?<br /><br />So the main ingredients of the "back2.c" recipe are:<br /><br /><a href="http://www.ubuntu.com/products/WhatIsUbuntu/serveredition">Ubuntu Server 8.10</a></div><div align="justify"><a href="http://www.lighttpd.net/">Lighttpd</a><br /><a href="http://www.fastcgi.com/drupal/">Gnu C Compiler<br />FastCGI libraries</a><br /><a href="http://www.sqlite.org/">SQLite library</a><br /><br />Follow me in my learning experiments, in the next post I will show you how easy it is to install an Ubuntu server: this is the first step to the "Hello world and over" experience.<br /><br />P.S.: Thanks to <a href="http://rdo.is-a-geek.net/" target="_blank">R.D.O.</a> for the joke of the logo :-)<br /><br /></div><div align="justify"></div><div align="justify"></div><div align="justify"><strong></strong></div><div align="justify"><strong>References</strong>:</div><div align="justify"><a href="http://www.fastcgi.com/drupal/node/6?q=node/15">A High-Performance Web Server Interface </a></div><div align="justify"><a href="http://www.fastcgi.com/drupal/node/6?q=node/16">Understanding FastCGI Application Performance </a></div>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0tag:blogger.com,1999:blog-7308387721082186740.post-50576615028278307292009-01-01T02:53:00.000-08:002009-10-13T11:32:40.549-07:00Download of FLUS<div align="justify">If you want to try FastCGIs there is an easy solution without changing your operating system, but only installing a virtual machine where you can run a guest environment provided with everything required for experiment FastCGIs. A good virtualization software is <a href="http://en.wikipedia.org/wiki/VirtualBox" target="_blank">Sun VirtualBox</a> that you can freely download <a href="http://www.virtualbox.org/wiki/Downloads" target="_blank">here</a>. As operating system I chosen <a href="http://www.ubuntu.com/products/WhatIsUbuntu/serveredition" target="_blank">Ubuntu Server</a>. To make it easier to install I prepared FLUS, an OVF image ready to use with Sun VirtualBox (at the moment ver. 3.08) that you can download <a href="http://www.vendercasa.it/download.php?file=FLUS_1_0.zip" target="_blank">here</a> (295 M).</div><p align="center"><a href="http://www.vendercasa.it/download.php?file=FLUS_1_0.zip"><span style="font-size:180%;">Download FLUS</span></a></p><p align="justify">FLUS 1.0 contains:</p><p align="justify">Ubuntu Server 8.04.3 TSL i386 (32 bit)<br />OpenSSH<br />Lighttpd 1.4.19<br />GCC 4.2.4<br />SQLite 2.8.17<br />FastCGI 2.4.0<br />All the samples of the blog (into /home/back2c directory)</p><p align="justify">To login use the user back2c (password back2c), then to enter in the root mode use <em>sudo –i</em> and enter the same password again.</p><div align="justify">Only one note: after importing of the image and before starting it remember to enable PAE/NX option in Settings/System/Processor panel of VirtualBox:</div><p align="justify"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0oUecHHkAOGC_bE3IoF3oeNnBMm180_2tIVC3TB7FTDmMhshWuVZ7tynznnth-1EI3aRw2KOzhyPkkvl4ON96IUyWBPRJgHyAPqLBqhre87UUu93dEjZ97m60lG-uWaVOe-G0q7jKxLhC/s1600-h/conf.png"><img style="MARGIN: 0px 10px 10px 0px; WIDTH: 400px; FLOAT: left; HEIGHT: 349px; CURSOR: hand" id="BLOGGER_PHOTO_ID_5390907532000370962" border="0" alt="" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0oUecHHkAOGC_bE3IoF3oeNnBMm180_2tIVC3TB7FTDmMhshWuVZ7tynznnth-1EI3aRw2KOzhyPkkvl4ON96IUyWBPRJgHyAPqLBqhre87UUu93dEjZ97m60lG-uWaVOe-G0q7jKxLhC/s400/conf.png" /></a></p>Explobothttp://www.blogger.com/profile/14357524085622946370noreply@blogger.com0