SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Downloaden Sie, um offline zu lesen
#6




                      Day #2
     Serving Dynamic Content with CGI
                    Wildan Maulana
             wildan.m@openthinklabs.com



           http://workshop.openthinklabs.com
Overview
●   How the CGI protocol works
●   How to configure Apache to run CGI scripts, on
    both Unix and Windows
●   How to troubleshoot common errors
Common Gateway Interface




Source : http://viu.eng.rpi.edu/
CGI Protocol

CERN HTTPd Server                                   NCSA HTTPd Server



      Both provided mechanisms to invoke external
      programs and scripts to create dynamic content but incompatible




                               The Solution

                        The CGI 1.1 specification
CGI Operation
●   Apache receives a request and determines that it
    needs to be served by the CGI program
●   Apache starts an instance of the CGI program
●   Apache passes information about the request to the
    CGI
●   Apache receives the response from the CGI, optionally
    processes its headers and contents, and sends it to the
    client
●   The CGI program finishes and all resources associated
    with it are recalled by the operating system
CGI Environment Variables
Variable Name     Variable Description
SERVER_NAME       Hostname or IP address of the server
REQUEST_METHOD    HTTP request method: HEAD, GET,
                  POST, and so on
REMOTE_ADDR       Client IP address
CONTENT_TYPE      MIME type of any client data being
                  passed by a POST or PUT request
CONTENT_LENGTH    Size of the client data
CGI Response
●   Location: Instructs Apache that the CGI is not going
    to answer the request and that the client should be
    redirected to the specified URL.
●   Status: This is not a valid HTTP header and it is not
    transmitted back to the client, but it indicates the
    HTTP status code for the request to Apache.
●   Content-Type: Specifies the type of data returned in
    the request. For example, if you are returning a Web
    page, the header value should be text/html.
Advantages and Disadvantages of
             CGI Scripts
●   Portability     ●   Performance
●   Simplicity      ●   Code and
●   Existing Code       Presentation
●   Source Hiding
●   Memory Leaks
Configuring Apache
Configuring Apache
                         CGI Content
ScriptAlias
ScriptAlias /usr/local/apache2/cgi-bin/ /cgi-bin/
Configuring Apache
                           Fine-Grained Control
SetHandler Directive

# Any files accessed thru the /cgi-bin/ url will execute as CGI scripts.
<Location “/cgi-bin/”>
 Options +ExecCGI
 SetHandler cgi-script
<Location>
                        Associating CGI Processing with File Extensions
                        # Any files ending in .pl will be executed as CGI scripts
                        <Files *.pl>
                         Options +ExecCGI
                         SetHandler cgi-script
                        </Files>
                        # Any files ending in .cgi in the /usr/local/apache2/htdocs/scripts
                         # will be executed as CGI scripts
                        AddHandler cgi-script .cgi

                        <Directory “/usr/local/apache2/htdocs/scripts”>
                         Options +ExecCGI
                        </Directory>
Configuring Apache
        Action and Script




Action image/gif /cgi-bin/process.cgi
Script PUT /cgi-bin/upload.cgi
Configuring Apache
                          CGI Security
●   Non Parse Headers (NPH) Scripts
    ●   nph-example.cgi
●   Debugging CGI Execution
    ●   ScriptLog
    ●   ScriptLogLength
    ●   ScriptLogBuffer
Unix Configuration
Testing Shell Script CGIs
Unix Configuration
                          Perl Installation
●   Preinstalled Perl
    #which perl
    perl -v
●   Installing Binaries
    ●   Linux
        –   Redhat : rpm -i perl*.rpm
        –   Ubuntu : sudo apt-get install perl
●   Installing from Source
    http://www.perl.com/pub/a/language/info/software.html#sourcecode
Unix Configuration
Testing Perl CGI Scripts
Windows Configuration
●   Testing Batch File CGIs
●   Perl on Windows
    ●   http://www.activestate.com
●   Testing Perl Scripts
Enhancing Your CGI Performance
●   mod_perl
●   FastCGI
Common CGI Problems
●   Forbidden Error
    ●   Filesystem Permissions
    ●   CGI Execute Permissions
●   Internal Server Error
    ●   Program Permissions
    ●   Interpreter Location
    ●   Malformed Headers
●   Other Causes
●   Source Code in the Browser
Q&A
http://workshop.openthinklabs.com/resources
Reference
●   Daniel Lopez Ridruezo; SAMS Teach Yourself
    Apache2 in 24 Hours, SAMS Publishing, 2002
    (Buy this book on Amazon)

Weitere Àhnliche Inhalte

Was ist angesagt?

ăƒžă‚€ă‚Żăƒ­ă‚”ăƒŒăƒ“ă‚čバックスンドAPIぼためぼRESTずgRPC
ăƒžă‚€ă‚Żăƒ­ă‚”ăƒŒăƒ“ă‚čバックスンドAPIぼためぼRESTずgRPCăƒžă‚€ă‚Żăƒ­ă‚”ăƒŒăƒ“ă‚čバックスンドAPIぼためぼRESTずgRPC
ăƒžă‚€ă‚Żăƒ­ă‚”ăƒŒăƒ“ă‚čバックスンドAPIぼためぼRESTずgRPC
disc99_
 
Docker in production service discovery with consul - road to opscon 2015
Docker in production  service discovery with consul - road to opscon 2015Docker in production  service discovery with consul - road to opscon 2015
Docker in production service discovery with consul - road to opscon 2015
Giovanni Toraldo
 
Kubernetes-Meetup
Kubernetes-MeetupKubernetes-Meetup
Kubernetes-Meetup
Vaibhav Kohli
 

Was ist angesagt? (20)

KubeCon EU 2016: A Practical Guide to Container Scheduling
KubeCon EU 2016: A Practical Guide to Container SchedulingKubeCon EU 2016: A Practical Guide to Container Scheduling
KubeCon EU 2016: A Practical Guide to Container Scheduling
 
Generating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPCGenerating Unified APIs with Protocol Buffers and gRPC
Generating Unified APIs with Protocol Buffers and gRPC
 
Import golang; struct microservice
Import golang; struct microserviceImport golang; struct microservice
Import golang; struct microservice
 
Docker pipelines
Docker pipelinesDocker pipelines
Docker pipelines
 
ăƒžă‚€ă‚Żăƒ­ă‚”ăƒŒăƒ“ă‚čバックスンドAPIぼためぼRESTずgRPC
ăƒžă‚€ă‚Żăƒ­ă‚”ăƒŒăƒ“ă‚čバックスンドAPIぼためぼRESTずgRPCăƒžă‚€ă‚Żăƒ­ă‚”ăƒŒăƒ“ă‚čバックスンドAPIぼためぼRESTずgRPC
ăƒžă‚€ă‚Żăƒ­ă‚”ăƒŒăƒ“ă‚čバックスンドAPIぼためぼRESTずgRPC
 
Scale out, with Kubernetes (k8s)
Scale out, with Kubernetes (k8s)Scale out, with Kubernetes (k8s)
Scale out, with Kubernetes (k8s)
 
[GID Live] Open-Source Cloud-Native Programming Language
[GID Live] Open-Source Cloud-Native Programming Language[GID Live] Open-Source Cloud-Native Programming Language
[GID Live] Open-Source Cloud-Native Programming Language
 
Docker in production service discovery with consul - road to opscon 2015
Docker in production  service discovery with consul - road to opscon 2015Docker in production  service discovery with consul - road to opscon 2015
Docker in production service discovery with consul - road to opscon 2015
 
Architectural caching patterns for kubernetes
Architectural caching patterns for kubernetesArchitectural caching patterns for kubernetes
Architectural caching patterns for kubernetes
 
Network services on Kubernetes on premise
Network services on Kubernetes on premiseNetwork services on Kubernetes on premise
Network services on Kubernetes on premise
 
NGINX Kubernetes Ingress Controller: Getting Started – EMEA
NGINX Kubernetes Ingress Controller: Getting Started – EMEANGINX Kubernetes Ingress Controller: Getting Started – EMEA
NGINX Kubernetes Ingress Controller: Getting Started – EMEA
 
Writing a fast HTTP parser
Writing a fast HTTP parserWriting a fast HTTP parser
Writing a fast HTTP parser
 
Mongo db - How we use Go and MongoDB by Sam Helman
Mongo db - How we use Go and MongoDB by Sam HelmanMongo db - How we use Go and MongoDB by Sam Helman
Mongo db - How we use Go and MongoDB by Sam Helman
 
Kubernetes-Meetup
Kubernetes-MeetupKubernetes-Meetup
Kubernetes-Meetup
 
Introducing Koki Short
Introducing Koki ShortIntroducing Koki Short
Introducing Koki Short
 
Building microservices with grpc
Building microservices with grpcBuilding microservices with grpc
Building microservices with grpc
 
Test-Driven Infrastructure with Chef
Test-Driven Infrastructure with ChefTest-Driven Infrastructure with Chef
Test-Driven Infrastructure with Chef
 
CI/CD Pipeline mit Gitlab CI und Kubernetes
CI/CD Pipeline mit Gitlab CI und KubernetesCI/CD Pipeline mit Gitlab CI und Kubernetes
CI/CD Pipeline mit Gitlab CI und Kubernetes
 
Docker for tooling
Docker for toolingDocker for tooling
Docker for tooling
 
Common Node
Common NodeCommon Node
Common Node
 

Andere mochten auch

SES Chicago 2013 - Responsive, Dynamic, Serving Mobile: Which Path is Right f...
SES Chicago 2013 - Responsive, Dynamic, Serving Mobile: Which Path is Right f...SES Chicago 2013 - Responsive, Dynamic, Serving Mobile: Which Path is Right f...
SES Chicago 2013 - Responsive, Dynamic, Serving Mobile: Which Path is Right f...
Benu Aggarwal
 

Andere mochten auch (6)

Ficha Tecnica EstanterĂ­A Uninorm
Ficha Tecnica EstanterĂ­A UninormFicha Tecnica EstanterĂ­A Uninorm
Ficha Tecnica EstanterĂ­A Uninorm
 
SES Chicago 2013 - Responsive, Dynamic, Serving Mobile: Which Path is Right f...
SES Chicago 2013 - Responsive, Dynamic, Serving Mobile: Which Path is Right f...SES Chicago 2013 - Responsive, Dynamic, Serving Mobile: Which Path is Right f...
SES Chicago 2013 - Responsive, Dynamic, Serving Mobile: Which Path is Right f...
 
Advanced Content Targeting & Personalization Within the Digital Experience Us...
Advanced Content Targeting & Personalization Within the Digital Experience Us...Advanced Content Targeting & Personalization Within the Digital Experience Us...
Advanced Content Targeting & Personalization Within the Digital Experience Us...
 
Managing data workflows with Luigi
Managing data workflows with LuigiManaging data workflows with Luigi
Managing data workflows with Luigi
 
Luigi presentation NYC Data Science
Luigi presentation NYC Data ScienceLuigi presentation NYC Data Science
Luigi presentation NYC Data Science
 
A Beginner's Guide to Building Data Pipelines with Luigi
A Beginner's Guide to Building Data Pipelines with LuigiA Beginner's Guide to Building Data Pipelines with Luigi
A Beginner's Guide to Building Data Pipelines with Luigi
 

Ähnlich wie Apache2 BootCamp : Serving Dynamic Content with CGI

are available here
are available hereare available here
are available here
webhostingguy
 
Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011
Tatsuhiko Miyagawa
 
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
webhostingguy
 
Common Gateway Interface
Common Gateway InterfaceCommon Gateway Interface
Common Gateway Interface
Piero Fraternali
 

Ähnlich wie Apache2 BootCamp : Serving Dynamic Content with CGI (20)

Python cgi programming
Python cgi programmingPython cgi programming
Python cgi programming
 
Cgi
CgiCgi
Cgi
 
Plack basics for Perl websites - YAPC::EU 2011
Plack basics for Perl websites - YAPC::EU 2011Plack basics for Perl websites - YAPC::EU 2011
Plack basics for Perl websites - YAPC::EU 2011
 
Nginx pres
Nginx presNginx pres
Nginx pres
 
Apache Web Server Setup 3
Apache Web Server Setup 3Apache Web Server Setup 3
Apache Web Server Setup 3
 
are available here
are available hereare available here
are available here
 
Cgi
CgiCgi
Cgi
 
Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011Deploying Plack Web Applications: OSCON 2011
Deploying Plack Web Applications: OSCON 2011
 
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
OpenShift Origin Community Day (Boston) Extending OpenShift Origin: Build You...
 
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
OpenShift Origin Community Day (Boston) Writing Cartridges V2 by Jhon Honce
 
Plack at OSCON 2010
Plack at OSCON 2010Plack at OSCON 2010
Plack at OSCON 2010
 
Building dynamic websites with Mod perl and apache
Building dynamic websites with Mod perl and apacheBuilding dynamic websites with Mod perl and apache
Building dynamic websites with Mod perl and apache
 
CGI by rj
CGI by rjCGI by rj
CGI by rj
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems
 
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
 
Extending kubernetes
Extending kubernetesExtending kubernetes
Extending kubernetes
 
Web Server - Internet Applications
Web Server - Internet ApplicationsWeb Server - Internet Applications
Web Server - Internet Applications
 
CGI Presentation
CGI PresentationCGI Presentation
CGI Presentation
 
Common Gateway Interface
Common Gateway InterfaceCommon Gateway Interface
Common Gateway Interface
 
PHP on Windows 2008
PHP on Windows 2008PHP on Windows 2008
PHP on Windows 2008
 

Mehr von Wildan Maulana

Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Wildan Maulana
 
Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014
Wildan Maulana
 
ICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi ArsipICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi Arsip
Wildan Maulana
 
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RWOpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
Wildan Maulana
 
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
Wildan Maulana
 
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyToolsPostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
Wildan Maulana
 
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
Wildan Maulana
 
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai SpMensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Wildan Maulana
 
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity ProviderKonfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
Wildan Maulana
 
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Wildan Maulana
 
Instalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphpInstalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphp
Wildan Maulana
 
River Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River RestorationRiver Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River Restoration
Wildan Maulana
 
Penilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan DasarPenilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan Dasar
Wildan Maulana
 
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and UsesProyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Wildan Maulana
 
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang TuaOpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
Wildan Maulana
 

Mehr von Wildan Maulana (20)

Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018Hasil Pendataan Potensi Desa 2018
Hasil Pendataan Potensi Desa 2018
 
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
Double for Nothing? Experimental Evidence on an Unconditional TeacherSalary I...
 
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam MelonKetahanan Pangan #1 : Gerakan Sekolah Menanam Melon
Ketahanan Pangan #1 : Gerakan Sekolah Menanam Melon
 
Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014Pengembangan OpenThink SAS 2013-2014
Pengembangan OpenThink SAS 2013-2014
 
ICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi ArsipICA – AtoM : Retensi Arsip
ICA – AtoM : Retensi Arsip
 
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RWOpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
OpenThink Labs Workshop : Ketahanan Pangan Skala RT/RW
 
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
OpenThink Labs : Dengar Pendapat Komunitas ciliwung dengan kemen pu dan kemen...
 
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyToolsPostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
PostgreSQL BootCamp : Manajemen Master Data dengan SkyTools
 
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...Mensetup Google Apps sebagai IdP jenis openID  dan Aplikasi Berbasis CakePHP ...
Mensetup Google Apps sebagai IdP jenis openID dan Aplikasi Berbasis CakePHP ...
 
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai SpMensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
Mensetup Google Apps sebagai IdP jenis openID dan Wordpress sebagai Sp
 
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity ProviderKonfigurasi simpleSAMLphp  dengan Google Apps Sebagai Identity Provider
Konfigurasi simpleSAMLphp dengan Google Apps Sebagai Identity Provider
 
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
Instalasi simpleSAMLphp sebagai Identity Provider (IdP)
 
Instalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphpInstalasi dan Konfigurasi simpleSAMLphp
Instalasi dan Konfigurasi simpleSAMLphp
 
River Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River RestorationRiver Restoration in Asia and Connection Between IWRM and River Restoration
River Restoration in Asia and Connection Between IWRM and River Restoration
 
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...Optimasi Limpasan Air Limbah  Ke Kali Surabaya (Segmen Sepanjang – Jagir)  De...
Optimasi Limpasan Air Limbah Ke Kali Surabaya (Segmen Sepanjang – Jagir) De...
 
Penilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan DasarPenilaian Siswa di Finlandia - Pendidikan Dasar
Penilaian Siswa di Finlandia - Pendidikan Dasar
 
Statistik Listrik
Statistik ListrikStatistik Listrik
Statistik Listrik
 
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and UsesProyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
Proyek Al-'Alaq : Electric Bicycles ; History, Characteristics, and Uses
 
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang TuaOpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
OpenThink SAS : Interaksi Antara Sekolah, Wali Kelas, Siswa dan Orang Tua
 
Menggunakan AlisJK : Equating
Menggunakan AlisJK : EquatingMenggunakan AlisJK : Equating
Menggunakan AlisJK : Equating
 

KĂŒrzlich hochgeladen

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

KĂŒrzlich hochgeladen (20)

MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
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
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 

Apache2 BootCamp : Serving Dynamic Content with CGI

  • 1. #6 Day #2 Serving Dynamic Content with CGI Wildan Maulana wildan.m@openthinklabs.com http://workshop.openthinklabs.com
  • 2. Overview ● How the CGI protocol works ● How to configure Apache to run CGI scripts, on both Unix and Windows ● How to troubleshoot common errors
  • 3. Common Gateway Interface Source : http://viu.eng.rpi.edu/
  • 4. CGI Protocol CERN HTTPd Server NCSA HTTPd Server Both provided mechanisms to invoke external programs and scripts to create dynamic content but incompatible The Solution The CGI 1.1 specification
  • 5. CGI Operation ● Apache receives a request and determines that it needs to be served by the CGI program ● Apache starts an instance of the CGI program ● Apache passes information about the request to the CGI ● Apache receives the response from the CGI, optionally processes its headers and contents, and sends it to the client ● The CGI program finishes and all resources associated with it are recalled by the operating system
  • 6. CGI Environment Variables Variable Name Variable Description SERVER_NAME Hostname or IP address of the server REQUEST_METHOD HTTP request method: HEAD, GET, POST, and so on REMOTE_ADDR Client IP address CONTENT_TYPE MIME type of any client data being passed by a POST or PUT request CONTENT_LENGTH Size of the client data
  • 7. CGI Response ● Location: Instructs Apache that the CGI is not going to answer the request and that the client should be redirected to the specified URL. ● Status: This is not a valid HTTP header and it is not transmitted back to the client, but it indicates the HTTP status code for the request to Apache. ● Content-Type: Specifies the type of data returned in the request. For example, if you are returning a Web page, the header value should be text/html.
  • 8. Advantages and Disadvantages of CGI Scripts ● Portability ● Performance ● Simplicity ● Code and ● Existing Code Presentation ● Source Hiding ● Memory Leaks
  • 10. Configuring Apache CGI Content ScriptAlias ScriptAlias /usr/local/apache2/cgi-bin/ /cgi-bin/
  • 11. Configuring Apache Fine-Grained Control SetHandler Directive # Any files accessed thru the /cgi-bin/ url will execute as CGI scripts. <Location “/cgi-bin/”> Options +ExecCGI SetHandler cgi-script <Location> Associating CGI Processing with File Extensions # Any files ending in .pl will be executed as CGI scripts <Files *.pl> Options +ExecCGI SetHandler cgi-script </Files> # Any files ending in .cgi in the /usr/local/apache2/htdocs/scripts # will be executed as CGI scripts AddHandler cgi-script .cgi <Directory “/usr/local/apache2/htdocs/scripts”> Options +ExecCGI </Directory>
  • 12. Configuring Apache Action and Script Action image/gif /cgi-bin/process.cgi Script PUT /cgi-bin/upload.cgi
  • 13. Configuring Apache CGI Security ● Non Parse Headers (NPH) Scripts ● nph-example.cgi ● Debugging CGI Execution ● ScriptLog ● ScriptLogLength ● ScriptLogBuffer
  • 15. Unix Configuration Perl Installation ● Preinstalled Perl #which perl perl -v ● Installing Binaries ● Linux – Redhat : rpm -i perl*.rpm – Ubuntu : sudo apt-get install perl ● Installing from Source http://www.perl.com/pub/a/language/info/software.html#sourcecode
  • 17. Windows Configuration ● Testing Batch File CGIs ● Perl on Windows ● http://www.activestate.com ● Testing Perl Scripts
  • 18. Enhancing Your CGI Performance ● mod_perl ● FastCGI
  • 19. Common CGI Problems ● Forbidden Error ● Filesystem Permissions ● CGI Execute Permissions ● Internal Server Error ● Program Permissions ● Interpreter Location ● Malformed Headers ● Other Causes ● Source Code in the Browser
  • 21. Reference ● Daniel Lopez Ridruezo; SAMS Teach Yourself Apache2 in 24 Hours, SAMS Publishing, 2002 (Buy this book on Amazon)