Project

General

Profile

Support #385

Updated by Daniel Curtis over 10 years ago

Here is a procedure to install a FAMP, *F*reeBSD with *A*pache, *M*ariaDB and *P*HP, server. The following setup runs Apache 2.4, MariaDB 5.5, and PHP 5 on FreeBSD 9.2. If any version of the packages needs to be changed, replace the versions in the commands accordingly. 

 h2. Pre-Installation Tasks 

 * Before installation of the components, download the compressed snapshot of the ports collection, using the following command: 
 <pre> 
 portsnap fetch 
 </pre> 

 * Now extract the snapshot into @/usr/ports@ using the following command: 
 <pre> 
 portsnap extract 
 </pre> 

 h2. Apache 2.2 – Installation and Configuration 

 * Install Apache 2.2 
 <pre> 
 cd /usr/ports/www/apache22 
 make install 
 </pre> 

 *NOTE*: 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. 

 *NOTE*: I use puppet to manage apache packages and configurations, so the above command is just for reference. 

 * Clean up the source packages: 
 <pre> 
 make clean 
 </pre> 

 * Edit the apache configuration file, i.e. @/usr/local/etc/apache22/httpd.conf@, and make the following changes: 
 <pre> 
 ServerRoot "/usr/local" 
 ServerAdmin you@your.address 
 ServerName www.example.com:80 
 DocumentRoot "/usr/local/www/apache22/data" 
 Listen :80 
 </pre> 

 * Edit the @/etc/hosts@ file and add the following line: 
 > <ip-address>                    <hostname>.<domain> 

 #* eg: 
 > 192.168.1.1                 hostname.example.org 

 * (Optional) 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@: 
 > echo 'apache22_enable="YES"' >> /etc/rc.conf 

 * Test the apache server installation using the following command: 
 <pre> 
 /usr/local/sbin/apachectl start 
 </pre> 

 h2. MariaDB – Installation and Configuration 

 Install MariaDB 5.5 
 <pre> 
 cd /usr/ports/databases/mariadb55-server/ 
 make install 
 make clean 
 </pre> 

 * Add the following line to the file @/etc/rc.conf@: 
 <pre> 
 echo 'mysql_enable="YES"' >> /etc/rc.conf 
 </pre> 

 * Start MariaDB 
 <pre> 
 service mysql-server start 
 </pre> 

 * Set password for mysql using the following command 
 <pre> 
 rehash 
 mysqladmin -uroot password 
 </pre>  

 h3. Configure MariaDB 

 * Use the following command: 
 <pre> 
 cp /usr/local/share/mysql/my-small.cnf /etc/my.cnf 
 </pre> 

 Restart mysql using the following commands: 
 <pre> 
 service mysql-server restart 
 </pre> 

 h2. PHP – Installation and Configuration 

 * Install Use the following commands to install PHP5 and other supporting packages: 
 <pre> 
 cd /usr/ports/lang/php5 
 make install 
 make clean 
 </pre> 

 * Copy the PHP configuration file using the following command 
 <pre> 
 cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini 
 </pre> 

 * Configure the mysql module for PHP: 
 <pre> 
 cd /usr/ports/databases/php5-mysql /usr/ports/databases/php5_extensions 
 make config 
 </pre> 

 *NOTE*: Make sure to enable the *mysql* extension 

 * Install the mysql module for PHP: 
 <pre> 
 make install 
 make clean 
 </pre> 

 * Install the php5-session package 
 <pre> 
 cd /usr/ports/www/php5-session 
 make install clean 
 </pre> 

 * Configure the php5-extensions package 
 <pre> 
 cd /usr/ports/lang/php5-extensions 
 make config 
 </pre> 
 *NOTE*: Enable all the modules that will apply to your PHP needs. 

 * Install the php5-extensions package 
 <pre> 
 make install clean 
 </pre> 

 * Install and configuring apache module for PHP: 
 <pre> 
 cd /usr/ports/www/mod_php5 
 make install 
 make clean 
 </pre> 

 * Edit @/usr/local/etc/apache22/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/apache22/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: 
 <pre> 
 /usr/local/sbin/apachectl restart 
 </pre> 

 h2. Resources 

 * http://fosskb.wordpress.com/2014/04/12/famp-installing-apache2-4-mariadb-php-on-freebsd-10/

Back