1 / 26

XAMPP

XAMPP. running PHP and Perl on the Apache server. First, few slides on using php with Apache. Show: how to make a simple php/html application. Where: to put them in the Apache directory structure What the XAMPP control panel looks like. The XAMPP Control panel running. Running a php.

alisa
Télécharger la présentation

XAMPP

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. XAMPP running PHP and Perl on the Apache server

  2. First, few slides on using php with Apache • Show: how to make a simple php/html application. • Where: to put them in the Apache directory structure • What the XAMPP control panel looks like

  3. The XAMPP Control panel running

  4. Running a php

  5. Put php here: xampp\htdocs

  6. Test1.php <html> <?php //put php stuff in here $myvar="message string"; echo $myvar; ?> other stuff may go here it will be delivered as normal html content <html>

  7. Variables • Php variables, even arrays, are designated with $ as in $myvar in the previous slide. • Type checking is not automatically performed but you can call a function to see if something is numeric

  8. Obtain info with a call to Phpinfo()

  9. You can access the function Phpinfo() <html> <?php phpinfo() ?> <html>

  10. examples • Lots of sample PHP files come with the XAMPP distribution.

  11. Perl & apache

  12. You must “turn on” cgi processing in apache • Useful link: http://www.ricocheting.com/server/cgi.html • Activating CGI • Using Notepad (or other text editor) open E:\Apache2\conf\httpd.conf (also should be start-menu shortcut called "Edit Apache HTTP httpd.conf File") and search for Options Indexes FollowSymLinks (about line 267) when you find it add ExecCGI to the end so it looks like Options Indexes FollowSymLinks ExecCGI • Enabling CGI in any directory [optional] • If you want to use CGI outside ScriptAliased directory (ScriptAlias is usually the Apache2/cgi-bin/), 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.You might also want to comment out: ScriptAlias /cgi-bin/ "E:/Apache2/cgi-bin/" so it becomes #ScriptAlias /cgi-bin/ "E:/Apache2/cgi-bin/"

  13. Another useful page • http://www.thesitewizard.com/archive/addcgitoapache.shtml • There are just a few changes to make: • To find perl scripts in cgi-bin directory (fix path, too): • ScriptAlias /cgi-bin/ "C:/Program Files/Apache Group/Apache/cgi-bin/" • To allow both pl and cgi suffix: • AddHandler cgi-script .cgi .pl • <Directory />  Options FollowSymLinks  AllowOverride None</Directory> • Change options to: • Options FollowSymLinks +ExecCGI

  14. On my apache version: about line 187 <Directory /> Options FollowSymLinks ExecCGI Includes AllowOverride None Order deny,allow Deny from all </Directory>

  15. Turn on cgi • Enabling SSI [optional] • Find the line from Step 1: Activating CGI and add Includes to the end so it becomes Options Indexes FollowSymLinks ExecCGI IncludesFind and uncomment the following lines #AddType text/html .shtml and #AddOutputFilter INCLUDES .shtml (Search for them, then remove the #)Some notes If you don't know what SSI (Server Side Include) is, I suggest looking for more info about it. It is a huge time saver for updating pages (you can update one "menu file" and have hundreds of pages reflect the updated changes). However, it adds additional strain on a server and can potentially make a server slightly less secure, so if you are not using, do not enable it.Since I use SSI for everything, I changed the settings so *.html files can also run SSI (by default it's only .shtml). So I have AddOutputFilter INCLUDES .shtml .htmlAddOutputFilter is completely different than the AddHandler server-parsed way Apache 1.3.x handled it. • Finding your location to perl • If you do not know where your perl.exe installed to, go to Start -> Search and type in a search for perl.exe This location is the path to perl you put on the top of all your cgi scripts. If you listened to my advice in the "Install" step, the path should be close to: E:/usr/bin/perl

  16. Turning on cgi • Some notes For the perl path E:/usr/bin/perl.exe all of these are/were valid. I prefer the last one, but to each their own.#!E:/usr/bin/perl.exe#!E:/usr/bin/perl#!/usr/bin/perl.exe#!/usr/bin/perl • Testing CGIIf you did not disable ScriptAlias /cgi-bin/ then create a file in E:/Apache2/cgi-bin/ called hello.cgi and put these three lines in it (if you did disable it, put the CGI file anywhere in your document_root):#!/usr/bin/perl print "Content-type:text/html\n\n"; print "hello world"; • Restart Apache if it is already running. Now go to http://127.0.0.1/cgi-bin/hello.cgi or localhost and run this script. (scripts in Apache2/cgi-bin/ are read as http://127.0.0.1/cgi-bin/ by default, although if did step (2) you should be able to run CGI scripts from anywhere). • If you get a hello world in your browser, CGI is running. If you get a 500 error, go to the last entry in E:/Apache2/logs/error.log (or the Review Error Log in the start menu) to see exactly what caused this error.

  17. Set the port number: 80 or 8080(around line 53 in my httpd.conf) # Listen: Allows you to bind Apache to specific IP addresses and/or # ports, instead of the default. See also the <VirtualHost> # directive. # # Change this to Listen on specific IP addresses as shown below to # prevent Apache from glomming onto all bound IP addresses (0.0.0.0) # #Listen 12.34.56.78:80 Listen 80

  18. Addhandler (line 418) • add .pl to this line: AddHandler cgi-script .cgi .pl This allows the scripts in the cgi-bin directory to have either a cgi or pl extension.

  19. Hello world script • note shebang 1st line points to perl on system… This seems not to be needed to run perl from apache #!c:\perl\bin\perl.exe print "Content-type:text/html\n\n"; print "hello world";

  20. Drop perlscripts into cgi-bin

  21. Using variables: Vars.pl #!c:\perl\bin\perl.exe print "Content-type: text/html \n\n"; # the header $mystring = "Hello, World"; $myescapechar = "Welcome to Joe\'s"; $myinteger = "5"; $myinteger2 = "-5"; $mypi = "3.14159"; print $mystring; print "<br />"; print $myescapechar; print "<br />"; print $myinteger; print "<br />"; print $myinteger2; print "<br />"; print $mypi;

  22. Vars.pl

  23. Additional perl module installs may be needed • These are performed by running ppm from the perl root directory, for example, if perl is in c:\: • C:\PERL>ppm install CGI • Some text examples use a CGI package, and to run a database connection DBI or DBD is needed.

  24. Ppm install CGI • C:\PERL>ppm install CGI • ==================== • Install 'CGI' version 2.91 in ActivePerl 5.8.7.815. • ==================== • Installing C:\Perl\html\site\lib\CGI.html • Installing C:\Perl\html\site\lib\CGI\Apache.html • Installing C:\Perl\html\site\lib\CGI\Carp.html • Installing C:\Perl\html\site\lib\CGI\Cookie.html • Installing C:\Perl\html\site\lib\CGI\Fast.html • Installing C:\Perl\html\site\lib\CGI\Pretty.html • Installing C:\Perl\html\site\lib\CGI\Push.html • Installing C:\Perl\html\site\lib\CGI\Switch.html • Installing C:\Perl\html\site\lib\CGI\Util.html • Installing C:\Perl\site\lib\CGI.pm • Installing C:\Perl\site\lib\CGI\Apache.pm • Installing C:\Perl\site\lib\CGI\Carp.pm • Installing C:\Perl\site\lib\CGI\Cookie.pm • Installing C:\Perl\site\lib\CGI\Fast.pm • Installing C:\Perl\site\lib\CGI\Pretty.pm • Installing C:\Perl\site\lib\CGI\Push.pm • Installing C:\Perl\site\lib\CGI\Switch.pm • Installing C:\Perl\site\lib\CGI\Util.pm • Successfully installed CGI version 2.91 in ActivePerl 5.8.7.815.

  25. C:\perl>ppm install DBI

  26. Installing dbd:mysql (not in perl5.8) c;:\>ppm install http://theoryx5.uwinnipeg.ca/ppms/DBD-mysql.ppd

More Related