SlideShare a Scribd company logo
1 of 11
Configure Python + WSGI


                            Sitthykun LY
                             @sitthykun
                ly.sitthykun@gmail.com
We will talk
●   What is Python Language??
●   How to set up Python??
●   How to run??
●   What is WSGI??
●   How to set up WSGI??
●   How to run??
What is Python Language??
●   Python is an interpreted, general-purpose high-level programming
    language whose design philosophy emphasizes code readability. Python
    aims to combine "remarkable power with very clear syntax", and its
    standard library is large and comprehensive. Its use of indentation for
    block delimiters is unique among popular programming languages.
●


●   Python supports multiple programming paradigms, primarily but not
    limited to object oriented, imperative and, to a lesser extent, functional
    programming styles. It features a fully dynamic type system and
    automatic memory management, similar to that of Scheme, Ruby, Perl,
    and Tcl. Like other dynamic languages, Python is often used as a
    scripting language, but is also used in a wide range of non-scripting
    contexts.
●   http://en.wikipedia.org/wiki/Python_language
●
What is WSGI??
●   The Web Server Gateway Interface (WSGI) defines
    a simple and universal interface between web
    servers and web applications or frameworks for the
    Python
●   WSGI(sometimes pronounced like 'whiskey' or 'wiz-
    gee') was created as a low-level interface between
    web servers and web applications or frameworks to
    promote common ground for portable web
    application development. WSGI is based on the
    existing CGI standard.
●   http://en.wikipedia.org/wiki/Wsgi
How to set up WSGI??
●   Assuming you have Apache2, installed, you'll
    need to install the WSGI module:
    ●   sudo apt-get install libapache2-mod-wsgi
●   This should install the module. Now to activate
    it:
    ●   sudo a2enmod mod-wsgi
●   Now to restart Apache2:
    ●   sudo /etc/init.d/apache2 restart
How to set up WSGI??
●   Okay, we have the module installed and ready
    to go, but now we need to associate the module
    with the ".wsgi" extension on your server. This
    will make files with a .wsgi extension use the
    wsgi module for processing. Open up
    /etc/apache2/sites-available/default:
    ●   sudo gedit /etc/apache2/sites-available/default
How to set up WSGI??
●   Around line 10, you should have something like
    this:
    ●   <Directory /var/www/>
    ●   Options Indexes FollowSymLinks MultiViews
        ExecCGI
    ●   AllowOverride None
    ●   Order allow,deny
    ●   allow from all
    ●   </Directory>
How to set up WSGI??
●   Replace it with this:
    ●   <Directory /var/www/>
    ●   Options Indexes FollowSymLinks MultiViews ExecCGI
    ●


    ●   AddHandler cgi-script .cgi
    ●   AddHandler wsgi-script .wsgi
    ●


    ●   AllowOverride None
    ●   Order allow,deny
    ●   allow from all
    ●   </Directory>
How to set up WSGI??
●   If you don't want to replace the whole thing, all
    you need to do is add "ExecCGI" to the Options
    list, and add the handlers cgi-script and wsgi-
    script (shown above).
●   That's it. Restart Apache:
    ●   sudo /etc/init.d/apache2 restart
How to set up WSGI??
●   You're done!
●   If you want to make "index.wsgi" act as an index
    for your directory (much like index.htm,
    index.html, index.php), open up
    /etc/apache2/mods-enabled/dir.conf:
    ●   sudo gedit /etc/apache2/mods-enabled/dir.conf
●   And change line (the line that has the
    DirectoryIndex) to:
    ●   DirectoryIndex index.html index.cgi index.pl
        index.php index.xhtml index.htm index.wsgi
How to set up run WSGI??
●   Create index.wsgi:
    ●   def application(environ, start_response):
    ●    status = '200 OK'
    ●    output = 'Hello World!'
    ●


    ●    response_headers = [('Content-type', 'text/plain'),
    ●                  ('Content-Length', str(len(output)))]
    ●    start_response(status, response_headers)
    ●


    ●    return [output]
●   Go to http://localhost/index.wsgi

More Related Content

What's hot

Grails 101
Grails 101Grails 101
Grails 101Lim Kin
 
Free jQuery Grid Plugin - jQGrid
Free jQuery Grid Plugin - jQGridFree jQuery Grid Plugin - jQGrid
Free jQuery Grid Plugin - jQGridprowebguru
 
Grunt understanding
Grunt understandingGrunt understanding
Grunt understandingKhalid Khan
 
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...niallo
 
JavaScript Jump Start
JavaScript Jump StartJavaScript Jump Start
JavaScript Jump StartHaim Michael
 
Creating custom chrome extensions
Creating custom chrome extensionsCreating custom chrome extensions
Creating custom chrome extensionsvaluebound
 
Jakarta js meetup kudo
Jakarta js meetup kudoJakarta js meetup kudo
Jakarta js meetup kudoAgung Julisman
 
Introduction to Moodle Development
Introduction to Moodle DevelopmentIntroduction to Moodle Development
Introduction to Moodle Developmentmoorejon
 
Front-end tools in java webapps
Front-end tools in java webappsFront-end tools in java webapps
Front-end tools in java webappsbenfante
 
WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)
WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)
WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)Hyun-woo Park
 
Drush Aegir & Drush, Drupal Roadshow Austria
Drush Aegir & Drush, Drupal Roadshow AustriaDrush Aegir & Drush, Drupal Roadshow Austria
Drush Aegir & Drush, Drupal Roadshow AustriaIztok Smolic
 
[HKDUG] #20180512 - Fix Hacked Drupal with GIT
[HKDUG] #20180512 - Fix Hacked Drupal with GIT[HKDUG] #20180512 - Fix Hacked Drupal with GIT
[HKDUG] #20180512 - Fix Hacked Drupal with GITWong Hoi Sing Edison
 
WSO2 Presentation Layer
WSO2 Presentation LayerWSO2 Presentation Layer
WSO2 Presentation LayerNuwan Bandara
 
Yahoo! Mojito talk on Agency Hackday
Yahoo! Mojito talk on Agency HackdayYahoo! Mojito talk on Agency Hackday
Yahoo! Mojito talk on Agency HackdayGaurav Vaish
 
WPE, a New WebKit Port Optimised for Embedded (IBC 2017)
WPE, a New WebKit Port Optimised for Embedded (IBC 2017)WPE, a New WebKit Port Optimised for Embedded (IBC 2017)
WPE, a New WebKit Port Optimised for Embedded (IBC 2017)Igalia
 
Grunt: the wild boar dev's best friend - WordCamp London 2018
Grunt: the wild boar dev's best friend - WordCamp London 2018Grunt: the wild boar dev's best friend - WordCamp London 2018
Grunt: the wild boar dev's best friend - WordCamp London 2018Marco Chiesi
 
Python Static Site Generator in Pelican
Python Static Site Generator in  PelicanPython Static Site Generator in  Pelican
Python Static Site Generator in PelicanGaurav Sehrawat
 
Django deployment and rpm+yum
Django deployment and rpm+yumDjango deployment and rpm+yum
Django deployment and rpm+yumWalter Liu
 

What's hot (20)

Grails 101
Grails 101Grails 101
Grails 101
 
Free jQuery Grid Plugin - jQGrid
Free jQuery Grid Plugin - jQGridFree jQuery Grid Plugin - jQGrid
Free jQuery Grid Plugin - jQGrid
 
Grunt understanding
Grunt understandingGrunt understanding
Grunt understanding
 
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
Continuous Deployment of Front-end JavaScript with StriderCD, Github and Sauc...
 
JavaScript Jump Start
JavaScript Jump StartJavaScript Jump Start
JavaScript Jump Start
 
Creating custom chrome extensions
Creating custom chrome extensionsCreating custom chrome extensions
Creating custom chrome extensions
 
GruntJS + Wordpress
GruntJS + WordpressGruntJS + Wordpress
GruntJS + Wordpress
 
Jakarta js meetup kudo
Jakarta js meetup kudoJakarta js meetup kudo
Jakarta js meetup kudo
 
Introduction to Moodle Development
Introduction to Moodle DevelopmentIntroduction to Moodle Development
Introduction to Moodle Development
 
Front-end tools in java webapps
Front-end tools in java webappsFront-end tools in java webapps
Front-end tools in java webapps
 
WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)
WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)
WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)
 
Drush Aegir & Drush, Drupal Roadshow Austria
Drush Aegir & Drush, Drupal Roadshow AustriaDrush Aegir & Drush, Drupal Roadshow Austria
Drush Aegir & Drush, Drupal Roadshow Austria
 
[HKDUG] #20180512 - Fix Hacked Drupal with GIT
[HKDUG] #20180512 - Fix Hacked Drupal with GIT[HKDUG] #20180512 - Fix Hacked Drupal with GIT
[HKDUG] #20180512 - Fix Hacked Drupal with GIT
 
WSO2 Presentation Layer
WSO2 Presentation LayerWSO2 Presentation Layer
WSO2 Presentation Layer
 
Yahoo! Mojito talk on Agency Hackday
Yahoo! Mojito talk on Agency HackdayYahoo! Mojito talk on Agency Hackday
Yahoo! Mojito talk on Agency Hackday
 
WPE, a New WebKit Port Optimised for Embedded (IBC 2017)
WPE, a New WebKit Port Optimised for Embedded (IBC 2017)WPE, a New WebKit Port Optimised for Embedded (IBC 2017)
WPE, a New WebKit Port Optimised for Embedded (IBC 2017)
 
Grunt: the wild boar dev's best friend - WordCamp London 2018
Grunt: the wild boar dev's best friend - WordCamp London 2018Grunt: the wild boar dev's best friend - WordCamp London 2018
Grunt: the wild boar dev's best friend - WordCamp London 2018
 
DiscoJuice
DiscoJuiceDiscoJuice
DiscoJuice
 
Python Static Site Generator in Pelican
Python Static Site Generator in  PelicanPython Static Site Generator in  Pelican
Python Static Site Generator in Pelican
 
Django deployment and rpm+yum
Django deployment and rpm+yumDjango deployment and rpm+yum
Django deployment and rpm+yum
 

Similar to Configure Python + WSGI in 40 chars

Volunteering at YouSee on Technology Support
Volunteering at YouSee on Technology SupportVolunteering at YouSee on Technology Support
Volunteering at YouSee on Technology SupportYouSee
 
GWT - Building Rich Internet Applications Using OO Tools
GWT - Building Rich Internet Applications Using OO ToolsGWT - Building Rich Internet Applications Using OO Tools
GWT - Building Rich Internet Applications Using OO Toolsbarciszewski
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Develcz
 
Jaggery Introductory Webinar
Jaggery Introductory WebinarJaggery Introductory Webinar
Jaggery Introductory WebinarNuwan Bandara
 
Nuxeo WebEngine and GlassFish v3
Nuxeo WebEngine and GlassFish v3Nuxeo WebEngine and GlassFish v3
Nuxeo WebEngine and GlassFish v3Nuxeo
 
OTLY: A framework for realtime collaboration
OTLY: A framework for realtime collaborationOTLY: A framework for realtime collaboration
OTLY: A framework for realtime collaborationXWiki
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingAlessandro Molina
 
PHP BASIC PRESENTATION
PHP BASIC PRESENTATIONPHP BASIC PRESENTATION
PHP BASIC PRESENTATIONkrutitrivedi
 
How to build a Portofino application
How to build a Portofino applicationHow to build a Portofino application
How to build a Portofino applicationGiampiero Granatella
 
Drupal in 5mins + Previewing Drupal 8.x
Drupal in 5mins + Previewing Drupal 8.xDrupal in 5mins + Previewing Drupal 8.x
Drupal in 5mins + Previewing Drupal 8.xWong Hoi Sing Edison
 
Gradle build automation tool
Gradle   build automation toolGradle   build automation tool
Gradle build automation toolIoan Eugen Stan
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to ApigilityEngineor
 
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
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Engineor
 
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...Ontico
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201ylefebvre
 
LasCon 2014 DevOoops
LasCon 2014 DevOoops LasCon 2014 DevOoops
LasCon 2014 DevOoops Chris Gates
 
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.Graham Dumpleton
 
Instant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositoriesInstant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositoriesYshay Yaacobi
 

Similar to Configure Python + WSGI in 40 chars (20)

Volunteering at YouSee on Technology Support
Volunteering at YouSee on Technology SupportVolunteering at YouSee on Technology Support
Volunteering at YouSee on Technology Support
 
GWT - Building Rich Internet Applications Using OO Tools
GWT - Building Rich Internet Applications Using OO ToolsGWT - Building Rich Internet Applications Using OO Tools
GWT - Building Rich Internet Applications Using OO Tools
 
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
 
Jaggery Introductory Webinar
Jaggery Introductory WebinarJaggery Introductory Webinar
Jaggery Introductory Webinar
 
Nuxeo WebEngine and GlassFish v3
Nuxeo WebEngine and GlassFish v3Nuxeo WebEngine and GlassFish v3
Nuxeo WebEngine and GlassFish v3
 
OTLY: A framework for realtime collaboration
OTLY: A framework for realtime collaborationOTLY: A framework for realtime collaboration
OTLY: A framework for realtime collaboration
 
EuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears TrainingEuroPython 2013 - Python3 TurboGears Training
EuroPython 2013 - Python3 TurboGears Training
 
PHP BASIC PRESENTATION
PHP BASIC PRESENTATIONPHP BASIC PRESENTATION
PHP BASIC PRESENTATION
 
How to build a Portofino application
How to build a Portofino applicationHow to build a Portofino application
How to build a Portofino application
 
Drupal in 5mins + Previewing Drupal 8.x
Drupal in 5mins + Previewing Drupal 8.xDrupal in 5mins + Previewing Drupal 8.x
Drupal in 5mins + Previewing Drupal 8.x
 
Gradle build automation tool
Gradle   build automation toolGradle   build automation tool
Gradle build automation tool
 
Introduction to Apigility
Introduction to ApigilityIntroduction to Apigility
Introduction to Apigility
 
NodeJS
NodeJSNodeJS
NodeJS
 
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
 
Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)Apigility introduction v2 (glasgow php)
Apigility introduction v2 (glasgow php)
 
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
Подталкиваем PHP к пределу возможностей, Michael Armstrong (lite speed techno...
 
WordPress Plugin Development 201
WordPress Plugin Development 201WordPress Plugin Development 201
WordPress Plugin Development 201
 
LasCon 2014 DevOoops
LasCon 2014 DevOoops LasCon 2014 DevOoops
LasCon 2014 DevOoops
 
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
PyCon AU 2010 - Getting Started With Apache/mod_wsgi.
 
Instant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositoriesInstant developer onboarding with self contained repositories
Instant developer onboarding with self contained repositories
 

Configure Python + WSGI in 40 chars

  • 1. Configure Python + WSGI Sitthykun LY @sitthykun ly.sitthykun@gmail.com
  • 2. We will talk ● What is Python Language?? ● How to set up Python?? ● How to run?? ● What is WSGI?? ● How to set up WSGI?? ● How to run??
  • 3. What is Python Language?? ● Python is an interpreted, general-purpose high-level programming language whose design philosophy emphasizes code readability. Python aims to combine "remarkable power with very clear syntax", and its standard library is large and comprehensive. Its use of indentation for block delimiters is unique among popular programming languages. ● ● Python supports multiple programming paradigms, primarily but not limited to object oriented, imperative and, to a lesser extent, functional programming styles. It features a fully dynamic type system and automatic memory management, similar to that of Scheme, Ruby, Perl, and Tcl. Like other dynamic languages, Python is often used as a scripting language, but is also used in a wide range of non-scripting contexts. ● http://en.wikipedia.org/wiki/Python_language ●
  • 4. What is WSGI?? ● The Web Server Gateway Interface (WSGI) defines a simple and universal interface between web servers and web applications or frameworks for the Python ● WSGI(sometimes pronounced like 'whiskey' or 'wiz- gee') was created as a low-level interface between web servers and web applications or frameworks to promote common ground for portable web application development. WSGI is based on the existing CGI standard. ● http://en.wikipedia.org/wiki/Wsgi
  • 5. How to set up WSGI?? ● Assuming you have Apache2, installed, you'll need to install the WSGI module: ● sudo apt-get install libapache2-mod-wsgi ● This should install the module. Now to activate it: ● sudo a2enmod mod-wsgi ● Now to restart Apache2: ● sudo /etc/init.d/apache2 restart
  • 6. How to set up WSGI?? ● Okay, we have the module installed and ready to go, but now we need to associate the module with the ".wsgi" extension on your server. This will make files with a .wsgi extension use the wsgi module for processing. Open up /etc/apache2/sites-available/default: ● sudo gedit /etc/apache2/sites-available/default
  • 7. How to set up WSGI?? ● Around line 10, you should have something like this: ● <Directory /var/www/> ● Options Indexes FollowSymLinks MultiViews ExecCGI ● AllowOverride None ● Order allow,deny ● allow from all ● </Directory>
  • 8. How to set up WSGI?? ● Replace it with this: ● <Directory /var/www/> ● Options Indexes FollowSymLinks MultiViews ExecCGI ● ● AddHandler cgi-script .cgi ● AddHandler wsgi-script .wsgi ● ● AllowOverride None ● Order allow,deny ● allow from all ● </Directory>
  • 9. How to set up WSGI?? ● If you don't want to replace the whole thing, all you need to do is add "ExecCGI" to the Options list, and add the handlers cgi-script and wsgi- script (shown above). ● That's it. Restart Apache: ● sudo /etc/init.d/apache2 restart
  • 10. How to set up WSGI?? ● You're done! ● If you want to make "index.wsgi" act as an index for your directory (much like index.htm, index.html, index.php), open up /etc/apache2/mods-enabled/dir.conf: ● sudo gedit /etc/apache2/mods-enabled/dir.conf ● And change line (the line that has the DirectoryIndex) to: ● DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm index.wsgi
  • 11. How to set up run WSGI?? ● Create index.wsgi: ● def application(environ, start_response): ● status = '200 OK' ● output = 'Hello World!' ● ● response_headers = [('Content-type', 'text/plain'), ● ('Content-Length', str(len(output)))] ● start_response(status, response_headers) ● ● return [output] ● Go to http://localhost/index.wsgi