How do I get my Poet web site running under Apache2?

611 views Asked by At

If I currently have a Poet web site running under the standalone plackup server (via run.pl), how do I configure Apache2 to host this Poet web site?

Searches for "+apache2 +poet" retrieve plenty of results about poets using Apache2 (to publish their poetry), and articles such as "Mason 2 will work with Apache/mod_perl 1." Then there are documents such as http://metacpan.org/pod/PSGI::FAQ which tell me “In Plack, we already support most web servers like Apache2” without giving any of the details of how such support is provided.

What is the minimal Apache2 config file I need in order to get my existing Poet web site running under Apache?

Here is my existing project layout:

/Users/me/Documents/Ponies/poet
    bin
        run.pl
    comps
        index.mc
    conf
    data
    db
    lib
    logs
    static
    t

Here is my starting httpd.conf file:

LoadModule log_config_module /opt/local/apache2/modules/mod_log_config.so

Listen 5000
ServerRoot /Users/me/Documents/Ponies/poet
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog logs/access.log combined
Errorlog logs/error.log
PidFile httpd.pid
LockFile accept.lock
User  me
Group staff

<VirtualHost *:5000>
ServerName foo.local
DocumentRoot /Users/me/Documents/Ponies/poet/
AddHandler cgi-script .cgi .pl .py
<Directory "/Users/me/Documents/Ponies/poet">
Options +ExecCGI
</Directory>
</VirtualHost>

Links to appropriate documentation would be appreciated, as long as there is some indication of what part of the Poet web site I need to point to in order to get a URL such as http://foo.local/ponies/ to produce the content generated by …/Ponies/poet/comps/index.mc.

1

There are 1 answers

0
ManicDee On

You could use mod_perl. Read the mod_perl quick start guide, then check out the Plack documentation. Note that the key file you want in the Poet environment is bin/app.psgi. Studying that file in association with the PSGI specification and the Plack documentation should help you understand what's going on (remembering that Plack is simply an implementation of PSGI).

To get you started quickly use the following httpd.conf file; noting the LoadModule line and the replacement of the contents of VirtualHost:

LoadModule log_config_module /opt/local/apache2/modules/mod_log_config.so
LoadModule perl_module       /opt/local/apache2/modules/mod_perl.so

Listen 5000
ServerRoot /Users/me/Documents/Ponies/poet
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
CustomLog logs/access.log combined
Errorlog logs/error.log
PidFile httpd.pid
LockFile accept.lock
User  me
Group staff

<VirtualHost *:5000>
ServerName foo.local
DocumentRoot /Users/me/Documents/Ponies/poet/
<Location />
    SetHandler perl-script
    PerlResponseHandler Plack::Handler::Apache2
    PerlSetVar psgi_app /Users/me/Documents/Ponies/poet/bin/app.psgi
</Location>
</VirtualHost>

This is, of course, a bare minimum config which will get you off plackup onto a "real" web server on the same port 5000 as the default Poet install and doesn't take into account little things like security, sharing a host with multiple applications, or any number of other details that the webmaster, system administrator or network security manager will want you to take into account.