SlideShare une entreprise Scribd logo
1  sur  21
Télécharger pour lire hors ligne
#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)

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à Apache2 BootCamp : Serving Dynamic Content with CGI

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
 

Similaire à 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
 

Plus de 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
 

Plus de 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
 

Dernier

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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
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
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
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
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
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...
 
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
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

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)