How to Setup a FreeBSD 6 Webserver - FAMP Server

Posted on February 2nd, 2008 in Computers, Servers/Hosting, Unix/Linux, Web | 8 Comments »

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!

FreeBSD

How to Install GD Support for PHP in Ubuntu - Drupal

Posted on January 2nd, 2008 in Unix/Linux, Web | 1 Comment »

I am in the process of building a social site using Drupal and realized I didn’t have GD support for PHP5 installed on my server. I’m sure this is a common roadblock for people new to installing Drupal or even just PHP so here is what you need to do:

Open terminal and type in the following command:

$ sudo apt-get install php5-gd

Now restart Apache

# sudo /etc/init.d/apache2 restart

There you go, you now have GD Support for PHP5 in Ubuntu. Get your Drupal on!