1 / 11

Configuring Apache Server and Perl for CGI

Configuring Apache Server and Perl for CGI. T.A. Maisa Khudair Dr. Qusai Abu Ein. Setting up Apache for Windows. Install Apache Server from following web site: http://httpd.apache.org/download.cgi Choose the Win32 Binary (MSI Installer): apache_2.2.4-win32-x86-no_ssl.msi

cachet
Download Presentation

Configuring Apache Server and Perl for CGI

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Configuring Apache Server and Perl for CGI T.A. Maisa Khudair Dr. Qusai Abu Ein

  2. Setting up Apache for Windows • Install Apache Server from following web site: http://httpd.apache.org/download.cgi • Choose the Win32 Binary (MSI Installer):apache_2.2.4-win32-x86-no_ssl.msi • To start using CGI, you have to download ActivePerl from following web site: http://www.ricocheting.com/server/cgi.html

  3. Cont’d • Get the Windows (x86) MSI version • To activate CGI in Perl, use your Notepad Editor • open E:\Apache2_2\conf\httpd.conf (note: Path in PINKis the path you had installed your ActivePerl to in your computer) • search for Options Indexes FollowSymLinks

  4. Cont’d • when you find it add ExecCGI to the end so it looks like Options Indexes FollowSymLinks ExecCGI • Always keep writing this line at the beginning of your CGI file: #!E:/Perl/bin/perl.exe • To start using Apache Server, go to Start Menu, search for Apache Http Server, then Control Apache Server > Start

  5. Testing Apache Server • To test your Apache Server working, go to your browser web page, type in the address bar the following: http://localhost • If you got a message telling you: It works! Your server is working well.

  6. Writing CGI Scripts • In order to execute your CGI scripts, you have to put them in cgi-bin folder located in your Apache Directory in your PC • Your files should be saved like this: fileName.cgi • To run your CGI, type: http://localhost/cgi-bin/fileName.cgi.

  7. First CGI Example #!d:/Perl/bin/perl.exe print "Content-type: text/html\n\n"; print "Hello, World."; print "This is ME!!";

  8. Output Hello, World This is ME!!

  9. Cont’d :Environment variables example #!d:/Perl/bin/perl.exe ## ## printenv -- demo CGI program which just prints its environment ## print "Content-type: text/plain; charset=iso-8859-1\n\n"; foreach $var (sort(keys(%ENV))) { $val = $ENV{$var}; $val =~ s|\n|\\n|g; $val =~ s|"|\\"|g; print "${var}=\"${val}\"\n"; }

  10. Output DOCUMENT_ROOT = /usr/local/etc/apache/htdocs GATEWAY_INTERFACE = CGI/1.1 HTTP_ACCEPT = image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* HTTP_ACCEPT_CHARSET = iso-8859-1,*,utf-8 HTTP_ACCEPT_LANGUAGE = en HTTP_CONNECTION = Keep-Alive HTTP_HOST = 200.210.220.1:8080 HTTP_USER_AGENT = Mozilla/4.01 [en] (Win95; I) PATH = /usr/local/bin:/bin:/etc:/usr/bin QUERY_STRING = REMOTE_ADDR = 200.210.220.3 REMOTE_HOST = 200.210.220.3 REMOTE_PORT = 1029 REQUEST_METHOD = GET REQUEST_URI = /cgi-bin/utils/printenv.cgi SCRIPT_FILENAME = /usr/local/lib/apache/cgi-bin/utils/printenv.cgi SCRIPT_NAME = /cgi-bin/utils/printenv.cgi SERVER_ADMIN = adminguy@acme.com SERVER_NAME = coyote.acme.com SERVER_PORT = 8080 SERVER_PROTOCOL = HTTP/1.0 SERVER_SOFTWARE = Apache/1.2.5 TZ = :US/Eastern

  11. Any Questions??

More Related