Here I'm not going to discuss about installing Apache Server, really I'm going to give a sequence of steps that will help you to Install and configure Perl with your Apace Server.
1. Install
Install perl (on linux yum install perl)
2. Activating CGI
Using Notepad (or other text editor) open httpd.conf (on linux /etc/httpd/conf)(should be start-menu shortcut "Apache HTTP Server 2.2 > Configure Apache Server > Edit the Apache httpd.conf Configuration File") and search for Options 'Indexes FollowSymLinks' (about line 190) when you find it add ExecCGI to the end so it looks like Options 'Indexes FollowSymLinks ExecCGI'
3. [OPTIONAL] Enabling CGI in any directory
If you want to use CGI outside the C:/Apache2_2/cgi-bin/ ScriptAliased directory, you will need to uncomment the following line: #AddHandler cgi-script .cgi becomes AddHandler cgi-script .cgi (remove the #) I also added .pl behind .cgi so 'perl' extension is also treated as cgi files.
If you will be creating your own cgi-bin, you will want to comment out: ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/" so it becomes #ScriptAlias /cgi-bin/ "C:/Program Files/Apache Software Foundation/Apache2.2/cgi-bin/
4.Testing CGI
If you if you uncommented (removed the # symbol) the line AddHandler cgi-script .cgi in step #4, then create a file in your document_root called hello.cgi and put these three lines in it (if you did not comment/disable it, put the CGI file in C:/Apache2_2/cgi-bin/):
#!/usr/bin/perl
print "Content-type:text/html\n\n";
print "hello world";
5. Restart Apache if it is already running. Now go to http://localhost/cgi-bin/hello.cgi (or wherever you put the file) and run the script.
6. If you get a hello world in your browser, CGI is running. If you get a 500 error, go to the last entry in Apache error log (Apache HTTP Server 2.2 > Review Server Log Files > Review Error Log shortcut in the Start Menu) to see exactly what caused this error.
chmod 775 /var/www/cgi-bin
chown [USER] /var/www/cgi-bin
can you add the url of where others can download these softwares and other tutorials, and check your header spellings
ReplyDelete