LINUX How to using perl script

1 Enable CGI executing and use perl script.
[root@www ~]#yum -y install perl perl-CGI 
2 Configure httpd.
[root@www ~]#vi /etc/httpd/conf/httpd.conf
# line 331: change (enable CGI and disable Indexes)
 Options FollowSymLinks ExecCGI
# line 402: add file name that it can access only with directory's name
DirectoryIndex index.html index.cgi
# line 796: uncomment and add file-type that apache looks them CGI
AddHandler cgi-script .cgi .pl
[root@www ~]#/etc/rc.d/init.d/httpd restart
Stopping httpd:[ OK ]
Starting httpd:[ OK ]
3 Create a CGI test page and access to it with web browser. It's OK if following page is shown.
[root@www ~]#vi /var/www/html/index.cgi
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<html>\n<body>\n";
print "<div style=\"width: 100%; font-size: 40px; font-weight: bold; text-align: center;\">\n";
print "CGI Test Page";
print "\n</div>\n";
print "</body>\n</html>\n";

[root@www ~]#chmod 705 /var/www/html/index.cgi 
 
Open web browser with address http://my-server.com/index.cgi

Comments

Popular posts from this blog

Java : Variables Declaring

SQL Self JOIN