Thread Tools Display Modes
Old 11-06-2013, 08:00 PM
jtscolorado jtscolorado is offline
Junior Member
Join Date: Nov 2013
Location: Colorado, USA
Posts: 22
Thanks: 2
Thanked 4 Times in 4 Posts
Default Install Apache, MySQL, PHP, and phpMyAdmin on PC-BSD-9.2 using ports
Here is a walkthrough of how I installed and configured Apache, MySQL, PHP, and phpMyAdmin using FreeBSD ports on my PC-BSD 9.2 machines that I use for simple local web development and hobby code work. These instructions should not be used for a production server. Given that PC-BSD is FreeBSD in the background, this guide may work on FreeBSD 9.2 as well but I haven't tested that.

The OS I'm using is PC-BSD-9.2-RELEASE-amd64

Here are the software versions that I installed:



1. Open a terminal window and login as root by entering su and then enter your root password when prompted. You should now have a terminal open with you as root.

2. You need to have an updated FreeBSD ports collection. If you don't have the ports collection installed, you will need to install it by entering:

portsnap fetch


portsnap extract

If you already have the ports collection installed, you will need to update it by entering:

portsnap fetch update

*** 3. While building the various ports below you should accept all default configuration options unless otherwise instructed.

Optional - install editor of your choice
I prefer the Nano editor and if I don't have this installed already, I'll do so at this point:

cd /usr/ports/editors/nano

make install clean

Install Apache

4. Navigate to the Apache server port and build it:

cd /usr/ports/www/apache24

make install clean

5. Once Apache has been successfully installed, add the following line to /etc/rc.conf so that the Apache server will start automatically at system boot.

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

6. Now you can start Apache to make sure it works:

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

Point your web browser to the host name or IP address of the host you’ve installed Apache on (I generally leave this as 'localhost' or '' on my computer) and you should see the default “It Works” page.

Install MySQL

7. Go to the port for the MySQL server:

cd /usr/ports/databases/mysql56-server

make install clean

8. Add the following line to /etc/rc.conf:

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

9. And start the mysql server:

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

10. Then set a password for the MySQL root user:

/usr/local/bin/mysqladmin -u root password 'your-password'

Install PHP

11. Before we build PHP, we need to add a configuration option so that PHP build includes support for the Apache server. Start with the following commands:

cd /usr/ports/lang/php5

make config

12. A menu should come up allowing you to select/deselect various build options. You should select “Build Apache module” by highlighting the option with the arrow keys and hitting the space bar. I also select the "Enable debug". Then hit Enter, which should bring you back to the command prompt.

13. Now proceed with building the port:

make install clean

14. Now I add the extensions to PHP to fulfill its capabilities. Before we build this port though we’ll want to add support for both MySQL and MySQLi (an improved interface to MySQL) in order to communicate with the MySQL server.

cd /usr/ports/lang/php5-extensions/

make config

15. In the corresponding menu you should select “MySQL database support” and “MySQLi database support”. I also select "CURL support", "PDO", and "PDO MySQL". Then hit enter and proceed with building the port:

make install clean

Install phpMyAdmin

phpMyAdmin is a common MySQL database administration tool -- it's up to you if you want to use this or another method to manage your databases.

16. I'll add support for MySQL and MySQLi before building the port:

cd /usr/ports/databases/phpmyadmin/

make config

17. Here you should ensure that both “MYSQL (DB_connect): PHP MySQL support via mysql client” and “MYSQLI (DB_connect) PHP Improved MySQL client support” are selected, then proceed with building the port:

make install clean


18. Now that you have the ports built and installed it’s time to configure them. First, create the file /usr/local/etc/php.ini to hold our PHP options. An easy way to do this is to copy the file /usr/local/etc/php.ini-development which will add the default settings for new PHP installations. As I mentioned previously - these instructions are not for production purposes.

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

19. Now you can configure Apache. Open the file /usr/local/etc/apache24/httpd.conf in your favorite 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

20. Then append the following lines to the end of the file in order to support PHP files as well as phpMyAdmin, which normally lives outside of the Apache document root. IT IS CRITICAL THAT YOU MAKE THESE CHANGES CORRECTLY. Note: if you chose not to install phpMyAdmin, then you only need to add the two AddType lines:

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

Alias /phpmyadmin "/usr/local/www/phpMyAdmin"

<Directory "/usr/local/www/phpMyAdmin">
Options None
AllowOverride None
Require all granted

21. If you’d like to add multilanguage support to Apache, uncomment the following line:

Include etc/apache24/extra/httpd-languages.conf

Then open the language settings file /usr/local/etc/apache24/extra/httpd-languages.conf and add the following line to the end of the file:

AddDefaultCharset On

22. Now restart Apache:

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

23. Now let’s configure phpMyAdmin. We’ll do this by creating the file /usr/local/www/phpMyAdmin/, the basic configuration file for phpMyAdmin. Traditionally, users have manually created, but now phpMyAdmin includes a nice setup script, making it much easier to create this file with the settings you want. Start by creating the directory /usr/local/www/phpMyAdmin/config and make it writable by phpMyAdmin:

mkdir /usr/local/www/phpMyAdmin/config && chmod o+w /usr/local/www/phpMyAdmin/config

24. Then add read permission to the default config file:

chmod +r /usr/local/www/phpMyAdmin/

25. Then open your web browser and go to http://your-hostname-or-IP-address/phpmyadmin/setup where you will see the phpMyAdmin setup Overview page. Select “New server” and then select the “Authentication” tab. Under the “Authentication type” choose “http” from the drop-down list (using HTTP-Auth to sign-in into phpMyAdmin will avoid storing login/password credentials directly in and remove “root” from the “User for config auth”.

26. Now select “Save” and you will be returned to the Overview page where you should see a new server listed. Select “Save” again in the Overview page to save your configuration as /usr/local/www/phpMyAdmin/config/

27. Now move that file to /usr/local/www/phpMyAdmin where phpMyAdmin can make use of it.

mv /usr/local/www/phpMyAdmin/config/ /usr/local/www/phpMyAdmin

28. Now you can try out phpMyAdmin to make sure it works. Point your web browser to http://your-hostname-or-IP-address/phpmyadmin where you will be presented with a pop-up box requesting you to log in. Use “root” and the MySQL password you set up previously, then you should be directed to the phpMyAdmin administration page.

29. You no longer need the /usr/local/www/phpMyAdmin/config directory so you can remove it and then restart the Apache and MySQL servers:

rm -r /usr/local/www/phpMyAdmin/config

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

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

30. Note that your public/www files for this server will by default be in the directory /usr/local/www/apache24/data. I will change ownership of that directory to my user account so that I can easily edit/add/delete files there:

chown -R 'your-user-name' /usr/local/www/apache24/data
Reply With Quote
The Following User Says Thank You to jtscolorado For This Useful Post:
helix (01-26-2014)
Old 01-31-2014, 03:59 PM
jtscolorado jtscolorado is offline
Junior Member
Join Date: Nov 2013
Location: Colorado, USA
Posts: 22
Thanks: 2
Thanked 4 Times in 4 Posts
Default This method successfully worked with PC-BSD-10.0
This method successfully worked with PC-BSD-10.0 as well.
Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 10:30 PM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

Copyright 2005-2010, The PC-BSD Project. PC-BSD and the PC-BSD logo are registered trademarks of iXsystems.
All other content is freely available for sharing under the terms of the Creative Commons Attribution License.