04 - Install PHP, Postfixadmin, perform initial configuration for PHP and apache

### Install PHP. I like using a specific version (5.3 in this case) as long as it's supported, instead of using /usr/ports/lang/php, which is allways 'the latest and the greatest', but may lead to trouble, as it was the case when upgrading from 5.2 to 5.3.
# cd /usr/ports/lang/php53
/usr/ports/lang/php53# make config
[ make sure you check 'APACHE'. I like to have the 'MAILHEAD' and 'MULTIBYTE' options checked, CGI unchecked ]
/usr/ports/lang/php53# portupgrade -Np



### Install an optional module: php53-imap, to avoid complaints from the Postfixadmin web installer

# portupgrade -Np php53-imap
[ cclient package configuration: select SSL_AND_PLAINTEXT, leave selected SSL and SSL_AND_PLAINTEXT ]
[ php53-imap config: leave SSL enabled ]


### Tell php what timezone to use, otherwise php date function won't work. The postfixadmin backup script will fail, unless date.timezone is set
# cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini
# echo 'date.timezone = Europe/Bucharest' >> /usr/local/etc/php.ini


### Install Postfixadmin
# cd /usr/ports/mail/postfixadmin/
/usr/ports/mail/postfixadmin# make config
[ select MYSQL and/or MYSQLI, OK ]
/usr/ports/mail/postfixadmin# portupgrade -Np
[ php53-mysql config: Keep MYSQLND checked ]
[ php53-mbstring config: Keep REGEX checked ]
[ php53-mysql config: Keep MYSQLND ]


### Let apache know about php and postfixadmin
###
# cat << DELIMITER > /usr/local/etc/apache22/Includes/mod_php.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
DELIMITER


### The following configuration will add /postfixadmin to all virtual hosts configured on this server
# cat << DELIMITER > /usr/local/etc/apache22/Includes/postfixadmin.conf
Alias /postfixadmin "/usr/local/www/postfixadmin"
<Directory "/usr/local/www/postfixadmin">
    Options none
    AllowOverride Limit
    Order Deny,Allow
#    Deny from all
    Allow from 127.0.0.1
# The Allow directive below MUST be changed/removed or replaced with 'Allow from 1.2.3.4', where 1.2.3.4 is the IP address of your workstation
    Allow from all
</Directory>
DELIMITER



### Add hosts' name to /etc/resolv.conf (or make it resovlable via DNS)
# vi /etc/hosts
[
edit the line containing 127.0.0.1 ]
127.0.0.1 localhost localhost.my.domain server.local.domain


### Start apache
# service apache22 start

Prev: Install Dovecot, Postfix and Apache
Next: Configure Postfixadmin, create the superadmin account
Comments