Webmiscreants

Sunday, September 05, 2010 10:26
About
Contact
Dvds_owned
Howto_P1006
Howto_freebsd_embperl
Main
Project

How to install embperl and mod_perl Apache 1.3.4 on FreeBSD 8.0

Go to /usr/ports/www/mod_perl

#make install

(Hint: do not "make clean" until after you build and successfully install embperl)

This will install mod_perl, some required Perl modules, and Apache 1.3.4.

Once mod_perl and Apache have compiled and installed successfully you should stop and configure /usr/local/etc/apache/httpd.conf according to your specific requirements. Once that has been done you should try starting apache:

/usr/local/sbin/apachectl start

and watch closely for errors. If all goes well you should now be able to see http server running.

#netstat -al

Proto Recv-Q Send-Q Local Address Foreign Address (state)
tcp4 00 *.http *.* LISTEN

Now build and install embperl. Go to /usr/ports/www/p5-HTML-Embperl

#make install

If there were no errors and all went as it should you should now be able to test your embperl/mod_perl apache server.

Testing embperl and mod_perl.

Add the following to your httpd.conf. Change IP address, domain name, document root, and log file locations as needed.

NameVirtualHost 10.100.0.2:80

<VirtualHost 10.100.0.2:80>
ServerName www.somedomain123.com
ServerAdmin webmaster@somedomain123.com
DocumentRoot /www/html
DirectoryIndex index.html
ErrorLog /var/log/somedomain123.com.error
TransferLog /var/log/somedomain123.com.access
PerlSetEnv EMBPERL_ESCMODE 0
PerlSetEnv EMBPERL_OPTIONS 16
PerlSetEnv EMBPERL_MAILHOST mail.somedomain123.com
PerlSetEnv EMBPERL_OBJECT_BASE base.epl
PerlSetEnv EMBPERL_OBJECT_FALLBACK notfound.html
PerlSetEnv EMBPERL_DEBUG 0
</VirtualHost>

<Directory "/www/html/">
<FilesMatch ".*\.html$">
SetHandler perl-script
PerlHandler HTML::EmbperlObject
Options ExecCGI
</FilesMatch>
<FilesMatch ".*\.epl$">
Order allow,deny
Deny From all
</FilesMatch>
</Directory>

Whenever you modify httpd.conf, you must restart apache for your changes to take effect.

#/usr/local/sbin/apachectl restart

If you try to access your new virtual server at 10.100.0.2:80 you will probably now get an error saying index.html is not found,even if you do have an index.html in the proper document root location. This is because you've configured this virtual server directory in your httpd.conf to interpret embperl and require a "base.epl" file.

Install an example "base.epl" and a simple html file to test embperl with. Just create a file named base.epl and paste this code.

<html>
<head><title> my page title </title>
</head> <body>
my embperl test website
<p>
[- Execute ('*') -]
</body> </html>

And them create another file named "test.html" and paste this code

This is a test of embperl and mod_perl Apache.
<br> It works!

Put these two files in your document root, /www/html or whatever. You should now be able to access http://10.100.0.2/test.html (along with any other .html files in document root) with your web browser. I personally installed and tested this using FreeBSD 8.0 current but I imagine it should work as written with FreeBSD 7.0. Enjoy!


You may wish to check out the excellent articles and embperl documentation at these web sites.

http://perl.apache.org
http://aspn.activestate.com


Last Modified 06/13/08 01:14
Copyright © 2005,2006,2007,2008 Baron Woodward