Well the documentation is rather poor and I will try to provide a copy of my own of a process that is repeatable. I do see some room for improvement with the whole thing but overall it seems like a good V 0.1
Category Archives: freebsd
FreeBSD 10 Hyper-V DHCP not working after install / reboot
- Edit /etc/rc.conf:
- Comment the following with a “#”: ifconfig_YOURNICID
- Add the following: ifconfig_YOURNICID=”SYNCDHCP media 100baseTX mediaopt full-duplex”
- Save
- Done
FreeBSD: Ports and Disk Space
# portsclean -C
# portsclean -D
# portsclean -DD

EC2 now has FreeBSD

Good news. EC2 now has FreeBSD. Though with some quirks…In order to work with EC2, the FreeBSD AMIs are slightly modified from what you would have immediately after installing FreeBSD from a release CD:
- The network is configured and the sshd daemon is enabled, for obvious reasons.
- SSH logins as root are enabled, but root’s password is starred out (i.e., password logins as root will fail until a password is set).
- The first time an AMI is booted, a script fetches the public half of an SSH keypair from EC2 and arranges for root logins using that key.
- Every time the the AMI boots, it prints the SSH host keys to the console in the same format as Amazon Linux AMIs do.
- The FreeBSD kernel is located on an ext2 filesystem, in order to allow Amazon’s user provided kernel functionality to work. (Everything else is on a single UFS2 filesystem.)
- AMIs published from 2010-12-29 onwards have /etc/motd text with some comments about FreeBSD/EC2 and a link to this page.
- AMIs published from 2010-12-29 onwards by default report kernel panics (including backtraces) to the FreeBSD/EC2 maintainer to assist him in identifying and fixing bugs.
The following AMIs are available (though there are additional obsolete AMIs…):
FreeBSD version us-east-1 us-west-1 eu-west-1 ap-southeast-1
FreeBSD 9.0-CURRENT @ 2011-01-04
For t1.micro instances only! ami-8cce3fe5 ami-61683824 ami-e388bd97 ami-36bdc364
FreeBSD 8.2-RC @ 2011-01-08
For t1.micro instances only! ami-4a15e423 ami-376e3e72 ami-f77e4a83 ami-3eb6c86c
Resources
http://aws.amazon.com/ec2/
http://www.freebsd.org/
http://forums.freebsd.org/showthread.php?t=254
PHP: Finding the binary
The other day I was stumped, albeit rather briefly, by something I should not have been. I was scripting out some CRON jobs for a CRM system when I found out I could not locate where the hosting company had put the PHP binary. Now that is something you usually do not have to think about so it can easily fall into the ‘been a while’ category.
So if you ever find yourself asking, where is the PHP binary? or just where is PHP? Here are some steps to follow.
Telnet/Shell
If you have shell access via telnet, log in, and type “which php” and you should be given the location to use.
If you don’t have shell, try one of the following:
Create a php page with just the following: and then call the page, this should tell you the location of PHP.
echo system('which php');
If that does not work, though it should, try checking one of the paths listed under path in the ENVIRONMENT section of the output with this.Take note though that this will give you the environment path so you will still need to add /php to it…
echo phpinfo();
FreeBSD How to check the size of a folder
Command line interaction can be a challenge for some as I noted recently and the simplest of things can be elusive. You can check the size of a folder running this command:
# du -hs /folder/

Getting Apache22 on FreeBSD 8.1 to work with DHCP
Apache likes to have a static IP address to work with and that is not always something you can guarantee to have. An easy way to get around this is to add the following two files to /etc
Firstly add a file called “dhclient-exit-hooks” with the following
#!/bin/sh
APINCDIR=/usr/local/etc/apache22/Includes
APPIDFILE=/var/run/httpd.pid
if [ ! -z “$new_ip_address” ]; then
# First, configure the /etc/hosts file so Apache can start
HOSTNAME=`grep ^hostname= /etc/rc.conf | awk -F = ‘{ print $2 }’ | sed -e ‘s/”//g;’`
if [ ! -z “$HOSTNAME” ]; then
echo “$new_ip_address $HOSTNAME” > /etc/hosts.dynamic
cat /etc/hosts.boilerplate /etc/hosts.dynamic > /etc/hosts
fi
# Next, we’ll configure the Apache web server, if it has been installed
if [ -d $APINCDIR ]; then
echo “ServerName $new_ip_address” > $APINCDIR/server-name.conf
if [ -f $APPIDFILE ]; then
kill -HUP `cat $APPIDFILE`
fi
fi
fi
Creating symbolic links in FreeBSD
Sometimes when you FTP into a FreeBSD environment you need to bounce around to directories acroos the file system. One way to simply this process when working in a FTP client is to create a symbolic link as a file. It is really easy.
To go from point A to point B where point A is a click able file and B is a target folder just run:
ln -s /path/to/folder/B /where/you/want/the/file/to/exist/B

How to install MemCached with Apache, PHP, and MySQL on FreeBSD
memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
Danga Interactive developed memcached to enhance the speed of LiveJournal.com, a site which was already doing 20 million+ dynamic page views per day for 1 million users with a bunch of webservers and a bunch of database servers. memcached dropped the database load to almost nothing, yielding faster page load times for users, better resource utilization, and faster access to the databases on a memcache miss.
Notes
- There are definitely steps in this that can be changed, extended, other, but these will get you what you want in a good learning fashion. And learning is key!
- You can just as easily install memcached on an IIS server.
- Yes you can download binaries with pkg_add etc. but building will help you literally see what is going where. One just has to make sure that some housekeeping is performed during the build process. This is done with the clean parameter in the make command.
- This appears to be quite a popular post. Please keep in mind that version numbers change so update the strings below.
First off build a FreeBSD box. It’s easy, fast, and best of all free once you have the hardware – real or virtualized. Don’t forget to install the ports. You’re going to need them going forward.
For dependency issues we’re going to install all the items in this order:
- MySQL Server 5.x
- Apache 2.x
- PHP5
- PDF-Lite
- PHP Extensions
- MemCached
Run netstat -an to confirm that a process is listening on TCP 11211
It may also be useful to run /usr/local/bin/php -i | grep -i ‘memcache’
Speed up your PHP like Facebook does with HipHop for PHP
If you’re interested in using/trying some PHP frameworks you can start by looking at: