Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Monday, February 15, 2010

Is language really important

I have tried my hands on most of the languages to check if one is better than the other. I rather found all of them to be useful in their own way. Its important for the developer to choose the right language/tools to make the application or program better.

For example one could/should use c/c++ for system level stuff, writing device drivers etc . But if a developer wants to write a web application with C/C++ then that is going to be a nightmare.

Languages like PERL/ruby/python have uses mostly in the *NIX (Linux/Unix) world where the developer or the system admin uses them to do stuff that could save a lot of human labor.

PHP has been in news for a while now.. and it seems to be a nice language  for which it was initially developed .. Its a good language for small/medium size web apps .. but the number of extensions and modules are lesser as compared to cpan for PERL

My all time favorite has been PERL . which has the ability to do both system  and web programming. and its highly customizable to make it efficient and fast. 

LAMP - Linux apache Mysql and Perl/PHP has been the best combination on the internet and a lot of successful website still serve thousands of pages using them.

so the point is unless you are really writing something that is going to change the world don't really bother too much on things like ruby (vs) perl (vs) php (vs) python.. each can solve you problem in the way you want it to.


http://news.cnet.com/8301-13505_3-10453213-16.html




Friday, October 19, 2007

configuring and installing Mod_perl with apache

Requirement

  1. mod_perl-2.0.3.tar.gz
  2. Assuming apache2 is installed

Operating system
  1. Linux
  2. I am using Fedora core 5 but these steps should work fine for most of the linux systems

Installing mod_perl

tar -xvzf mod_perl-2.0.3.tar.gz
cd mod_perl-2.0.3

run
# which apxs

if its not found then do a

#yum nstall httpd-devel ;# works on FC

for others get a compatible version of your httpd-devel and install it
as apxs gives the information required to build the mod_perl.so module.

do a
#which apxs
again to check where its installed

Assuming that its installed in /usr/bin/apxs

Run

#perl MakeFile.PL MP_APXS=/usr/bin/apxs
#make
#make test
#make install

this would install all the modules required to run mod_perl in the PERL5LIB path


Copy the mod_perl.so to your <>/modules /etc/httpd/modules/

Edit your httpd.conf and add


LoadModule perl_module modules/mod_perl.so


And now restart your server.

Testing the mod_perl module.

create a /var/www/html/perl/rock.pl

print "Content-type: text/html\n\n";
print "mod perl rocks";
print "

test

";




Edit your httpd.conf and add the following

Alias /perl/
/var/www/html/perl/
<Location /perl/>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
Order allow,deny
Allow from all
</Location>

Try to access from your browser

http://localhost/perl/rocks.pl

Using a module to handle a request

create a file Hello.pm and make sure the path exists in @INC
to check the @INC paths
perl -e 'print join("\n",@INC)'

type the following in


package Hello;
use Apache2::RequestRec();
use Apache2::RequestIO();
use Apache2::Const -compile=>qw(OK);

sub handler{
my $r=shift;
$r->content_type('text/html');
print 'welcome';
return Apache2::Const::OK;
}
1;


edit your httpd.conf and add

PerlModule Hello

SetHandler perl-script
PerlResponseHandler Hello
PerlSendHeader On


Use a browser now and try the URL
http://localhost/HI


Useful links

http://www.perl.com/pub/a/2002/02/26/whatismodperl.html
http://www.revsys.com/writings/modperl.html