Apache with dynamic IP
I was setting up a FreeBSD system to use Apache, and I was running into some problems getting it to start normally. I had the following in my /etc/rc.conf file:
hostname="grtest.domain.name.com"
ifconfig_em0="DHCP"
...
and in my /etc/hosts file:
::1 localhost
127.0.0.1 localhost
I was getting assigned a good IP, but when I would attempt to start Apache, I would get an error message similar to
[Thu Aug 18 11:05:11] [alert] httpd: Could not determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
What I had to do to fix the issue was to add a private IP for my NIC. I did this via the FreeBSD Diary’s instructions, which involved:
- Adding the following line to /etc/hosts:
192.168.0.1 grtest grtest.domain.name.com - Adding line to /etc/rc.conf to add IP automatically to NIC on boot:
ifconfig_em0_alias="inet 192.168.0.1 netmask 0xffffffff" - Add IP to NIC via the command:
ifconfig em0 alias 192.168.0.1 netmask 0xffffffff - Restart apache, noting no longer an error:
/usr/local/etc/rc.d/apache2.sh restart
Now it will still give me a public IP from the DHCP, but now works so that Apache will start correctly.
I was having a similar problem on a Gentoo Linux system before I scrapped it, so a similar solution would probably have fixed that issue as well.

Rafael Said,
January 3, 2006 @ 9:33 am
Very good! It worked!
Teh Blarg » Red Hat Enterprise Linux (RHEL) 4 ifconfig adding an alias Said,
June 12, 2007 @ 8:27 am
[...] Ubuntu is not for me.Apache with dynamic IPGentoo LinuxSpyware Removal ApplicationsMaxtor Hard Drive, [...]