How to Setup a FreeBSD 6 Webserver - FAMP Server
Posted on February 2nd, 2008 in Computers, Servers/Hosting, Unix/Linux, Web |
Here it is, the meat and potatoes of setting up a FAMP server (FreeBSD 6.3, Apache, MySQL, PHP/Perl). Keep in mind these instructions are exactly what I do step by step to setup a FreeBSD webserver. Originally when I started with FreeBSD I couldn’t find a solid source of reliable information on how to set all this up. Every time I would ask someone for some good instruction I was always directed to www.freebsd.org. I have to tell you it is extremely overwhelming for me at that time to even understand anything off of that site’s directions - as well written as it is.
Over the last few years I have come across some decent walkthroughs and tutorials but 90% of them were still either out dated or lacking 1 or 2 steps that can really jack things up. I have really tried to make this tutorial as straight forward as possible, no BS and no info that’s going to waste your time.
Before I install anything I always make sure I have the latest release of FreeBSD installed with the Developer distribution. Many tutorials out there tell you to install the bare minimum of FreeBSD with the “Minimum” distro, I recommend Developer. If you need a good step by step on how to install FreeBSD (6.2 & 6.3) then click here. Remember, instead of selecting the minimal option on the Distributions screen, choose Developer.
Once you have FreeBSD installed the steps below will show you how to setup and configure a full FAMP server. Good luck!
# cd /usr/ports/lang/php5
# make config
select: Apache
# make install
# cd /usr/ports/lang/php5-extensions
# make config
select: bcmath, bz2, ctype, curl, dom, ftp, gd, gettext, mbstring, mysql, pcre, posix, pdo, session, simplexml, sqlite, xml, zlib (also by default there are many options pre-selected including some of the ones listed here, make sure to leave those checked).
# make install
Usually after everything is done you will notice a few mysql errors appear, run this command:
# pkg_add -r mysql50-server
Now before editing any file on my system I always make a backup of it:
# cp /usr/local/etc/apache/httpd.conf /usr/local/etc/apache/httpd.conf.orig
Now let’s edit your Apache config file to get everything configured properly:
# edit /usr/local/etc/apache/httpd.conf
Change the default listen address to the IP address of your webserver.
#Listen 12.34.56.78:80
To:
#Listen 192.168.1.10:80 (example, use your machines IP Address)
Change the email address of the ServerAdmin to your email address or the address of the person in charge on this server:
#ServerAdmin you@your.address (use your email address)
Change the ServerName option, if you don’t have a fully qualified domain name please change this to the servers IP address:
#ServerName www.example.com
To:
#ServerName 192.168.1.10 (example, use your machines IP Address - for internal, intranet implementations)
Or:
#ServerName www.peter-v.com (example, use your domain name if you have one and your going to point DNS to that machine)
# Add a DirectoryIndex option:
DirectoryIndex index.php index.html index.htm index.php3 index.php4
# In the AddType section add the following for PHP:
AddType application/x-httpd-php .php .htm .html
AddType application/x-httpd-php-source .phps
Now exit and save, your all done with Apache.
# echo ‘/usr/local/sbin/apachectl start’ >> /etc/rc.local
Now let’s configure MySQL:
# cp /usr/local/share/mysql/my-medium.cnf /etc/my.cnf
# echo ‘mysql_enable=”YES”‘ >> /etc/rc.conf
# /usr/local/bin/mysql_install_db
# chown -R mysql:mysql /var/db/mysql
# /usr/local/share/mysql/mysql.server start
If the command: # /usr/local/share/mysql/mysql.server start doesn’t work or fails, try this command:
# /usr/local/etc/rc.d/mysql-server.sh start
# /usr/local/bin/mysqladmin -u root -h Hostname.domainname.tld password ‘YourPassword’
# /usr/local/bin/mysqladmin -u root password ‘YourPassword’
Example:
# /usr/local/bin/mysqladmin -u root -h webserver.peter-v.com password ’secret’
# /usr/local/bin/mysqladmin -u root password ’secret’
Now let’s install Perl DBI and DBD Support (which many apps need that run using Apache and MySQL):
# cd /usr/ports/databases/p5-DBI && make install && make clean
# cd /usr/ports/databases/p5-DBD-mysql50 && make install && make clean
Reboot.
That’s it, your all done and now you’ve got yourself a FAMP Webserver.
Tips:
If at anytime in this tutorial a command doesn’t work, try rebooting first. Sometimes after installing certain applications or components it is required to reboot before being able to utilize it. After a quick reboot it always works.
I would love to hear your comments and if you have any suggestions or issues with this tutorial please leave a comment, thanks!

Tags: Apache, Developer, Distros, FAMP, FreeBSD, FreeBSD 6.2, FreeBSD 6.3, FreeBSD Webserver, Install, internet, IP Address, MySQL, networking, Perl, PHP, PHP5, root, Tutorial, unix, walkthrough
If you found this page useful, consider linking to it.
Simply copy and paste the code below into your web site (Ctrl+C to copy)
It will look like this: How to Setup a FreeBSD 6 Webserver - FAMP Server






















7 Responses
This page was very helpful. Great write up! Big thanks to the author for making it simple and thorough.
Thanks Cyrus, glad I was able to help.
I am currently testing FreeBSD 7.0 RC2 and I will be sure to do a little walk through on setting up and configuring a FreeBSD 7.0 FAMP web server.
Why are you not installing MySQL from ports?
Sylvar,
I prefer to install the latest release of MySQL for stability and security reasons. You can accomplish the same results by installing MySQL using the ports collection if thats your preference.
Also, I have noticed with many applications a lag with the ports collection being updated. Even though you can run a command to update your ports collection there could still be a good sized lag from the developer updating FreeBSD’s port collection. A good example of this is phpMyAdmin in ports.
really nice i done this on FreeBSD 7 Thanxxxxxxxxx
Great Job, worked like a charm. Very useful reading.
very nice…
how would i extend on this and add to this…
my goal is to use this for a web hosting business, i would need ftp, email and some sort of control panel for adding websites — many thanks