{"id":263,"date":"2020-07-11T23:12:44","date_gmt":"2020-07-11T23:12:44","guid":{"rendered":"https:\/\/molecularsciences.org\/content\/?p=263"},"modified":"2024-02-08T08:18:41","modified_gmt":"2024-02-08T13:18:41","slug":"installing-perl-cgi-on-microsoft-windows","status":"publish","type":"post","link":"https:\/\/molecularsciences.org\/content\/installing-perl-cgi-on-microsoft-windows\/","title":{"rendered":"Installing Perl\/CGI on Microsoft Windows"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">My Configurations<\/h2>\n\n\n\n<p>My system is configured as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Web root = c:\/www \nApache version = 2.4 \nApache installation directory = c:\/Apache2.4\/<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Download ActivePerl<\/h2>\n\n\n\n<p>Download windows MSI version from <a href=\"http:\/\/www.activestate.com\/store\/activeperl\/download\" target=\"_blank\" rel=\"noreferrer noopener\">http:\/\/www.activestate.com\/store\/activeperl\/download<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Install ActivePerl<\/h2>\n\n\n\n<p>Double click on the downloaded file to install it. By default it installs at c:\/Perl.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Test Installation<\/h2>\n\n\n\n<p>To test whether the installation was successfull, we need to create and run a hello world file.<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-code\"><code>c\/Perl\/bin\/perl\nprint \"Hello, World...\\n\";<\/code><\/pre>\n\n\n\n<p><\/p>\n<\/div><\/div>\n\n\n\n<p>Save the file as\u00a0<strong>c:\/www\/hello.pl<\/strong><\/p>\n\n\n\n<p>Type <strong>cmd<\/strong> in window search at the bottom left and click on <strong>Command Prompt<\/strong>. Then type the following command in the window.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>perl hello.pl<\/code><\/pre>\n\n\n\n<p>If you see&nbsp;<strong>Hello, World&#8230;<\/strong>, Perl installed correctly, otherwise reinstall ActiveState Perl.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Activate CGI<\/h2>\n\n\n\n<p>Open&nbsp;<strong>httpd.conf<\/strong>&nbsp;change<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Options Indexes FollowSymLinks<\/code><\/pre>\n\n\n\n<p>to<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Options Indexes FollowSymLinks ExecCGI<\/code><\/pre>\n\n\n\n<p>ExecCGI tells Apache to execute CGI. Next, change<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># AddHandler cgi-script .cgi<\/code><\/pre>\n\n\n\n<p>to<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>AddHandler cgi-script .cgi .pl<\/code><\/pre>\n\n\n\n<p>Now .cgi and .pl files could be executed as CGI.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Test CGI<\/h2>\n\n\n\n<p>Type the following code.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/Perl\/bin\/perl\nprint \"Content-type:text\/html\\n\\n\"; \nprint \"hello world\";<\/code><\/pre>\n\n\n\n<p>Save it as\u00a0<strong>c:\/Apache2.4\/cgi-bin\/hello.cgi<\/strong>. View http:\/\/localhost\/cgi-bin\/hello.cgi in your browser. If you see\u00a0<strong>hello world<\/strong>, CGI is working correctly.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Running CGI from another address<\/h2>\n\n\n\n<p>Very often you would not want to run CGI from an Apache directory. To change the cgi-bin, create the folder<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>c:\/www\/cgi-bin\/<\/code><\/pre>\n\n\n\n<p>Then edit your&nbsp;<strong>httpd.conf<\/strong>&nbsp;file. The ScriptAlias line should look as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ScriptAlias \/cgi-bin\/ C:\/www\/cgi-bin\/<\/code><\/pre>\n\n\n\n<p>and change<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Directory \"C:\/Apache2.4\/cgi-bin\"><\/code><\/pre>\n\n\n\n<p>to<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Directory \"C:\/www\/cgi-bin\"><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Errors<\/h2>\n\n\n\n<p>Perl errors are logged in the Apache error log. To view it, go to Start > Apache HTTP Server 2.4 > Review Server Log Files > Review Error Log or C:\/Apache2_4\/logs\/error.log<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My Configurations My system is configured as follows: Download ActivePerl Download windows MSI version from http:\/\/www.activestate.com\/store\/activeperl\/download Install ActivePerl Double click on the downloaded file to install it. By default it installs at c:\/Perl. Test Installation To test whether the installation was successfull, we need to create and run a hello world file. Save the file [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[512],"tags":[],"class_list":["post-263","post","type-post","status-publish","format-standard","hentry","category-misc"],"_links":{"self":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/comments?post=263"}],"version-history":[{"count":3,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/263\/revisions"}],"predecessor-version":[{"id":266,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/posts\/263\/revisions\/266"}],"wp:attachment":[{"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/media?parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/categories?post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/molecularsciences.org\/content\/wp-json\/wp\/v2\/tags?post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}