SlideShare una empresa de Scribd logo
1 de 22
Building dynamic websites with
Mod_Perl
Building dynamic websites with
Mod_Perl
Kamal Nayan
http://tipstricksandhacking.blogspot.in
Topics covered
 What is Perl
 What Web Server do
 What is CGI
 Perl CGI
 What is Mod_Perl
 Why use Mod_Perl
 Difference between CGI and Mod_Perl
 Evolution of website
 How Mod_Perl works with Apache
 The Apache request cycle
 Web Server working diagram
 How to install Mod_Perl
 Mod_Perl Configuration
 How to Check Version
 Mod_Perl Handler
 Further Reading
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
What is Perl
Perl is an all-purpose, open source (free software) interpreted
language maintained and enhanced by a core development team
called the Perl Porters. It is used primarily as a scripting language and
runs on a number of platforms. Although initially designed for the UNIX
operating system.
Perl is interpreted language which is parsed and executed at run time
Instead of being compiled into binary form and then run.
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
• In response to a Web client request
(e.g., http://google.com) a Web server:
 Accepts network connection
 Parses the request (index.html)
 Reads file from disk or runs a dynamic content
generator
 Sends content (headers and body) back
What Web Servers Do
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
What is CGI

Common Gateway Interface, which is just an interface
between browsers and servers

CGI provides a standard way a browser can call, pass data to
and receive response from programs on server

CGI is not a Perl-specific concept. Almost any language can
produce CGI programs but Perl has a very nice interface to
creating CGI methods
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
Perl CGI
Perl is a simple programming language. it's popular for use
on the web. When it's used on the web the programs are
called Perl CGI, because CGI is the way that Perl talks to
your web browser.
e.g.
#!/usr/bin/perl -w
print "Content-type: text/htmlnn";
print "Hello, I am kamal nayan";
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
What is Mod_Perl?
 The fast way to create server side Perl
scripts that replace the need for the
Common Gateway Interface.
 Open-Source interface between Apache
and Perl
 Apache handlers can be written in Perl
 One-time parsing/compilation
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
Why Use Mod_Perl
 As sites grow, their content usually becomes
more dynamic
 Sites ported to mod_perl show request
return rates 200% to 2000% higher
 Generally the more processing of content, the
slower the page return
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
 The main difference between Mod_Perl and Perl scripts
running as CGIs is that Mod_Perl compiles Perl modules
and scripts the first time they are run/used, and keeps them
in memory, ready to be executed in the next request
 A Perl script run as CGI is compiled every time it is run
 Mod_Perl can be used also to create Apache modules in
Perl, that will completely handle the requests as if a normal
Apache module
Difference between CGI and Mod_Perl
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
How Mod_Perl works with Apache
 Mod_Perl allows you to interact with server and
directly alter server behavior
 Gives you the ability to "program within
Apache's
framework instead of around it"
 Allows you to intercept basic Apache functions
and replace them with your own Perl
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
Evolution of a Web-site
PerlRun
How to execute the Perl
interpreter
Perl Registry
This module creates an object
oriented interface to registry. It
allows you to read & update
local as well as remote registry.
The Apache request cycle
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
Web Server working diagram
/home/sulabh/Desktop/webserver.jpg
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
Quick way to install Mod_Perl:
For CentOS :
yum install mod_perl -y
rpm -qa|grep -i mod_perl
For Ubuntu :
apt-get install libapache2-mod-perl2
dpkg -l|grep mod-perl2
How to install Mod_Perl
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
How to install mod_perl
Basic steps to install Mod_Perl:
$ lwp-download http://www.apache.org/dist/httpd/httpd-2.4.9.tar.gz
$ lwp-download http://apache.org/dist/perl/mod_perl-2.0.8.tar.gz
$ tar xzvf httpd-2.4.9.tar.gz
$ tar xzvf mod_perl-2.0.8.tar.gz
$ cd mod_perl-2.0.8
$ perl Makefile.PL –with-apxs=<Path of APXS>
e.g. /usr/local/apache_back/bin/apxs
$ make && make test && make install
$ cd ../httpd-2.4.9
$ make install
LoadModule perl_module modules/mod_perl.so
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
Mod_Perl Configuration
Specific File type :
<Files *.mp>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
</Files>
Specific File :
<Files "^/cgi/get_captcha.cgi">
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
</Files> HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
How to Check Version
To check Apache version
/usr/local/apache/bin/httpd -V
To check Perl version
$perl -v
To check Mod_Perl version
$perl -Mmod_perl 999 or perl -Mmod_perl2 999
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
Mod_Perl Handler
Handlers are simply perl subroutines called by the server at
various stages of the HTTP request cycle. Handlers, are
typically created as a perl modules stored in a library, and
accessible via perl's @INC array.
For example, here's an example that returns a greeting and the
current local time.
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
File:My/Greeting.pm
package My::Greeting;
use strict;
use Apache::Constants qw(OK);
sub handler
{
my $r = shift;
my $now = scalar localtime;
my $server_name = $r->server->server_hostname;
$r->send_http_header('text/plain');
print "Thanks for visiting $server_name.n";
print "The local time is $now.";
return OK;
}
1;
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
We have to save the above file in perl library (e.g. My/Greeting.pm).
Now we have to write below given code in httpd.conf, to return the
above greeting when the URL /hello is visited on your server.
<Location /hello>
SetHandler perl-script
PerlHandler My::Greeting
</Location>
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
Further Reading
CPAN
http://www.cpan.org/
Mod_Perl Guide
http://perl.apache.org/guide
Stas Bekman
FAQ
http://perl.apache.org/faq
Frank Cringle
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN

Más contenido relacionado

La actualidad más candente

CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...Ortus Solutions, Corp
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for DevelopmentChris Tankersley
 
Apache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whaleApache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whaleHenryk Konsek
 
Create dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLCreate dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLkangaro10a
 
Php Performance On Windows
Php Performance On WindowsPhp Performance On Windows
Php Performance On Windowsruslany
 
PHP Enhancement with Windows Server 2008
PHP Enhancement with Windows Server 2008PHP Enhancement with Windows Server 2008
PHP Enhancement with Windows Server 2008Krit Kamtuo
 
WordPress + NGINX Best Practices with EasyEngine
WordPress + NGINX Best Practices with EasyEngineWordPress + NGINX Best Practices with EasyEngine
WordPress + NGINX Best Practices with EasyEngineNGINX, Inc.
 
Js engine performance
Js engine performanceJs engine performance
Js engine performancepaullfc
 
Ruby on Rails workshop for beginner
Ruby on Rails workshop for beginnerRuby on Rails workshop for beginner
Ruby on Rails workshop for beginnerUmair Amjad
 
ApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
ApacheConNA 2015: Apache httpd 2.4 Reverse ProxyApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
ApacheConNA 2015: Apache httpd 2.4 Reverse ProxyJim Jagielski
 
The Integration of Laravel with Swoole
The Integration of Laravel with SwooleThe Integration of Laravel with Swoole
The Integration of Laravel with SwooleAlbert Chen
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011Bachkoutou Toutou
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2Merixstudio
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and DrushPantheon
 
Reverse Installing CPAN
Reverse Installing CPANReverse Installing CPAN
Reverse Installing CPANbrian d foy
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magentoMathew Beane
 
Symfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim RomanovskySymfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim Romanovskyphp-user-group-minsk
 
30 Minutes To CPAN
30 Minutes To CPAN30 Minutes To CPAN
30 Minutes To CPANdaoswald
 

La actualidad más candente (20)

CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
CBDW2014- Intro to CommandBox; The ColdFusion CLI, Package Manager, and REPL ...
 
Composer
ComposerComposer
Composer
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for Development
 
Apache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whaleApache Camel in the belly of the Docker whale
Apache Camel in the belly of the Docker whale
 
Create dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQLCreate dynamic sites with PHP & MySQL
Create dynamic sites with PHP & MySQL
 
Php Performance On Windows
Php Performance On WindowsPhp Performance On Windows
Php Performance On Windows
 
PHP Enhancement with Windows Server 2008
PHP Enhancement with Windows Server 2008PHP Enhancement with Windows Server 2008
PHP Enhancement with Windows Server 2008
 
WordPress + NGINX Best Practices with EasyEngine
WordPress + NGINX Best Practices with EasyEngineWordPress + NGINX Best Practices with EasyEngine
WordPress + NGINX Best Practices with EasyEngine
 
Js engine performance
Js engine performanceJs engine performance
Js engine performance
 
Ruby on Rails workshop for beginner
Ruby on Rails workshop for beginnerRuby on Rails workshop for beginner
Ruby on Rails workshop for beginner
 
ApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
ApacheConNA 2015: Apache httpd 2.4 Reverse ProxyApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
ApacheConNA 2015: Apache httpd 2.4 Reverse Proxy
 
The Integration of Laravel with Swoole
The Integration of Laravel with SwooleThe Integration of Laravel with Swoole
The Integration of Laravel with Swoole
 
Stress Free Deployment - Confoo 2011
Stress Free Deployment  - Confoo 2011Stress Free Deployment  - Confoo 2011
Stress Free Deployment - Confoo 2011
 
Why we choose Symfony2
Why we choose Symfony2Why we choose Symfony2
Why we choose Symfony2
 
Ansible
AnsibleAnsible
Ansible
 
Using Composer with Drupal and Drush
Using Composer with Drupal and DrushUsing Composer with Drupal and Drush
Using Composer with Drupal and Drush
 
Reverse Installing CPAN
Reverse Installing CPANReverse Installing CPAN
Reverse Installing CPAN
 
Zendcon scaling magento
Zendcon scaling magentoZendcon scaling magento
Zendcon scaling magento
 
Symfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim RomanovskySymfony Under Control by Maxim Romanovsky
Symfony Under Control by Maxim Romanovsky
 
30 Minutes To CPAN
30 Minutes To CPAN30 Minutes To CPAN
30 Minutes To CPAN
 

Destacado

plan de alimentacion 1300 Kcal
plan de alimentacion 1300 Kcalplan de alimentacion 1300 Kcal
plan de alimentacion 1300 KcalJaz_Aguayo
 
Pp production plan_template
Pp production plan_templatePp production plan_template
Pp production plan_templatemegrobbo95
 
2013_DS5_FinalReview_11N1064_両者共存の家
2013_DS5_FinalReview_11N1064_両者共存の家2013_DS5_FinalReview_11N1064_両者共存の家
2013_DS5_FinalReview_11N1064_両者共存の家11n1064
 
Mor research - testimonial (Physio-logic) (1)
Mor research - testimonial (Physio-logic) (1)Mor research - testimonial (Physio-logic) (1)
Mor research - testimonial (Physio-logic) (1)Gadi Ginot
 
QAAD Form 1- Application for Government Temporary Permit and Recognition
QAAD Form 1- Application for Government Temporary Permit and Recognition QAAD Form 1- Application for Government Temporary Permit and Recognition
QAAD Form 1- Application for Government Temporary Permit and Recognition Dr. Joy Kenneth Sala Biasong
 
Financial Management (Short-Term Course for Non-Finance Managers) MBA Program
Financial Management (Short-Term Course for Non-Finance Managers) MBA ProgramFinancial Management (Short-Term Course for Non-Finance Managers) MBA Program
Financial Management (Short-Term Course for Non-Finance Managers) MBA ProgramDr. Joy Kenneth Sala Biasong
 
Financial Management (Short-Term Course for Non-Finance Managers) MBA Program
Financial Management (Short-Term Course for Non-Finance Managers) MBA ProgramFinancial Management (Short-Term Course for Non-Finance Managers) MBA Program
Financial Management (Short-Term Course for Non-Finance Managers) MBA ProgramDr. Joy Kenneth Sala Biasong
 
"DepEd Order No.2, s. 2015 Guidelines on the Establishment & Implementation o...
"DepEd Order No.2, s. 2015 Guidelines on the Establishment & Implementation o..."DepEd Order No.2, s. 2015 Guidelines on the Establishment & Implementation o...
"DepEd Order No.2, s. 2015 Guidelines on the Establishment & Implementation o...REYBETH RACELIS
 
las 300 preguntas para desaburrir he interactuar con amigos/pareja
las 300 preguntas para desaburrir he interactuar con amigos/parejalas 300 preguntas para desaburrir he interactuar con amigos/pareja
las 300 preguntas para desaburrir he interactuar con amigos/parejaPablo Martinez Mendoza
 
A study to compare trajectory generation algorithms for automatic bucket fill...
A study to compare trajectory generation algorithms for automatic bucket fill...A study to compare trajectory generation algorithms for automatic bucket fill...
A study to compare trajectory generation algorithms for automatic bucket fill...Reno Filla
 
Representative Testing of Emissions and Fuel Consumption of Working Machines ...
Representative Testing of Emissions and Fuel Consumption of Working Machines ...Representative Testing of Emissions and Fuel Consumption of Working Machines ...
Representative Testing of Emissions and Fuel Consumption of Working Machines ...Reno Filla
 
Automation of Mobile Working Machines
Automation of Mobile Working MachinesAutomation of Mobile Working Machines
Automation of Mobile Working MachinesReno Filla
 

Destacado (16)

plan de alimentacion 1300 Kcal
plan de alimentacion 1300 Kcalplan de alimentacion 1300 Kcal
plan de alimentacion 1300 Kcal
 
Pp production plan_template
Pp production plan_templatePp production plan_template
Pp production plan_template
 
Home work#4
Home work#4Home work#4
Home work#4
 
1
11
1
 
CV of Amanda Zodiates
CV of Amanda ZodiatesCV of Amanda Zodiates
CV of Amanda Zodiates
 
2013_DS5_FinalReview_11N1064_両者共存の家
2013_DS5_FinalReview_11N1064_両者共存の家2013_DS5_FinalReview_11N1064_両者共存の家
2013_DS5_FinalReview_11N1064_両者共存の家
 
Mor research - testimonial (Physio-logic) (1)
Mor research - testimonial (Physio-logic) (1)Mor research - testimonial (Physio-logic) (1)
Mor research - testimonial (Physio-logic) (1)
 
Edteca ppt2
Edteca ppt2Edteca ppt2
Edteca ppt2
 
QAAD Form 1- Application for Government Temporary Permit and Recognition
QAAD Form 1- Application for Government Temporary Permit and Recognition QAAD Form 1- Application for Government Temporary Permit and Recognition
QAAD Form 1- Application for Government Temporary Permit and Recognition
 
Financial Management (Short-Term Course for Non-Finance Managers) MBA Program
Financial Management (Short-Term Course for Non-Finance Managers) MBA ProgramFinancial Management (Short-Term Course for Non-Finance Managers) MBA Program
Financial Management (Short-Term Course for Non-Finance Managers) MBA Program
 
Financial Management (Short-Term Course for Non-Finance Managers) MBA Program
Financial Management (Short-Term Course for Non-Finance Managers) MBA ProgramFinancial Management (Short-Term Course for Non-Finance Managers) MBA Program
Financial Management (Short-Term Course for Non-Finance Managers) MBA Program
 
"DepEd Order No.2, s. 2015 Guidelines on the Establishment & Implementation o...
"DepEd Order No.2, s. 2015 Guidelines on the Establishment & Implementation o..."DepEd Order No.2, s. 2015 Guidelines on the Establishment & Implementation o...
"DepEd Order No.2, s. 2015 Guidelines on the Establishment & Implementation o...
 
las 300 preguntas para desaburrir he interactuar con amigos/pareja
las 300 preguntas para desaburrir he interactuar con amigos/parejalas 300 preguntas para desaburrir he interactuar con amigos/pareja
las 300 preguntas para desaburrir he interactuar con amigos/pareja
 
A study to compare trajectory generation algorithms for automatic bucket fill...
A study to compare trajectory generation algorithms for automatic bucket fill...A study to compare trajectory generation algorithms for automatic bucket fill...
A study to compare trajectory generation algorithms for automatic bucket fill...
 
Representative Testing of Emissions and Fuel Consumption of Working Machines ...
Representative Testing of Emissions and Fuel Consumption of Working Machines ...Representative Testing of Emissions and Fuel Consumption of Working Machines ...
Representative Testing of Emissions and Fuel Consumption of Working Machines ...
 
Automation of Mobile Working Machines
Automation of Mobile Working MachinesAutomation of Mobile Working Machines
Automation of Mobile Working Machines
 

Similar a Building dynamic websites with Mod perl and apache

Web Development in Perl
Web Development in PerlWeb Development in Perl
Web Development in PerlNaveen Gupta
 
Use Xdebug to profile PHP
Use Xdebug to profile PHPUse Xdebug to profile PHP
Use Xdebug to profile PHPSeravo
 
Scale Apache with Nginx
Scale Apache with NginxScale Apache with Nginx
Scale Apache with NginxBud Siddhisena
 
APACHE
APACHEAPACHE
APACHEARJUN
 
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019Viktor Todorov
 
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”Valent Mustamin
 
Perl hosting for beginners - Cluj.pm March 2013
Perl hosting for beginners - Cluj.pm March 2013Perl hosting for beginners - Cluj.pm March 2013
Perl hosting for beginners - Cluj.pm March 2013Arpad Szasz
 
Ch 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet ServersCh 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet Serverswebhostingguy
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerJackson F. de A. Mafra
 
Apache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheApache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheWildan Maulana
 
Integrating PHP With System-i using Web Services
Integrating PHP With System-i using Web ServicesIntegrating PHP With System-i using Web Services
Integrating PHP With System-i using Web ServicesIvo Jansch
 

Similar a Building dynamic websites with Mod perl and apache (20)

Web Development in Perl
Web Development in PerlWeb Development in Perl
Web Development in Perl
 
Use Xdebug to profile PHP
Use Xdebug to profile PHPUse Xdebug to profile PHP
Use Xdebug to profile PHP
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
 
Apache Ppt
Apache PptApache Ppt
Apache Ppt
 
Getting Started: The Environment
Getting Started: The EnvironmentGetting Started: The Environment
Getting Started: The Environment
 
Apache ppt
Apache pptApache ppt
Apache ppt
 
5-WebServers.ppt
5-WebServers.ppt5-WebServers.ppt
5-WebServers.ppt
 
Scale Apache with Nginx
Scale Apache with NginxScale Apache with Nginx
Scale Apache with Nginx
 
PHP as a Service TDC2019
PHP as a Service TDC2019PHP as a Service TDC2019
PHP as a Service TDC2019
 
APACHE
APACHEAPACHE
APACHE
 
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
The Recording HTTP Proxy: Not Yet Another Messiah - Bulgaria PHP 2019
 
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
High Performance Wordpress: “Faster, Cheaper, Easier : Pick Three”
 
Perl hosting for beginners - Cluj.pm March 2013
Perl hosting for beginners - Cluj.pm March 2013Perl hosting for beginners - Cluj.pm March 2013
Perl hosting for beginners - Cluj.pm March 2013
 
Apache Web Server Setup 3
Apache Web Server Setup 3Apache Web Server Setup 3
Apache Web Server Setup 3
 
Ch 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet ServersCh 22: Web Hosting and Internet Servers
Ch 22: Web Hosting and Internet Servers
 
Php Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant KillerPhp Conference Brazil - Phalcon Giant Killer
Php Conference Brazil - Phalcon Giant Killer
 
Lamp Zend Security
Lamp Zend SecurityLamp Zend Security
Lamp Zend Security
 
PHP Development Tools
PHP  Development ToolsPHP  Development Tools
PHP Development Tools
 
Apache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With ApacheApache2 BootCamp : Getting Started With Apache
Apache2 BootCamp : Getting Started With Apache
 
Integrating PHP With System-i using Web Services
Integrating PHP With System-i using Web ServicesIntegrating PHP With System-i using Web Services
Integrating PHP With System-i using Web Services
 

Último

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 

Último (20)

Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Building dynamic websites with Mod perl and apache

  • 1. Building dynamic websites with Mod_Perl Building dynamic websites with Mod_Perl Kamal Nayan http://tipstricksandhacking.blogspot.in
  • 2. Topics covered  What is Perl  What Web Server do  What is CGI  Perl CGI  What is Mod_Perl  Why use Mod_Perl  Difference between CGI and Mod_Perl  Evolution of website  How Mod_Perl works with Apache  The Apache request cycle  Web Server working diagram  How to install Mod_Perl  Mod_Perl Configuration  How to Check Version  Mod_Perl Handler  Further Reading HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 3. What is Perl Perl is an all-purpose, open source (free software) interpreted language maintained and enhanced by a core development team called the Perl Porters. It is used primarily as a scripting language and runs on a number of platforms. Although initially designed for the UNIX operating system. Perl is interpreted language which is parsed and executed at run time Instead of being compiled into binary form and then run. HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 4. • In response to a Web client request (e.g., http://google.com) a Web server:  Accepts network connection  Parses the request (index.html)  Reads file from disk or runs a dynamic content generator  Sends content (headers and body) back What Web Servers Do HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 5. What is CGI  Common Gateway Interface, which is just an interface between browsers and servers  CGI provides a standard way a browser can call, pass data to and receive response from programs on server  CGI is not a Perl-specific concept. Almost any language can produce CGI programs but Perl has a very nice interface to creating CGI methods HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 6. Perl CGI Perl is a simple programming language. it's popular for use on the web. When it's used on the web the programs are called Perl CGI, because CGI is the way that Perl talks to your web browser. e.g. #!/usr/bin/perl -w print "Content-type: text/htmlnn"; print "Hello, I am kamal nayan"; HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 7. What is Mod_Perl?  The fast way to create server side Perl scripts that replace the need for the Common Gateway Interface.  Open-Source interface between Apache and Perl  Apache handlers can be written in Perl  One-time parsing/compilation HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 8. Why Use Mod_Perl  As sites grow, their content usually becomes more dynamic  Sites ported to mod_perl show request return rates 200% to 2000% higher  Generally the more processing of content, the slower the page return HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 9.  The main difference between Mod_Perl and Perl scripts running as CGIs is that Mod_Perl compiles Perl modules and scripts the first time they are run/used, and keeps them in memory, ready to be executed in the next request  A Perl script run as CGI is compiled every time it is run  Mod_Perl can be used also to create Apache modules in Perl, that will completely handle the requests as if a normal Apache module Difference between CGI and Mod_Perl HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 10. How Mod_Perl works with Apache  Mod_Perl allows you to interact with server and directly alter server behavior  Gives you the ability to "program within Apache's framework instead of around it"  Allows you to intercept basic Apache functions and replace them with your own Perl HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 11. Evolution of a Web-site PerlRun How to execute the Perl interpreter Perl Registry This module creates an object oriented interface to registry. It allows you to read & update local as well as remote registry.
  • 12. The Apache request cycle HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 13. Web Server working diagram /home/sulabh/Desktop/webserver.jpg HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 14. Quick way to install Mod_Perl: For CentOS : yum install mod_perl -y rpm -qa|grep -i mod_perl For Ubuntu : apt-get install libapache2-mod-perl2 dpkg -l|grep mod-perl2 How to install Mod_Perl HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 15. How to install mod_perl Basic steps to install Mod_Perl: $ lwp-download http://www.apache.org/dist/httpd/httpd-2.4.9.tar.gz $ lwp-download http://apache.org/dist/perl/mod_perl-2.0.8.tar.gz $ tar xzvf httpd-2.4.9.tar.gz $ tar xzvf mod_perl-2.0.8.tar.gz $ cd mod_perl-2.0.8 $ perl Makefile.PL –with-apxs=<Path of APXS> e.g. /usr/local/apache_back/bin/apxs $ make && make test && make install $ cd ../httpd-2.4.9 $ make install LoadModule perl_module modules/mod_perl.so HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 16. Mod_Perl Configuration Specific File type : <Files *.mp> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI </Files> Specific File : <Files "^/cgi/get_captcha.cgi"> SetHandler perl-script PerlResponseHandler ModPerl::Registry PerlOptions +ParseHeaders Options +ExecCGI </Files> HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 17. How to Check Version To check Apache version /usr/local/apache/bin/httpd -V To check Perl version $perl -v To check Mod_Perl version $perl -Mmod_perl 999 or perl -Mmod_perl2 999 HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 18. Mod_Perl Handler Handlers are simply perl subroutines called by the server at various stages of the HTTP request cycle. Handlers, are typically created as a perl modules stored in a library, and accessible via perl's @INC array. For example, here's an example that returns a greeting and the current local time. HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 19. File:My/Greeting.pm package My::Greeting; use strict; use Apache::Constants qw(OK); sub handler { my $r = shift; my $now = scalar localtime; my $server_name = $r->server->server_hostname; $r->send_http_header('text/plain'); print "Thanks for visiting $server_name.n"; print "The local time is $now."; return OK; } 1; HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 20. We have to save the above file in perl library (e.g. My/Greeting.pm). Now we have to write below given code in httpd.conf, to return the above greeting when the URL /hello is visited on your server. <Location /hello> SetHandler perl-script PerlHandler My::Greeting </Location> HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN
  • 21. Further Reading CPAN http://www.cpan.org/ Mod_Perl Guide http://perl.apache.org/guide Stas Bekman FAQ http://perl.apache.org/faq Frank Cringle HTTP://TIPSTRICKSANDHACKING.BLOGSPOT.IN