2.7. Apache, MySQL and PHP

If you plan to use Postfix Admin to manage your virtual users and domain, or provide webmail access to the email stored on the server you will have to install a web server.

apt-get install mysql-server mysql-client apache2 apache2-mpm-prefork apache2-utils ssl-cert \
                libapache2-mod-php5 php5 php5-common php5-curl php5-gd php-pear php5-imagick \
                php5-imap php5-mcrypt php5-mysql php5-pspell php5-sqlite php5-xmlrpc php5-xsl php5-intl

This will also install Exim as the MTA. Uninstall it after you finish installing Postfix.

Default configuration of Apache sends server information in the response headers that we do not want to expose to everybody. To disable this open /etc/apache2/conf.d/security with nano and replace:

ServerTokens Full
ServerSignature On


ServerTokens Prod
ServerSignature Off

All application on my web server use UTF-8 as a default encoding so I also edit /etc/apache2/conf.d/charset and uncomment the AddDefaultCharset UTF-8 directive which adds the UTF-8 as the default charset to the header for all files that Apache sends to clients.

PHP also provides additional information in the response headers so we can turn off those as well.

Open /etc/php5/apache2/php.ini. Change expose_php = On to expose_php = Off and set date.timezone= Europe/Zagreb (or whatever timezone you use). The link to a list of available time zones is located in the file.

Enable mod_rewrite in Apache and restart Apache for the changes to take effe

a2enmod rewrite
invoke-rc.d apache2 restart