This document describes how to install an Apache web server (1.3.x) with mod_ssl and PHP enabled.
This howto is meant as a practical guide; it does not cover the theoretical backgrounds. They are treated in a lot of other documents in the web.
This document comes without warranty of any kind!
1 Get the Sources
We need the following software: openssl, apache (1.3.x), mod_ssl and PHP. We will install the software from the /tmp directory.
Then go to http://www.php.net and download the latest PHP version (4.3.4 at the time of this writing). Download it to your /tmp directory
2 Install Openssl
tar xvfz openssl-0.9.7c.tar.gz
3 Configure and Install mod_ssl and apache
(The option --htdocsdir=/usr/local/httpd/htdocs specifies the the default location for documents that will be delivered by this web server is in /usr/local/httpd/htdocs.
Please note: You can change the configure command to suit to your needs. Type
to get a list of all configuration options available!)
<- Signature Algorithm:
(Please note: It is safe to accept the default values for all the questions above because in either case you will receive a warning in your browser if you try to access an SSL site on your server:
If you do not want to get this warning you will have to get a "real" SSL certificate (but this is not for free!). Have a look at the following sites:
4 Install PHP
(Please note: You can change the configure command to suit to your needs. Type
to get a list of all configuration options available! If you do not specify the --with-mysql[=DIR] option, the bundled MySQL library will be used. This works in most cases.
If you use --with-gd, and you get an error message because of a missing libpng library, install it and then re-run the configure command. On Debian,
apt-get install libpng-dev libpng2 libpng2-dev libpng3
This will install a PHP binary (normally under /usr/local/bin/php) that can be run from the command line as well as an Apache module.
Now we have to create /etc/php.ini. The easiest way is to take the one that comes with the PHP sources:
If you like you can now modify /etc/php.ini to suit to your needs.
5 Configure Apache
Now we have to add the following entry in /etc/httpd/httpd.conf (in the section where document types are handled; there should be entries like AddHandler or AddType):
AddType application/x-httpd-php .php .php4 .php3
In order to start your Apache at boot time do the following:
ln -s /etc/init.d/httpd
Then start your Apache:
6 Test your Configuration
should show you that Apache uses the ports 80 (http) and 443 (https).
Now go to /usr/local/httpd/htdocs and create a file called info.php with the following contents:
Try to access it with your browser (e.g. using the IP address of the server) via http (e.g. http://192.168.0.1/info.php) and https (https://192.168.0.1/info.php). The output should look similar to this screenshot: