Planet Fox > Computer World > The MAINFRAME > Internet Servers

Internet Servers

As if this poor machine didn't already have anough stuff running on it, I decided that I would be nice to have a private web server, especially for things like remote linking graphics on forums and providing file downloads. The page you're reading might have been served off this machine, you never know! I also wanted an FTP server, which would allow me to access my files from any computer anywhere, since every computer manufactured since the dawn of time has a built in FTP client, plus FTP is a great way to move text files back and forth between Windows and Unix, since it converts the formatting on the fly. Fortunately, an FTP server (ftpd) is already built in to FreeBSD and can be enabled by simply removing the comment from the line

ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l

in inetd.conf. Keep in mind, that like telnet, FTP sends passwords and data unencrypted, so never use it over an insecure connection - use something like scp (secure copy) instead.

Apache (httpd)

The Apache webserver is a bit large, but it's also well secured and highly reliable. Installing it is straightforward, simply run make config-recursive in /usr/ports/www/apache22 and deselect any options or modules you won't need, keep the default options for its dependencies unless you know what you're doing, then run make install clean which will probably take a while.

After everything's done you can edit the configuration file at /usr/local/etc/
We're only going to change a few options;


Then we need to add the user webmaster, who is part of the www group, and create a directory called data in their home directory. Then we can link /usr/local/www/apache22/data to that folder. This is to simplify file uploads to our server via FTP.

# adduser
Username: webmaster
Full Name: Webmaster
Uid (Leave empty for default):
Login group[webmaster]:
Login group is webmaster. Invite into other groups? []: www
Home directory [/usr/home/webmaster]:
Enter password:
# cd /usr/local/etc/apache22/data
# rm -r data
# mkdir /usr/home/webmaster/data
# ln -s /usr/home/webmaster/data data
# date | cat > data/index.html

Now we can test it with apachectl configtest, if it returns Syntax OK we can start apache by adding apache22_enable="YES" to /etc/rc.conf and running service start apache
Now aim your browser at your server's local address, if it worked you should see today's date. If it didn't work, try loading it from a browser on the same machine (Lynx is a good browser for machines without a windowing system, and even works over telnet) by visiting your loopback address. If that doesn't work it means you've misconfigured the server, otherwise it's a problem with your network.
To see if your web server is visible to the public internet, visit a proxy site and enter your public IP address. If it worked, congratulations. If you got an error message such as "Connection closed by remote host" then it's very likely that you're behind a firewall. Reconfigure any routing devices, modems or gateways you have to enable network address translation (NAT) and change the firewall settings to allow unsolicited inbound connections on port 80.

DHCP (dhcpd)

Dynamic host control protocol is useful for automatically configuring computers that connect to your LAN, it automatically assigns an IP address, default route and DNS information to each new computer that connects. This is another one that isn't installed by default. To install it, simply run make install clean in /usr/ports/ics-dhcp42-server. Once that's installed, all you need to do is configure it by editing /usr/local/etc/dhcpd.conf

# IP address of your ISP's domain name server
# You can use this one if you don't know
option domain-name-servers;

# This specifies how long a device may hold its lease,
# in seconds. For a larger network with many new
# connections, you may want to use a smaller value
default-lease-time 86400;
max-lease-time 172800;

#This is the authoritative DHCP server for this LAN
# This data is provided to the hosts that
# connect to this machine and specifies the
# range of available IP addresses and the default route
subnet netmask {
option routers;
option subnet-mask;

Now, each client that connects to our local network will get an automatically generated IP address between and, a netmask of, a default route of and a DNS server at

Powered by FreeBSD
Valid HTML 4.01
Site Map
©MMIX-MMXIV Planet Fox