Apache2-SSL-PHP5-Howto (+ Zend Optimizer And IonCube Loader)
(+ Zend Optimizer And IonCube Loader)
This document describes how to install an Apache web server (2.0.x) with SSL and PHP5 (with Zend Optimizer and ionCube Loader) 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 (2.0.x), and PHP5. We will install the software from the /tmp directory.
Then go to http://www.php.net and download the latest PHP version (5.0.4 at the time of this writing). Download it to your /tmp directory.
2 Install Openssl
tar xvfz openssl-0.9.7g.tar.gz
3 Configure And Install Apache2
Please note: You can change the configure command to suit to your needs. Type
to get a list of all configuration options available!)
This will install Apache2 under /usr/local/apache. The web root directory is /usr/local/apache/htdocs, the log directory is /usr/local/apache/logs.
If we want to start up our Apache2 with SSL support we have to generate the file /etc/httpd/ssl.crt/server.crt because otherwise we will get an error message when we start Apache2.
(Please note: It is safe to accept the default values for all the questions you see when you create /etc/httpd/ssl.crt/server.crt 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 PHP5
(Please note: You can change the configure command to suit to your needs. Type
to get a list of all configuration options available! In PHP5, you must specify the --with-mysql[=DIR] option, otherwise PHP5 will not have MySQL support! And yes, MySQL has to be installed before you run the ./configure statement. If you install MySQL From a package (.rpm or .deb), be sure that you also install the corresponding mysql-devel package! Otherwise the ./configure statement will abort with an error message.
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 entries in /etc/httpd/httpd.conf (in the section where document types are handled; there should be entries like AddHandler or AddType):
AddHandler cgi-script .cgi
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 Apache2 uses the ports 80 (http) and 443 (https).
Now go to /usr/local/apache/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:
7 Install Zend Optimizer And IonCube Loader
If you want to run PHP files that have been encoded with the Zend Encoder you need the Zend Optimizer. If you want to run PHP files that have been encoded with the ionCube PHP Encoder you need the ionCube Loader. I will show how to install both.
Get the latest version of the ionCube Loader from http://downloads.ioncube.com/loader_downloads.
Now edit /etc/php.ini and add the line zend_extension=/usr/local/lib/ioncube/ioncube_loader_lin_5.0.so right at the beginning:
Get the latest version of the Zend Optimizer from http://www.zend.com/store/free_download.php and save it in your /tmp/ directory.
Edit /etc/php.ini and add two more lines to the [PHP] section of the file at the beginning so that it looks like this:
Now restart Apache2:
If you reload your info.php that you created in step 6 you should now see that the ionCobe Loader and the Zend Optimizer are mentioned on the page: