HP Open Source Middleware Stacks Blueprint: LAMP Architecture on HP ProLiant BladeSystem Servers on RHEL

2. Create a sample test file named /var/www/html/Testphpmysql.php by adding the
following code to the file:
<?php
$dbhost = <MySQL Server Name>;
$dbuser = <MySQL DB User>;
$dbpass = <MySQL DB Password>;
mysql_connect($dbhost, $dbuser, $dbpass) or die
('Error connecting to mysql:'.mysql_error());
printf('MySQL Version:');
printf(mysql_get_server_info());
mysql_close();
?>
3. Launch a browser and navigate to the following website to verify PHP and MySQL are
working:
http://<YOUR_HOSTNAME>/Testphpmysql.php
The test page opens and the following message is displayed:
MySQL Version: 5.0.22
Integrating Apache HTTP Server with Perl and MySQL
Use the following procedure to configure PHP and MySQL:
1. Verify that the necessary Perl packages are installed by entering the following command:
# rpm q mod_perl perl perl-DBI perl-DBD-MySQL
If any of these packages are not installed, locate the RPM package on the Linux distribution
media and install them.
2. Create a following sample test file named /var/www/html/perl/Testperlmysql.pl
by adding the following:
#!/usr/bin/perl
use DBI;
use DBD::mysql
print "Content-type: text/html \n\n";
$platform = "mysql";
$database = "mysql";
$host = <MySQL Server Name>;
$port = <MySQL Server Port>;
$user = <MySQL DB User>;
$pw = <MySQL DB Password>;
$sql = "select version()";
$dsn = "dbi:mysql:$database:$host:$port";
$dbh = DBI->connect($dsn, $user, $pw) or die "Unable to connect: $DBI::errstr\n";
$sth = $dbh->prepare($sql);
$sth->execute;
@row = $sth->fetchrow_array;
print "MySQL Version: $row[0]";
$sth->finish();
$dbh->disconnect();
3. Edit the /etc/httpd/conf.d/perl.conf file by adding these lines:
Alias /perl /var/www/html/perl
<Directory /var/www/html/perl>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
</Directory>
Integrating LAMP Components 19