Apache 2 & SSL - PHP4 - MySQL 4.1

From Wiki

Revision as of 14:49, 6 April 2009 by Admin (Talk | contribs)
(diff) ← Older revision | Current revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Installing Apache2, PHP4 and MySQL

Installing Apache, PHP and MySQL is very simple - if the following steps are adhered to.

1. Install MySQL:

apt-get install mysql-server mysql-client libmysqlclient12-dev
Not sure about requiring libmysqlclient12-dev, but will check out.

2. Install Apache2 (see http://www.debianhelp.co.uk/apache2.htm):

apt-get install apache2
apt-get install libapache2-mod-php4 php4-cli php4-common php4-cgi
apt-get install php4-mysql

You will also have to symlink mods_available/php.* to /mods_enabled/php.*

cd /etc/apache2/mods_enabled
ln -s /etc/apache2/mods_available/php4.conf php4.conf

Apache2 SSL & Virtual Hosting

Apache SSL should be installed already with Previous Packages
Look and see if ssl.conf and ssl.load are in /etc/apache2/mods-available
Symlink them into mods-enabled:

chdir /etc/apache2/mods-enabled
ln -s /etc/apache2/mods-available/ssl.conf ssl.conf

Edit /etc/apache2/ports.conf and Add in:

Listen 443

Restart Apache and that Should be it working. To use SSL - it must be added into the Vhosts in sites-enabled
Two main lines to add for SSL Engine:

SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem

To make the SSL Cert - Apache has a built-in tool :-)

chdir to /etc/apache2/ssl and run
apache2-ssl-certificate
apache2-ssl-certificate -days 365  //generate for 365 days

This tool is no longer in Debian Etch ;-( Here is how instead:

openssl req -x509 -days 365 -newkey rsa:1024 -keyout hostkey.pem -nodes -out hostcert.pem
cat hostkey.pem >> hostcert.pem
mv hostcert.pem apache.pem

Onto Configing Vhosts
1. Default Apache:

NameVirtualHost kartbuilding.net:80
<VirtualHost kartbuilding.net:80>
//insert code as Normal
</VirtualHost>
NameVirtualHost kartbuilding.net:443 <VirtualHost kartbuilding.net:443> //insert code as Normal; same as above SSLEngine On SSLCertificateFile /etc/apache2/ssl/apache.pem </VirtualHost>

2. Vhost #1 - www.kartbuilding.net

<VirtualHost www.kartbuilding.net:80>
//same as normal
</VirtualHost>
<VirtualHost www.kartbuilding.net:443> //as Normal same as above SSLEngine On SSLCertificateFile /etc/apache2/ssl/apache.pem </VirtualHost>

3. Vhost #2 - misc.kartbuilding.net

<VirtualHost misc.kartbuilding.net:80>
//same as normal
</VirtualHost>
<VirtualHost misc.kartbuilding.net:443>
//as Normal same as above
SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
</VirtualHost>

Main Config got from HAL!
Info on Apache + SSL: http://mattl.co.uk/apache2subversiondebianhowto.html

Apache2 SSL Cert Generation

To make the SSL Cert - Apache has a built-in tool :-)

chdir to /etc/apache2/ssl and run
apache2-ssl-certificate --force -days x

More Info about Vhosts and Multiple Domain Names at:
http://mathforum.org/~sasha/tech/apachevhosts.html

Server Side Includes (ssi)

a2enmod include
//thats it. No htaccess file should be needed.

Quick Test Example:

index.shtml:
Main Page
<!–-#include virtual="navbar.shtml" -->

navbar.shtml:
nav

Files called .shtml are by default parsed. A htaccess file can be used if you want the server to parse html files.

http://httpd.apache.org/docs/2.2/howto/ssi.html

Personal tools