Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Configuring Apache Server and Perl for CGI T.A. Maisa Khudair Dr. Qusai Abu Ein."— 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: Install Apache Server from following web site: http://httpd.apache.org/download.cgi http://httpd.apache.org/download.cgihttp://httpd.apache.org/download.cgi Choose the Win32 Binary (MSI Installer): apache_2.2.4-win32-x86-no_ssl.msi Choose the Win32 Binary (MSI Installer): apache_2.2.4-win32-x86-no_ssl.msi apache_2.2.4-win32-x86-no_ssl.msi To start using CGI, you have to download ActivePerl from following web site: 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 Get the Windows (x86) MSI version To activate CGI in Perl, use your Notepad Editor To activate CGI in Perl, use your Notepad Editor open E:\Apache2_2\conf\httpd.conf open E:\Apache2_2\conf\httpd.conf (note: Path in PINK is the path you had installed your ActivePerl to in your computer) (note: Path in PINK is the path you had installed your ActivePerl to in your computer) search for Options Indexes FollowSymLinks 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 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: Always keep writing this line at the beginning of your CGI file: #!E:/Perl/bin/perl.exe #!E:/Perl/bin/perl.exe To start using Apache Server, go to Start Menu, search for Apache Http Server, then To start using Apache Server, go to Start Menu, search for Apache Http Server, then Control Apache Server > Start 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: To test your Apache Server working, go to your browser web page, type in the address bar the following: http://localhost http://localhosthttp://localhost If you got a message telling you: If you got a message telling you: It works! Your server is working well. 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 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: Your files should be saved like this: fileName.cgi fileName.cgi To run your CGI, type: To run your CGI, type: http://localhost/cgi-bin/fileName.cgi. http://localhost/cgi-bin/fileName.cgi.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 = $ENV{$var}; $val =~ s|\n|\\n|g; $val =~ s|\n|\\n|g; $val =~ s|"|\\"|g; $val =~ s|"|\\"|g; print "${var}=\"${val}\"\n"; 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 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??


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

Similar presentations


Ads by Google