Packing site to standalone executable file

There is an utility tools/packsite-par.pl included for creating executables from web server and the site itself. That utility uses PAR toolkit as backend. You have to install PAR and all its dependancies to be able to use that utility; there are caveats in installing PAR and choosing version of Perl to use with it listed below.

Stunnix Advanced Web Server package includes a sample site and scripts to make multiplatform CDROM with site on it (with autorun support for platforms where it's possible to have it) and also a sample for packing same site and Stunnix Advanced Web Server into standalone executable - see more details in Stunnix Advanced Web Server package overview.

Notes on installing PAR and choosing version of Perl to use

Here are the notes on packing perl interprerter and site itself into single .exe file using PAR toolkit as backend via use of packsite-par.pl utility.

Notes on packing to .exe for unix:

  • Don't use perl built with shared libperl.so support - at least with PAR-0.80 they won't run without perl interpreter.
  • There is severe problem of loosing entire set of environment variables when .exe is started without any arguments; this problem takes place with Perl-5.6.1 on Linux and PAR-0.80. This problem is absent in modern Perl - it's absent with at least Perl-5.8.0 and above.

Notes on packing to .exe for Windows:

  • It appears that PAR installed from bribes.org using ppm3 (the recommended method of installing PAR on windows in the PAR FAQ) is corrupted, and .exes produced by it will sometimes cease to run. So after installing PAR using ppm3 you should download .par archive corresponding to your version of perl from CPAN (as explained in PAR FAQ), extract script/*.exe files from it and put to the /bin subdirectory of your Perl installation.
  • It appears that building .exe's on Windows 98 produces .exe that lack some modules due to case sensitivity of file names (e.g. Getopt::Long.pm is not included since the module is stored in 'getopt/Long.pm'). Using NT-based OS for building .exes solves the problem.

Note on protecting your code from analysis

Even if your site is packed into executable, your entire site and Stunnix Advanced Web Server are extracted to the temporary directory once executable is run, and are available in the form they were packed in. So packing sites into executables shouldn't be meant as a way to protect code from analysis and illegal reuse. If intellectual property of your Perl code that implements logic of the site needs to be protected, the most recommended way is to use a special tool for making Perl source unreadable and much more difficult to analyze - Stunnix Perl-Obfus. In fact, Stunnix Advanced Web Server and Project Manager code are already protected with Stunnix Perl-Obfus.