Setting up FAMP server on FreeBSD 11 using Pkg

FAMP stands for “FreeBSD, Apache, MySQL and PHP. The following procedure shows how you can install FAMP server on FreeBSD 11 using ‘pkg’ tool.

MySQL

Install MySQL using the following command.

pkg install mysql57-server

Once MySQL is installed we need to set the password for root user. Start the MySQL server once for setting the password for root.

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

MySQL creates a initial root password and stores it as a file in the following name.

/root/.mysql_secret

Change the password if needed

rehash

Edit /etc/rc.conf and add the following line to enable MySQL service.

mysql_enable="YES"

Copy the sample MySQL configuration file to the path /etc/ as my.cnf. If there are any additional configuration to be done, edit the file my.cnf before restarting MySQL.

cp /usr/local/share/mysql/my-default.cnf /etc/my.cnf

Restart MySQL server

/usr/local/etc/rc.d/mysql-server restart

Apache

Install Apache Web server using the following command.

pkg install apache24

Edit /etc/rc.conf and add the following line to enable Apache service.

apache24_enable="YES"

Check if Apache service can be started without errors.

/usr/local/etc/rc.d/apache24 start

Edit the file /usr/local/etc/apache24/httpd.conf and uncomment the following line and add the registered DNS address here. If the server doesn’t have a registered DNS name, enter its IP address instead of the FQDN. If there are any additional configurations to be done, edit the appropriate lines in this file.

ServerName www.example.com:80

Restart Apache server to test.

/usr/local/etc/rc.d/apache24 restart

PHP

Install PHP and related dependencies using the following command

pkg install php56 mod_php56

Check if the reference to the PHP5 module is added to the Apache configuration file.

cat /usr/local/etc/apache24/httpd.conf | grep php5_module

The output should be similar to the following. If the output is empty, add the line, or if line is commented, uncomment it.

LoadModule php5_module libexec/apache24/libphp5.so

Edit the file /usr/local/etc/apache24/httpd.conf and make the following changes

<Directory "/usr/local/www/apache24/data">
....
DirectoryIndex index.php
</Directory>

<IfModule php5_module>
        DirectoryIndex index.php index.html
        AddType application/x-httpd-php .php
        AddType application/x-httpd-php-source .phps
</IfModule>

Restart Apache service once the changes are made.

/usr/local/etc/rc.d/apache24 restart

Create a new file /usr/local/www/apache24/data/info.php and add the following lines to check the installation.

<?php
phpinfo();
phpinfo(INFO_MODULES);
?>

Use the following URL to load the web page.

http://<ip-address>/info.php
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s