If you see the above message, CGI is running. You should see a page that displays a level two heading with the following text: Now go to (scripts in Apache2\cgi-bin\ are read as by default). Print $q->header( "text/html" ),$q->start_html( "hello from perl cgi!" ) # print header and start the markup output # ^^^ this must be the first line of the script! ^^^ Save the following test script in your DocumentRoot directory (if you have uncomment ScriptAlias, you can put it anywhere inside your DocumentRoot directory, or if you have set ScriptAlias to some particular directory, put the cgi in that directory only, i.e Apache2/cgi-bin) as or test.cgi (depending on your configuration of the AddHandler line) and modify the first line as required to point to your ActivePerl interpreter: #!c:/perl/bin/perl.exe ![]() Testing Your Web Server CGI Configuration If you follow default installation procedure, the path should be C:\perl\bin\perl.exe.įor the path to perl.exe path, all of these format are valid: This location is the path to the perl executable that has to be put on the top of all cgi scripts. If you don’t know where is perl.exe installed to, go to Start -> Search and search for perl.exe. Replace backslashes of directory/folder path with forward slashes in Apache nf even though you’re on Windows machine. If you want to use CGI outside ScriptAliased directory (ScriptAlias is usually the Apache2/cgi-bin/), comment out the following line: ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache2/cgi-bin/" Test the configuration as described in Testing Your Web Server CGI Configuration at the end of this article. Save the nf configuration file, restart the Apache server. cgi if you prefer that perl extention is also treated as cgi files) For example: #AddHandler cgi-script. Search for the following line and remove the hash mark character (#) to uncomment this line. In the main directory section, search for Options Indexes FollowSymLinks (at about line 267), and add ExecCGI to the end so it looks like: Options Indexes FollowSymLinks ExecCGI Alternatively, open the nf with any text editor. Open the nf file for editing by selecting Start > Programs > Apache HTTP Server > Configure Apache Server > Edit the Apache nf Configuration File. Make sure that the following options is checked (selected):Īdd Perl to the PATH environment variable To change the installation path, click on browse button when you’re on the installation screen that prompts you to select which features you want to install. This allows codes written on Windows machine been moved to, without changes, to Linux machine, and have it run there, and vice versa. C:\perl), install it in C:\usr instead, so that the Perl executable is located at /usr/bin/perl. So, it’s best when install Perl on an Windows machine, instead of installing it in the default location (i.e. If you will be using Perl CGI programs and want to maintain some level of portability between both Linux machines and Windows machines, you may want to install Perl at the same location on your Windows machine as it is on most Linux machines.įor example, on Linux machine, Perl is located at /usr/bin/perl and so every Perl program that I write begins with #!/usr/bin/perl. ![]() Start the installation by double clicking the setup file. ![]() Then download the latest version of Windows MSI package. Just leave it blank and press ‘Next’ to start the download. There is no need to input any contact info. ![]() Click on Free Download to start the download process.
0 Comments
Leave a Reply. |