Apache · Apache 2.4 · FAMP · MySQL · PHP · Web Server

FAMP – Installing Apache2.4, MySQL, PHP on FreeBSD-9.1

Here is a procedure to install a FAMP(FreeBSD with Apache, MySQL and PHP)  server. The following setup runs Apache 2.4, MySQL 5.6, and PHP 5.5 on FreeBSD 9.1. 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

MySQL – Installation and Configuration

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

Start MySQL

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

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 '<password>'

Configuring mysql

Use the following command

 # cp /usr/local/share/mysql/my-default.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

Check the option ‘Build Apache Module’ as shown in the image and continue

PHP55Apache module

# make clean

Copy the PHP configuration file using the following command

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

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
Advertisements

2 thoughts on “FAMP – Installing Apache2.4, MySQL, PHP on FreeBSD-9.1

  1. You might want to change the heading since you are configuring apache 2.4 not 2.2 .
    also apache24 and enable need an underscore between them as in apache24_enable=”YES” in /etc/rc.conf

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