HP Open Source Middleware Stacks Blueprints: LAMP Architecture on HP ProLiant BladeSystem Servers on SLES

Alias /perl /srv/www/htdocs/perlmysql
<Directory /srv/www/htdocs/perlmysql>
SetHandler perl-script
PerlResponseHandler ModPerl::Registry
PerlOptions +ParseHeaders
Options +ExecCGI
</Directory>
5. Edit the /etc/sysconfig/apache2 file by adding perl to the line APACHE_MODULES.
After completing this edit, the line should look like the following:
APACHE_MODULES=”… perl
6. Restart the Apache server by entering the following command:
# /etc/init.d/apache2 restart
7. Verify that Perl and MySQL are working by navigating to the following website:
http://<YOUR_HOSTNAME>/Testperlmysql.pl
The test page opens and the following message is displayed:
MySQL Version: 5.0.26
Integrating Apache HTTP Server with Python and MySQL
The mod_python module embeds the Python environment into the Apache Web server.
Embedding this environment avoids the run-time overhead of starting the Python environment
externally. Use the following procedure to configure Python and MySQL:
1. Verify that the necessary Python packages are installed by entering the following command:
# rpm -q python apache2-mod_python python-mysql
If any of these packages are not installed, locate the RPM package on the Linux distribution
media and then install.
2. Edit the /etc/sysconfig/apache2 file by adding python to the line APACHE_MODULES.
After completing this edit, the line should look like the following:
APACHE_MODULES=”… python
3. Create the following test file: /srv/www/htdocs/test.py
Add the following lines to the preceding file
from mod_python import apache
import MySQLdb
def handler(req):
conn = MySQLdb.connect(host="<MySQL Server Name>",user="<MySQL DB User>", passwd="<MySQL DB
Password>", db="test")
cursor = conn.cursor()
cursor.execute("SELECT VERSION()")
row = cursor.fetchone()
req.write("MySQL version:" + row[0])
cursor.close()
conn.close()
return apache.OK
4. Edit the following file: /etc/apache2/conf.d/mod_python.conf
Add the following lines to the preceding file:
<Directory /srv/www/htdocs>
AddHandler mod_python .py
PythonHandler test
PythonDebug On
</Directory>
5. Restart Apache by entering the following command:
# /etc/init.d/apache2 restart
Integrating LAMP Components 21