Lessons learned: Installing Wt on Squeeze LAMP
Added by Languid Octosquid over 11 years ago
Here is my experience with installing Wt on a Debian Squeeze LAMP machine. It was an involved process. I've worked on large, complex code bases before, so I knew about the question, "How does one eat an elephant?" The answer is "One bite at a time." Meaning, I had to decompose the issue down to manageable chunks and nibble away at the smaller problems.
1) I downloaded a LAMP appliance from TurnKey Linux. I ran it on the free VMware player. It's how I've developed PHP, MySQL and JavaScript projects.
2) I looked at what was required to install WT: http://www.webtoolkit.eu/wt/doc/reference/html/InstallationUnix.html
3) Okay - requirements. I had no idea about CGI, as I'd not used it before. I had to learn about CGI which I did, by going here: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html and here: http://httpd.apache.org/docs/2.2/howto/cgi.html . I realized I wanted to start with FCGI, because if I were ever going to deploy, that's what I was going to use. Why? Apache is a well-known and reliable web server. Also, there's a difference between FCGI and FastCGI which is quite significant. FastCGI is encumbered with licensing and/or patent issues while FCGI is not.
4) So I installed the libapache2-mod-fcgid for Debian Squeeze. I had to learn about dpkg, dpkg-query and apt-get. And the sources.list file. I'd used apt-get before but I just knew what it did and few other details.
5) I needed to test whether FCGI was working. The LAMP machine had a test.cgi file in its cgi-bin directory. That worked. I created a directory called fcgi-bin. I copied test.cgi into it. No joy. As it turned out, the cgi-bin directory was set up to allow .cgi file execution in the Apache configuration files via the ScriptAlias directive. I had to add a handler to handle cgi scripts outside of that directory with AddHandler cgi-script .cgi. The CGI scripts now worked in fcgi-bin. But that's just CGI. What about FCGI? I needed a simple test script.
6) So, I had installed the FCGI package (libapache2-mod-fcgid). It loaded a module in Apache called mod_fcgid.c. The handler for FCGI is called fcgid-script, which was set to handle file types of .fcgi. That was in the fcgid.conf file by default. I set the Options +ExecCGI for the fcgi-bin directory in Apache via a directive. And I added the file type .pl (for Perl) to the fcgid-script handler entry in the IfModule directive within the fcgid.conf file.
7) The perl file was still not working when I tried to run it via the browser. Finally, I discovered that in the perl script file, one need to use "Use FCGI" not "Use CGI::Fast". And I found a simple two line script that would work under FCGI. CGI and FCGI perl scripts are quite different. Then, from looking at the Apache error log, I determined I needed to install the perl FCGI package, libfcgi-perl. The perl script finally worked with FCGI. Finally I knew FCGI was working.
8) Next, I went to install Wt. But before that, I had to install package 'build-essential' for the c compilers and make. Then I had to install CMake.
9) Finally, I installed packages witty and witty-dev.
10) I compiled the hello.c example with g -o hello hello.c -lwtfcgi -lwt. Turns out the library libwtfcgi isn't on my machine. So, based on reading the forums, it seemed like the best way to get the most current installation of Wt with the required libraries, I should compile and install Wt myself. It wasn't installed as part of the witty packages I installed earlier.
11) So I had to read up on CMake, which is a utility which manages and generates makefiles. I went through the CMakeLists.txt files. I made a few minor changes. In the main CMakeLists.txt file, I set it to use the FCGI connector, not the built-in webserver one. I changed where the examples should go. The directions in the INSTALL.html file were spot on - perfect for building the project.
12) Recommendation: READ the main CMakeLists.txt file. It'll take 20 minutes, but it's 20 minutes well spent. Also, read up on CMake.
13) Warning: The CMake program wants to chown /var/run/wt directory to apache:apache. On my machine, it should be www-data:www-data. There's no user apache.
14) Read your wt_config.xml file. Might have to set num-threads to '2'. I did. It's working. Don't know if it's important.
15) Then, I had to make the examples. Per the instructions, I did a make -C examples from the build directory I created to compile the Wt project. That worked. I saw that I had a hello.wt file in the examples/hello directory. The directions said to run ./deploy.sh. But there was no suitable deploy.sh. I copied deploy.sh from the root directory of the Wt-3.1.2 directory to the hello directory. Ran it. It choked. I looked at the deploy.sh file and I could sort of follow along with what it was doing. Copying in a resources directory with images and such. I don't know from where the variables in deploy.sh were supposed to be set.
16) The /var/www/wt directory had to have Options +ExecCGI set. The fcgid-script handler was set to handle .wt files. Both of these items are set in the Apache config files.
17) Okay, next. I copied in hello.wt to my /var/www/wt directory. Tried to run it from a browser. No dice. Internal server error. In the Apache error log, I saw the same old error 104: mod_fcgid: error reading from fast cgi server, premature end of script headers. Sh-t. However, I recalled that someone on the forums said one could run the wt executable on the command line and it should run. I went to do that, ./hel- hit tab to autocomplete the name and nothing. A ha! It wasn't set to execute. So I chmod 755 hello.wt, ran it on the command line, then it worked! Then I ran it from the browser and it worked! HALLELUJAH!
18) I tried the treeview example, as I'm fond of treeviews. I ran it, and it ran, but it looked awfully sparse. Well, the deploy.sh talked about a resources directory. I noticed that FireBug, my web page inspector, was reporting several missing icons. So I created symbolic links to the resources directory on my server, in the same directory as the treeviewexample.wt (/var/www/wt), as well as to the icons directory. Everything then displayed correctly.
Next steps:
1) Install Eclipse on the VM I'm working on.
2) Set up x-forwarding so that the Eclipse display on the machine will display on my Windows machine.
3) Then, I can actually start learning how to develop with WT.
Recommendations to Wt developers:
It took me about a solid week to get from downloading the intro PDFs to the point where hello.wt was working on my server. It was quite a job, a lot of fiddling around. I had to learn about CGI, FCGI, CMake, dpkg, dpkg-query, apt-get, perl, Apache configuration, linking libraries. It was worthwhile. HOWEVER, when I started with PHP, I downloaded a fully functioning virtual machine with the foundations installed and configured, so I could immediately start working with LAMP development without having to deal with setup. So - I would strongly suggest that the Wt project also look into creating virtual machines with FCGI and Apache (as they are very common) that people can download and immediately start testing the examples and developing with Wt. Installing Wt really was eating the elephant. Again, I learned a lot but I'm not so sure most people will be so tenacious.
The process itself wasn't quite as clean as I've listed above. I actually installed build-essentials, then witty, and then started fighting with FCGI and perl.
Replies (6)
RE: Lessons learned: Installing Wt on Squeeze LAMP - Added by Plug Gulp over 11 years ago
Hi Languid,
Nice wite-up. Thanks! I agree that the steps required to setup Wt sometimes are bit involved at first and hence a VM with initial vanilla Witty setup is a good idea.
BTW, please could you add contents of your post to the Wiki here: http://redmine.webtoolkit.eu/projects/wt/wiki It will help others.
Thanks and regards,
~Plug
RE: Lessons learned: Installing Wt on Squeeze LAMP - Added by Languid Octosquid over 11 years ago
BTW, please could you add contents of your post to the Wiki here: http://redmine.webtoolkit.eu/projects/wt/wiki It will help others.
I'll do so. I'll put it under the "Getting Started" header with the same title. Please feel free to edit/move as people see fit.
Additionally, I did get Eclipse and X-forwarding working (which I'll add to the post). To those considering creating a VM with the vanilla Wt install, I simply installed the xbase-clients package, instead of the full xorg package, since I would never be putting displays on the VM. The VM is essentially used headless, only to be ssh'd into. I just use Xming on my Windows box as the X-server which receives the displays from the Eclipse client on the remote machine (VM).
IF you have a better IDE or other graphical development environment which could be x-forwarded to the Windows box, it might not be a bad idea to install it on the machine, and just let people know how to x-forward it to their graphical machine (ie, "1) allow xforwarding in sshd_config on the remote machine (like 1 or 2 minor changes), 2) ssh into the VM with x-11 forwarding enabled for the session, 3) start the executable with "./executable_name &\"
So totally a ready-to-go VM, including editor, so the user can immediately get started with Wt.
RE: Lessons learned: Installing Wt on Squeeze LAMP - Added by Languid Octosquid over 11 years ago
BTW, please could you add contents of your post to the Wiki here: http://redmine.webtoolkit.eu/projects/wt/wiki
Done.
RE: Lessons learned: Installing Wt on Squeeze LAMP - Added by Wim Dumon over 11 years ago
Hi Languid,
Thanks for updating the wiki. Pau does a great job packaging Wt for Ubuntu, and we mention those packages on our download page. I believe he also packages the fcgi connector so I'm not sure if you really have to compile it manually (though indeed you learn a lot from it and you can use the latest and greatest Wt releases).
I'm not a specialist in debian/ubuntu installs of Wt, but it seems to me that the packages have been renamed and you'll need libwt libwt-dev libwthttp-dev libwtfcgi-dev witty-examples, ... I got that list from here: http://packages.debian.org/source/sid/witty
Pau, any comments?
BR,
Wim.
RE: Lessons learned: Installing Wt on Squeeze LAMP - Added by Pau Garcia i Quiles over 11 years ago
Wim Dumon wrote:
Hi Languid,
Thanks for updating the wiki. Pau does a great job packaging Wt for Ubuntu, and we mention those packages on our download page. I believe he also packages the fcgi connector so I'm not sure if you really have to compile it manually (though indeed you learn a lot from it and you can use the latest and greatest Wt releases).
I'm not a specialist in debian/ubuntu installs of Wt, but it seems to me that the packages have been renamed and you'll need libwt libwt-dev libwthttp-dev libwtfcgi-dev witty-examples, ... I got that list from here: http://packages.debian.org/source/sid/witty
Pau, any comments?
It's explained in full detail here:
http://redmine.emweb.be/boards/1/topics/6067?r=6198#message-6198
The wtfcgi connector is packaged in the libwtfcgi* packages ('apt-cache search libwtfcgi' for the exact package name, as in Debian and Ubuntu you may have several runtime versions available at once), so no need to recompile it yourself.
If you want to perform a quick and easy installation, 'sudo apt-get install witty witty-dev witty-doc witty-dbg' is the preferred way.
If you only want to install either the wthttp OR (but not both) the wtfcgi connector, then you will have to install libwthttp* OR libwtfcgi* manually. You can of course install both of them (after all, that's exactly what the 'witty' package does: it pulls in all the libwt* packages for runtime).
So essentially:
- Any package named libwt* provides exactly ONE thing, and it will of course pull in any dependency it has. I. e. if you install the libwtdbopostgres package, it will install libwt-common (config files, resources), libwthttp, libwtdbo and libwtdbopostgres (in addition to postgresql, bzip, etc)
- Any package named witty* is a convenience package which will install all you need for runtime ('witty'), development ('witty-dev', it does pull 'witty' too), documentation ('witty-doc') or debug ('witty-dbg', it does pull in 'witty' too).
Hope that helps.
Do not hesitate to contact me directly by e-mail in case of trouble, I generally do not follow the forums (ah, that forums-email bridge I long for...)
RE: Lessons learned: Installing Wt on Squeeze LAMP - Added by Languid Octosquid over 11 years ago
Wim: Thanks for the information! I see one error I made - I didn't go to sid, I stuck with stable.
Pau: Thanks as well for the info!
I wrote up my experience in installing Wt. I might have made errors other might not have, and vice versa. If it doesn't belong on the wiki, and is best suited for the forum, please do remove it, or let me know it should be removed and I will. It's just a data point I thought might smooth the installation path for at least some users. Actually this thread will do that pretty effectively I think.