Install Apache, MariaDB And PHP In FreeBSD10

by
Share this Article: Facebook44Google+5Twitter12LinkedIn1Reddit0Pinterest0StumbleUpon1Digg

This tutorial describes how to install AMP(Apache, MariaDB, PHP) server in FreeBSD 10.

We assume you have the FreeBSD Ports Collection installed. If not, do:

portsnap fetch
portsnap extract

If the Ports Collection is already installed,  update it  with :

portsnap fetch update

Okay, let’s   begin the  installation of the  componments

Install Apache

Navigate to the Apache server port and build it:

cd /usr/ports/www/apache24
make install clean

Edit /etc/rc.conf so that the Apache server will start automatically at system boot.

echo 'apache24_enable="YES"' >> /etc/rc.conf

start Apache an check with http://IP-address.

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

apachefreebsd

Install MariaDB Database Server

cd /usr/ports/databases/mariadb55-server
make config ; make install clean

Edit rc.conf to start MariaDB at boot:

# vi /etc/rc.conf
 ...
# add mysql_enable
 mysql_enable="YES"

Now start MariaDB:

# service mysql-server start

Setup grant tables:

# cd /usr/local/   # mysql_install_db assumes its running from here
# mysql_install_db --user=mysql

Configure root password:

mysqladmin -u root password 'yournewpassword'

Grant root permission to connect remotely:

mysql -u root -p
mysql> grant all privileges on *.* to 'root'@'%' identified by 'appleton' with grant option;
mysql> exit;

Install PHP

Before we proceed to build PHP, we need to add a configuration option so that PHP build includes support for the Apache server.

 cd /usr/ports/lang/php55
 make config

A menu should come up allowing you to select/deselect various build options. You should select “Build Apache module”

apache-php2014-01-23_110302

now go ahead with setup:

make install clean

add support for both MySQL and MySQLi   to to communicate with the MySQL server.

cd /usr/ports/lang/php55-extensions/
make config

mysql-php

In the corresponding menu you should select “MySQL database support” and “MySQLi database support”.

start building:

 make install clean

 

Configuration of  PHP

cp /usr/local/etc/php.ini-development /usr/local/etc/php.ini

Now let’s configure Apache. Open the file /usr/local/etc/apache24/httpd.conf in your favourite editor and look for the following line:

DirectoryIndex index.html

And change it so it reads as follows:

 DirectoryIndex index.html index.htm index.php

AddType lines:

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

Now restart Apache:

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

To check if your php is nstalled,

add the code test.php,

cd /usr/local/www/apache24/data/
vi   test.php

Add the following lines:

<?php
  phpinfo();
?>

Restart apache and test:

http://ip/test.php

phpinfo

Please note: For PhpMyadmin if you are working with php55 you will get this error:

===>  pecl-APC-3.1.14_1 cannot be installed: doesn't work with lang/php55 port (doesn't support PHP 5.5).
 *** Error code 1

You have to Downgrade to php53 to get rid off this error, else wait till this issue be fixed by FreeBSD  developers.

For questions please refer to our Q/A forum at : http://ask.unixmen.com/

Share this Article: Facebook44Google+5Twitter12LinkedIn1Reddit0Pinterest0StumbleUpon1Digg