This article assumes that you are running on Debian Lenny (or above) and uses aptitude/apt-get for fetching and installing packages.
Install these packages :
apt-get install nginx libfcgi-perl wget
Now we replace Nginx’s package maintainer’s vhosts file with our own.
mv /etc/nginx/sites-available/default /etc/nginx/sites-available/default.old
vi /etc/nginx/sites-available/default
Put these as the file contents :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Now let us create the directory where the site will reside and assign proper ownership to it.
mkdir /var/www/example.com
chown -R www-data:www-data /var/www/example.com
Next, we should download and configure a FastCGI wrapper script (credit: Denis S. Filimonov), a Debian init script to start/stop the FastCGI process, give them the necessary permissions to be executed and set the init script to start up the FastCGI daemon automatically.
wget http://nginxlibrary.com/downloads/perl-fcgi/fastcgi-wrapper -O /usr/bin/fastcgi-wrapper.pl
wget http://nginxlibrary.com/downloads/perl-fcgi/perl-fcgi -O /etc/init.d/perl-fcgi
chmod +x /usr/bin/fastcgi-wrapper.pl
chmod +x /etc/init.d/perl-fcgi
update-rc.d perl-fcgi defaults
insserv perl-fcgi
Now that everything is done, let us start Nginx and test out a sample Perl script.
/etc/init.d/nginx start
/etc/init.d/perl-fcgi start
vi /var/www/example.com/index.pl
Put the following in the file :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
Let us make the script executable by issuing the following command :
chmod a+x /var/www/example.com/index.pl
Now, go to example.com and you’ll see a list of Perl environment variables if everything was done correctly.