Home : Einführung : Embperl::Object
Google Web perl.apache.org

Embperl 2 Advanced
Weitere Infos
Hinzufügen Infos

    Stable 2.4.0
    Beta 2.5.0_3
Unterstützen Sie Embperl! Mehr...
Getting Started
[ << Prev: Introduction ] [ Content ] [ Next: Hello World >> ]

We'll assume here that you've successfully installed the latest Apache, mod_perl and Embperl on your system. That should all be relatively painless - problems normally occur when mixing older versions of one tool with later versions of another. If you can, try to download the latest versions of everything.

Having done all that, you might want to get going with configuring a website. The first thing you need to do is set up the Apache config file, usually called httpd.conf.

Configuring httpd.conftop

The following is an example configuration for a single virtual host to use EmbperlObject. There are, as usual, different ways to do this; but if you are starting from scratch then it may be useful as a template. It works with the later versions of Apache (1.3.6 and up). Obviously, substitute your own IP address and domain name.


<VirtualHost> ServerName www.mydomain.com ServerAdmin webmaster@mydomain.com DocumentRoot /www/mydomain/com/htdocs DirectoryIndex index.html ErrorLog /www/mydomain/com/logs/error_log TransferLog /www/mydomain/com/logs/access_log PerlSetEnv EMBPERL_ESCMODE 0 PerlSetEnv EMBPERL_OPTIONS 16 PerlSetEnv EMBPERL_MAILHOST mail.mydomain.com PerlSetEnv EMBPERL_OBJECT_BASE base.epl PerlSetEnv EMBPERL_OBJECT_FALLBACK notfound.html PerlSetEnv EMBPERL_DEBUG 0 </VirtualHost>

# Set EmbPerl handler for main directory <Directory "/www/mydomain/com/htdocs/"> <FilesMatch ".*\.html$"> SetHandler perl-script PerlHandler HTML::EmbperlObject Options ExecCGI </FilesMatch> <FilesMatch ".*\.epl$"> Order allow,deny Deny From all </FilesMatch> </Directory>

Note that you could change the .html file extension in the FilesMatch directive; this is a personal preference issue. Personally, I use .html for the main document files simply because I can edit files using my favorite editor (emacs) and it will automatically load html mode. Plus, this may be a minor thing - but using .html rather than a special extension such as .epl adds a small amount of security to your site since it provides no clue that the website is using Embperl. If you're careful about the handling of error messages, then there never be any indication of this. These days, the less the script kiddies can deduce about you, the better...

Also, note that we have added a second FilesMatch directive, which denies direct access to files with .epl extensions (again, you could change this extension to another if you like, for example .obj). This can be helpful for cases where you have Embperl files which contain fragments of code or HTML; you want those files to be in the Apache document tree, but you don't want people to be able to request them directly - these files should only included directly into other documents from within Embperl, using Execute(). This is really a security issue. In the examples that follow, we name files which are not intended to be requested directly with the .epl extension. Files which are intended to be directly requested are named with the standard .html extension. This can also be helpful when scanning a directory, to see which are the main document files and which are the modules. Finally, note that using the Apache FilesMatch directive to restrict access does not prevent us from accessing these files (via Execute) in Embperl.

So how does all this translate into a real website? Let's have a look at the classic first example, Hello World.

[ << Prev: Introduction ] [ Content ] [ Next: Hello World >> ]

© 1997-2012 Gerald Richter / ecos gmbh