Apache2 Web Server

Installation

# apt-get update
# apt-get install apache2 apache2-utils php5 php5-gd

SQLite3

# apt-get install sqlite3 php5-sqlite

Download phpLiteAdmin and move the php file into the same directory, where you keep the db file for the application.

MySQL

# apt-get install mysql-server mysql-client php5-mysql

Download phpMyAdmin and move the php into any directory within the application.

Enable SSL and Rewrite

# a2enmod ssl
# a2enmod rewrite
# /etc/init.d/apache2 force-reload # to enable.

Learn Apache mod_rewrite: 13 Real-world Examples Part I and Part II

Disable SSLv3, which is not safe. Modify /etc/apache2/mods-available/ssl.conf by changing the SSLProtocol directive:

SSLProtocol All -SSLv2 -SSLv3

This will allow all protocols except SSLv2 and SSLv3. You can test your configuration change with the command:

apachectl configtest

You will then need to restart your Apache instance. On Ubuntu and Debian:

sudo service apache2 restart

Check whether your SSL connection is safe

Setting up virtual hosts

Rewrite

You should rewrite all sub-directories in your document root which are accessed through a virtual host definition from being accessed through http://document-root/sub-dir. This is particularly important if you use a DynDNS name to access your server's document root. Without this, settings within the virtual host definition will not be applied. Modify your virtual host definition for the document root as follows. If you also serve a https site, you need to do the same in the <VirtualHost *:443> definition.

<VirtualHost *:80>

ServerAdmin bco@localhost

# DynDNS IP address cannot resolve domain forwarding
# hence all sites must be below one tree, forwards with directory
DocumentRoot /home/bco/www/

<Directory /home/bco/www/>
  Options Indexes FollowSymLinks MultiViews
  AllowOverride None
  Order allow,deny
  allow from all

  RewriteEngine on
  Redirect /sub-dir/ http://www.domain.tld/

</Directory>

Trouble shooting

PHP modules not found

First, find out which files are trying to load the extensions:

$ grep -Hrv ";" /etc/php5 | grep -i "extension="

Example output line:

/etc/php5/mods-available/gd.ini:extension=gd.so

Now find the files that are loading the extensions that are causing the errors and comment out those lines with a ;.