Perl hosting for beginners - Cluj.pm March 2013
Upcoming SlideShare
Loading in...5
×
 

Perl hosting for beginners - Cluj.pm March 2013

on

  • 5,401 views

 

Statistics

Views

Total Views
5,401
Views on SlideShare
5,400
Embed Views
1

Actions

Likes
0
Downloads
5
Comments
0

1 Embed 1

http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Perl hosting for beginners - Cluj.pm March 2013 Perl hosting for beginners - Cluj.pm March 2013 Presentation Transcript

  • Perl web hosting for beginners Árpád Szász Freelance Perl Developer Twitter: @arpadszasz Blog: http://arpi.plenum.ro
  • Background ● Programming newbie
  • Background ● Programming newbie ● Want to host a simple dynamic website
  • Background ● Programming newbie ● Want to host a simple dynamic website ● Process must be easy
  • Background ● Programming newbie ● Want to host a simple dynamic website ● Process must be easy ● Using Microsoft Windows as a workstation
  • Background ● Programming newbie ● Want to host a simple dynamic website ● Process must be easy ● Using Microsoft Windows as a workstation ● Using GNU/Linux on the server side
  • Why use Perl? ● Perl makes easy things easy and hard things possible
  • Why use Perl? ● ● Perl makes easy things easy and hard things possible Perl is available by default on every shared host provider's servers (GNU/Linux)
  • Why use Perl? ● ● ● Perl makes easy things easy and hard things possible Perl is available by default on every shared host provider's servers (GNU/Linux) Perl is Modern
  • Why use shared hosting? ● Inexpensive
  • Why use shared hosting? ● Inexpensive ● Easy to setup
  • Strawberry Perl ● Perl distribution for Windows
  • Strawberry Perl ● Perl distribution for Windows ● Available at http://strawberryperl.com/
  • Strawberry Perl ● Perl distribution for Windows ● Available at http://strawberryperl.com/ ● Up to date (Perl version 5.16.3)
  • Apache ● Most popular web server
  • Apache ● ● Most popular web server Windows binaries available at http://httpd.apache.org/download.cgi
  • Mojolicious ● Next generation web framework
  • Mojolicious ● ● Next generation web framework Easy to deploy (only dependent on core Perl 5)
  • Mojolicious ● ● Next generation web framework Easy to deploy (only dependent on core Perl 5) – download from https://github.com/jamadam/mojo-legacy
  • Mojolicious ● ● Next generation web framework Easy to deploy (only dependent on core Perl 5) – download from https://github.com/jamadam/mojo-legacy – extract lib folder from archive to Apache's htdocs folder
  • Configuring Apache ● Allow the use of .htaccess files <Directory "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin"> AllowOverride All Options FollowSymlinks Order allow,deny Allow from all </Directory>
  • Configuring Apache ● Allow the use of .htaccess files ● Enable mod_rewrite LoadModule rewrite_module modules/mod_rewrite.so
  • Configuring Mojolicious app ● Goes into Apache's htdocs folder as app.pl #!perl use 5.10.1; use strict; use lib qw(lib); use Mojolicious::Lite; get '/' => sub { return shift->render('index'); }; get '/*page' => sub { my $self = shift; return $self->render( $self->param('page') ); }; app->start('cgi');
  • Configuring Mojolicious app ● Goes into Apache's htdocs folder as app.pl ● Templates go into htdocs/templates htdocs/templates/index.html.ep htdocs/templates/contact.html.ep ...
  • Configuring .htaccess file ● Execute Perl programs as CGI AddHandler cgi-script .pl Options +ExecCGI
  • Configuring .htaccess file ● Execute Perl programs as CGI ● Route all requests to Mojolicious app RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.pl/$1 [L,QSA]
  • Configuring .htaccess file ● Execute Perl programs as CGI ● Route all requests to Mojolicious app ● Deny listing of templates <FilesMatch ".html.ep"> Order deny,allow Deny from all </FilesMatch>
  • Configuring .htaccess file ● Execute Perl programs as CGI ● Route all requests to Mojolicious app ● Deny listing of templates ● Directory index points to app DirectoryIndex app.pl
  • Configure templates Add HTML markup to templates ● <h1>Welcome!</h1> <p> Hello and welcome to our silly website. </p>
  • Configure templates ● Add HTML markup to templates ● Add Perl code to templates <h1>Welcome!</h1> <p> Hello and welcome to our silly website. Server time is: <%= time %> </p>
  • Deploy ● Transfer contents of htdocs using FTP to server
  • Deploy ● ● Transfer contents of htdocs using FTP to server Access the application on the server via CGI
  • Questions?
  • Thank You! Talk and code available at https://github.com/arpadszasz/perl-hosting-beginners-talk