Upgrade to php52 on FreeBSD

By default, after portsnap to latest FreeBSD port tree, it will upgrade your php5.2 to php5.3 automatically. There isn’t any option where you can to remain your PHP version to 5.2.

In order to keep my PHP applications running on PHP version 5.2, what I did is upgrade all php5-* packages to php52-*, but it will be a little waste of time if doing it manually, port by port.

So I written this simple bash to output me the packages of php5-* which need to upgrade to php52-*


for d in `portversion -vL= | grep php5 | awk '{print $1}'`; do  OLD=`echo $d | cut -d - -f 1,2`; NEW=`echo $d | sed s/php5/php52/ | cut -d - -f 1,2`; THEPATH=`whereis $NEW | awk '{print $2}' | cut -d / -f 4,5`; echo "portupgrade -o $THEPATH $OLD && \\"; done

The bash will actually output


portupgrade -o textproc/php52-simplexml php5-simplexml && \
portupgrade -o devel/php52-spl php5-spl && \
portupgrade -o databases/php52-sqlite php5-sqlite && \
portupgrade -o devel/php52-tokenizer php5-tokenizer && \
portupgrade -o textproc/php52-xml php5-xml && \
portupgrade -o textproc/php52-xmlreader php5-xmlreader && \
portupgrade -o textproc/php52-xmlwriter php5-xmlwriter && \
portupgrade -o archivers/php52-zip php5-zip && \
portupgrade -o archivers/php52-zlib php5-zlib && \

Before upgrading the php extensions package, upgrade your php52 as below


portupgrade -o lang/php52 php5

On the last time, remember to remove “&& \”, or you can press enter key twice to activate the upgrade.

Bind Error: “max open files (3520) is smaller than max sockets (4096)”

Just notice one of the DNS server has the error message


28-Jun-2010 16:28:24.283 general: max open files (3520) is smaller than max sockets (4096)

It’s something to do with kernel setting, on FreeBSD, configure the following


shell> sysctl kern.maxfiles=4096
shell> sysctl kern.maxfilesperproc=4096

Alternatively, put the above configuration on /etc/sysctl.conf in order to configure it at start up level.

Change or Set User Password in FreeBSD

If you notice, during FreeBSD installation, it doesn’t have a step by step installation guides for creating user’s password for login credential. By default, FreeBSD installation only come with user “root”, and it doesn’t prompts for password setting for default user “root”. After installation, you can login to FreeBSD with user “root”, no password.

So, it’s advise that to set user’s password after installation. You can set or change user’s password in FreeBSD with passwd command.

Try to have your password in alphanumeric combination, meaning alphabets + numbers and at least 6 characters long. You can do some creative password combination like “go2HELL”, “1amN00b1nUn1x”, “BUYm3b33r”, “h3ySumm3rH0t” and etc. Please do remember, the password is case sensitive too.

To Set Password for Default User “root”

To set the password;

  • type: passwd
  • input your password twice

To change your password, use the same command and it will prompt you for current password before putting the new one.

To Set or Change Password for Other Userid

Login as “root” and change user’s password, in example userid foo

  • Type: passwd foo
  • Input your password twice

How to Change Hostname in Unix FreeBSD

We have interesting hostname for our all our servers. Some of it is using Football Team like Manchester, Liverpool, Chelsea, Arsenal. Part of it is striker name like Rooney, Ronaldo and etc. We also have like meganfox, milla, jessicaalba for those “hot” “steamy” servers. Occasionally if the football team is not perform well, we will change the hostname for the server to other football team, for example Manchester to Chelsea. Yea.. We are not loyal support, we only support the no. 1 team.

Joking aside, how to change server hostname in Unix FreeBSD? There are 2 ways to do it, one is the easy way another is the geeky way. Depend on yourself, if you want to show your elite skills, do it with the text editor, or make the change with Sysinstall.

Change Hostname in Unix FreeBSD with Sysinstall

  • In command line, type: sysinstall
  • Select Configure
  • Select Networking
  • Select Interfaces
  • Select your Network Interface Card (em0 em1 fxp0)
  • No IPV6 (Select yes if you are running on ipv6)
  • No DHCP (Select yes if you are running on dhcp)
  • host: should be your server name like chelsea
  • domain: should be your own domain like takizo.com
  • Select Ok
  • Exit, Exit, Exit
  • In command shell, type: hostname chelsea.takizo.com

This will update your new hostname in Unix FreeBSD box. But please take note you will have extra junk in /etc/rc.conf. So it’s recommend to change your hostname in Unix FreeBSD with following method.

Change Hostname in Unix FreeBSD in “Clean” Way

  • In command shell, type: hostname chelsea.takizo.com
  • Edit /etc/hosts with vi, change the existing hostname to your new hostname
  • Edit /etc/rc.conf with vi, on the “hostname” variable change the existing hostname to your new hostname

This is the better approach in order to organize your /etc/rc.conf clean and clear.

How to Change User’s Shell Environment in FreeBSD

In FreeBSD, user’s default shell environment is either sh or csh and I have installed Bash in FreeBSD and would like to change user’s shell environment to Bash.

To change user’s shell environment in FreeBSD.


shell> chsh -s /usr/local/bin/bash userid

To change your shell environment in FreeBSD


shell> chsh -s /usr/local/bin/bash