Sunday 20 November 2011

The FreeBSD experience - part 3 let's AMP

Now the basics are there, I'm going to turn my VM into an (F)AMP-machine; Apache, MySQL and PHP.

I'm going to use the current versions available in de ports-repository:

Apache 2.2 (v2.2.21)
MySQL 5.5 server (v5.5.17)
PHP 5 (v5.3.8)


Install MySQL
(these are the installation instructions taken from the Joomla site).

Go to the ports directory and install
# whereis mysql55-server
mysql55-server: /usr/ports/databases/mysql55-server
# cd /usr/ports/databases/mysql55-server
# make install clean
Accept the default settings.

Copy the MySQL configuration file to /usr/local/etc and edit this file (my.cnf)
cp /usr/local/share/mysql/my-medium.cnf /usr/local/etc/my.cnf
To enable an automatic start of MySQL at boot time do the following:
echo mysql_enable=\"YES\" >> /etc/rc.conf
Before we continue we add a root password to MySQL
mysql -u root password {yourpasswordhere}
Install Apache 2.2.x
# whereis apache22
apache22: /usr/ports/www/apache22
# cd /usr/ports/www/apache22
# make install clean
-- Accept default settings --

After installation, uncomment the following lines in /usr/local/etc/apache22/httpd.conf
Include etc/apache22/extra/httpd-mpm.conf
Include etc/apache22/extra/httpd-default.conf 
(We'll dive into SSL later).

Let's add Apache to /etc/rc.conf to have it started at boottime
echo apache22_enable=\"YES\" >> /etc/rc.conf
Also enable AcceptFilter suport in FreeBSD kernel:
echo apache22_http_accept_enable=\"YES\" >> /etc/rc.conf
That takes care of loading accf_http kernel module at system startup. To manually load the module, use
kldload accf_http
The utility of accf_http is such that a server will not have to context switch several times before performing the initial parsing of the request. Use this command to check whether the accf_http kernel module is successfully loaded:
kldstat | grep accf_http
To start Apache HTTP server, you may restart the system or enter command:
service apache22 start
You can point your browser to that server's URL and see whether Apache is serving the default page.

Install PHP5
# whereis php5
php5: /usr/ports/lang/php5
# cd /usr/ports/lang/php5
# make install clean
Select Apache Module and continue till it's done. After installation we need to copy a configuration file in /usr/local/etc:
cd /usr/local/etc
cp php.ini-production php.ini
Load the php.ini in an editor and add/change the following:
[Date]
date.timezone = "Europe/Amsterdam"
[Session]
session.save_path = "/var/tmp"
Edit your Apache configuration file (/usr/local/etc/apache22/httpd.conf) and add  this:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
In  the DirectoryIndex  add php  extentions  like:
DirectoryIndex index.php index.html
Start/restart Apache22
apachectl restart
Create a file /usr/local/www/apache22/data/phpinfo.php with a single line:
echo '<?php phpinfo(); ?>' >> phpinfo.php
Check if it works by browsing to {your serverip}/phpinfo.php

Thanks to the following links I was able to get here:

http://joomlab15.exonsoft.com/en-us/articles/joomla!15x/99-joomla-15-on-freebsd-81?start=3

http://www.unixmen.com/linux-tutorials/unix-tutorials/1397-how-to-install-apache-mysql-php-phpmyadmin-in-freebsd

The Joomla info is a bit outdated and not very accurate at some points (I struggled with mod.fcgid so I left it out).

At this point I'm having a bit of a dilemma to install phpmyAdmin as well.


No comments:

Post a Comment