Alwina's open source efforts


Specialized in FreeBSD and CentOS

Perfect FAMP server for 8.x

September 7th, 2010 at 6:54

How to install Apache, MySQL, PHP, and PhpMyAdmin on FreeBSD/PCBSD 8.1 (FAMP)

1. Installing MySQL

a. Build MySQL from the ports

# cd /usr/ports/databases/mysql51-server
# make install clean

This may take a while. Please relax and enjoy life!

b. # ee /etc/rc.conf

Add the following line to /etc/rc.conf:


This line will enable mysql and start mysql on boot.

c. Start MySQL manually

Now we will start mysql manually with the following command:

# /usr/local/etc/rc.d/mysql-server onestart

*note – if the user has to stop mysql enter the following

# /usr/local/etc/rc.d/mysql-server onestop

d. Set password for MySQL

Set the passwor for MySQL with the followingcommand (substitute your own password for ‘your-password’:

# rehash
# mysqladmin -uroot password ‘your-password’

check to see if mysql is running

# /usr/local/etc/rc.d/mysql-server onestop

# /usr/local/etc/rc.d/mysql-server onestart

MySQL should now be installed and functioning.

2. Installing Apache

a. Build Apache from the ports

# cd /usr/ports/www/apache22
# make install clean

b. ee /etc/rc.conf

Add the following line:


c. ee /usr/local/etc/apache22/httpd.conf

press esc → then press f → press a and enter the following


underneath this line enter the name of the Server



or enter a usable name for the server. However it must correspond to the name of the server once PHP is installed and configured. *note – this is in reference to Step 3 Installing PHP, part f.

3. Installing PHP

a. Build PHP from the ports

# cd /usr/ports/lang/php5
# make install clean

Make sure the APACHE option (Build apache module) option is ticked when configuring the build. All other options should not be changed. This take a lot of time, another coffee!

b. Install the php5-extensions

# cd /usr/ports/lang/php5-extensions
# make install clean

c. Install the php.ini file

# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

You could also take the development version php.ini-development if you prefer.

d. Edit your Apache configuration file httpd.conf

# ee /usr/local/etc/apache22/httpd.conf

Add the following lines to the end of the file, just before the include statement:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Search for the line that reads:

DirectoryIndex index.html

and add index.php so it reads

DirectoryIndex index.php index.html

Enable language settings by searching for the line

#Include etc/apache22/extra/httpd-languages.conf

and removing the # comment mark so it reads:

Include etc/apache22/extra/httpd-languages.conf

e. Edit your Apache configuration file httpd-languages.conf

# ee /usr/local/etc/apache22/extra/httpd-languages.conf

Add the following line to the end of the file:

AddDefaultCharset On

f. Add you hostname to /etc/hosts

# ee /etc/hosts

Add your ‘hostname’ and your ‘hostname’.localdomain this file, so it maps to the IP of your machine.
After the modification the file /etc/host should look like this:

::1 localhost localhost.pcbsd-8032 pcbsd-8032 localhost localhost.pcbsd-8032 pcbsd-8032

g. Start Apache

# /usr/local/etc/rc.d/apache22 onestart

*note – to stop apache

# /usr/local/etc/rc.d/apache22 openstop

If there are no errors: you’re done. Apache with PHP is installed!

4. Installing phpMyAdmin

a. Build phpMyAdmin from the ports

# cd /usr/ports/databases/phpmyadmin
# make install clean

b. Edit Apache configuration file httpd.conf

# vi /usr/local/etc/apache22/httpd.conf

Add the following line to the <IfModule alias_module> section (just search where the other Alias commands are.)

Alias /phpmyadmin /usr/local/www/phpMyAdmin

Add the following <Directory> entry to the configuration:

<Directory “/usr/local/www/phpMyAdmin”>
Order allow,deny
Allow from all

Note: You may prefer to ut the Alias entry inside a <VirtualHost> entry if you are hosting multiple sites using name based virtual hosting and do not wish to enable phpMyAdmin on all the sites.

c. Fix ownership and access rights:

# cd /usr/local/www
# chown -R www:www phpMyAdmin
# chmod +x phpMyAdmin

d. Visit http://<yourip>/phpmyadmin and do the setup

You should get the configuration dialogue of PhpMyAdmin and follow the instructions.

e. Finish configuration of phpMyAdmin

# cd /usr/local/www/phpMyAdmin/
# chown www:www
# chmod 444

f. Restart Apache

# /usr/local/etc/rc.d/apache22 onestop

# /usr/local/etc/rc.d/apache22 onestart

g. Configure phpMyAdmin

Now you can visit http://<yourip>/phpmyadmin and continue the configuration of phpMyAdmin.
The page you see should look like this:

And after logging in it should look like this:

If there is a comment at the bottom about ‘blowfish’ enter the following:

# cd /usr/local/www/phpMyAdmin

# ee

$cfg['blowfish_secret'] = 'kJ76Fgeak98h6thjd6';   

*note – the password ‘kJ76Fgeak98h6thjd6′ is an example and should be changed

Tags: , , , , , , , , ,

One Response to “Perfect FAMP server for 8.x”

  1. admin Says:

    Thanks a lot Walter, for this contribution! Regards, Alwina