Here is a procedure to install a FAMP(FreeBSD with Apache, MariaDB and PHP) server. The following setup runs Apache 2.4, MySQL 5.6, and PHP 5.5 on FreeBSD 10. If any version of the packages needs to be changed, replace the versions in the commands accordingly.
Pre-Installation Tasks
Before installation of the components, Download the compressed snapshot of the ports collection, using the following command
# portsnap fetch
Now extract the snapshot into /usr/ports using the following command
# portsnap extract
Apache 2.4 – Installation and Configuration
# cd /usr/ports/www/apache24 # make install
(While running “make install” the installer asks to check the boxes to install various libraries and support packages. Check the appropriate boxes as per requirements.
# make clean
Edit the apache configuration file i.e. /usr/local/etc/apache24/httpd.conf and make the following changes
ServerRoot "/usr/local" ServerAdmin you@your.address ServerName www.example.com:80 DocumentRoot "/usr/local/www/apache24/data" Listen :80
Edit the /etc/hosts file and add the following line:
<ip-address> <hostname>.<domain>
eg:
192.168.1.1 hostname.example.org
Create a file named /boot/loader.conf or edit it if it is already present and add the following line:
accf_http_load="YES"
Add the following line to /etc/rc.conf
apache24_enable="YES"
Test the apache server installation using the following command:
# /usr/local/sbin/apachectl start
MariaDB – Installation and Configuration
# cd /usr/ports/databases/mariadb55-server/ # make install # make clean
Start MariaDB
# /usr/local/etc/rc.d/mysql-server start
Add the following line to the file /etc/rc.conf
mysql_enable="YES"
Set password for my sql using the following command
# rehash # mysqladmin -uroot password
Configuring mysql
Use the following command
# cp /usr/local/share/mysql/my-small.cnf /etc/my.cnf
Restart mysql using the following commands
# /usr/local/etc/rc.d/mysql-server restart
PHP – Installation and Configuration
Use the following commands to install PHP5.5 and other supporting packages
# cd /usr/ports/lang/php55 # make install # make clean
Copy the PHP configuration file using the following command
# cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
Install and configuring mysql module for PHP
# cd /usr/ports/databases/php55_extensions # make config
Enable the mysql extension as in the image below
# make install # make clean
Install and configuring apache module for PHP
# cd /usr/ports/www/mod_php55 # make install # make clean
Edit /usr/local/etc/apache24/httpd.conf file and add the following lines under /AddType
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
And add the following line under LoadModule section
LoadModule php5_module libexec/apache24/libphp5.so
Modify the line ‘DirectoryIndex index.html’ to the following
DirectoryIndex index.php index.html
Now restart the apache server by using the following command
# /usr/local/sbin/apachectl restart