| Subcribe via RSS

Do This BEFORE You Install FreeBSD 7

September 8th, 2008 | 2 Comments | Posted in FreeBSD, Tutorial

Installing FreeBSD

First Things First

So you’ve decided to install FreeBSD. Great! Now go out and get a copy of Bryan J. Hong’s book, “Building a Server with FreeBSD 7″ before you do anything else! Especially if this is your first attempt at installing FreeBSD–even if you are proficient with Linux or any other variety of the UNIX-like operating systems.

If you are in a big hurry, buy the book from the publisher along with the PDF version (buy both–you will want the hardcopy version for your notes).

 

Building a Server with FreeBSD 7

Why this book? First, it has a very clear set of instructions for installing each component you will need to create a complete web server with email support, FTP capability, SSH and SSL support, all using the PORTS system. Second, the book is small enough to take with you when you travel, so if there is a problem back at home, you can refer to the book and see where all those configuration files reside on your server. Third, it is a great reference book for future server builds, and a great place to put your own notes for customizations you have made.

Very soon after you install FreeBSD on your first server, you will have the confidence to build a second or third (or more). As you start adding FreeBSD servers to your data center, you may want to install custom FreeBSD servers for special purposes. For example, you may want to build a stand-alone mail server, that only handles email for your domain and other domains, as well.

Next Steps

After you build your first server, you may want to customize it… making changes to certain features. You will want to install and customize many of the PORTS available, getting the latest FreeBSD software and tools for your server.

FreeBSD Starter Library

Your Library

A good starter library for installing and maintaining FreeBSD servers would include the following books:

  • Building a Server with FreeBSD 7, by Bryan J. Hong
  • Absolute FreeBSD, by Michael W. Lucas
  • Wicked Cool Shell Scripts, by Dave Taylor
  • The Book of PF, by Peter N. M. Hansteen
  • The Book of IMAP, by Peer Heinlein and Peer Hartleben
  • The Book of Postfix, by Ralf Hildebrandt and Patrick Koetter
  • BSD UNIX Toolbox, by Christopher Negus and Francois Caen

I have all of the above books in my library. I do not consider this list to be complete, by any means. But if you are just getting started, buy the first and second book first. Then, as your interests become more focused, check out the rest of the books in my list. You will be able to install FreeBSD and maintain your server with proficiency.

Note: I have written a post to catalog my Errata for Building a Server with FreeBSD 7.

Buy the book and follow step-by-step the instructions to install FreeBSD. You can go from zero to fully functional web server over the weekend!

Tags: ,

Errata: Building a Server with FreeBSD 7

September 8th, 2008 | 2 Comments | Posted in FreeBSD, Tutorial

I have built a few servers following the instructions given by Bryan J. Hong in his very thorough book: “Building a Server with FreeBSD 7.” For anybody wanting to build a web server, mail server, FTP server, or just a local network server, this book makes the process as easy as possible.

No Starch Press, the publisher, has an Errata page for this book. I found some additional errors when I built my servers, which I document here. Please check the official Errata page on No Starch’s site, and make the following corrections to your copy of the book before building your server. As of this writing, the official Errata page does not include these corrections:

  • On p. 25, in step 6., before “cd /usr/ports” issue this command: 
  • touch /usr/ports/INDEX-7
  • On p. 46, just above step 2., the two commands should NOT include “.sh” and should be:
  • /usr/local/etc/rc.d/courier-imap-imapd start
  • /usr/local/etc/rc.d/courier-imap-imapd-ssl start
  • On p. 184, the directory link (the second command on the page) should be:
  • ln -s /usr/local/www/apache22/data www

Using the default settings and following the directions in the book, the above corrections should all work perfectly.

Note: I have written a post on installing FreeBSD. It covers a good starter library of books on FreeBSD.

Tags: ,

Courier-IMAP Trouble Connecting Multiple Computers

May 26th, 2008 | No Comments | Posted in FreeBSD, Tutorial

Having your own mail server can be a great experience. If you are hosting your own mail server with Courier-IMAP, you might have trouble connecting with more than one computer at the same time. I had that trouble and found the solution in the configuration file.

With my Mail application running on my desktop machine, my laptop would not connect to the server. It looked like there were SSL problems on my laptop, but it turned out not to be so. Later, I noticed that if my laptop was already connected to the mail server, my desktop machine could not connect. The message from Mail was a little misleading. It appeared that there was a problem connecting to the server because of a problem with the SSL certificate or some other SSL issue.

After a little digging around in the Courier-IMAP configuration file, I found a line that limited the maximum number of connections from the same IP address.

In a FreeBSD server, that configuration file is:

/usr/local/etc/courier-imap/imapd

I solved the problem by changing the configuration file for Courier-IMAP. Since my desktop and my laptop share the same IP, I had to tell the IMAPD configuration file that I wanted more connections from the same IP address.

Max Per IP Courier-IMAP

The default setting was:

MAXPERIP=4

I changed it to:

MAXPERIP=8

I am not sure how many connections each computer made, but when I went from one computer to two, the default setting of 4 didn’t work. So, I doubled it, restarted the mail server and connected from two computers simultaneously.

My problem disappeared. So if you are having trouble connecting with more than one computer, try changing the MAXPERIP number to something higher. And realize that if you are connecting from a network that shares a single IP address, multiple computers will need multiple connections from the same IP address, and this needs to be managed in the imapd configuration file.

EDIT: I subsequently decided to change the number of connections to 16:

MAXPERIP=16

By observing the netstat (with this command: systat -netstat), the first computer logged in with 4 connections, the second with 5 connections. It all depends on the e-mail client and how many connections it opens simultaneously. I have not yet tried more than two clients, but I set it at 16 while I am the only one using this e-mail address from a single IP.

If you have multiple people checking e-mail from behind a single firewall (a single IP address), you may want to change this setting to something more like 5 * [number of users]. For example, 10 users could easily use up 50 connections.

To restart courier-imap on a FreeBSD 7 machine, use these two commands:

/usr/local/etc/rc.d/courier-imap-imapd restart
/usr/local/etc/rc.d/courier-imap-imapd-ssl restart

That’s it. No more trouble with multiple computers checking into your courier-imap mail server. These examples are from FreeBSD 7, with courier-imap installed from the ports collection.

I highly recommend this book: “Building a Server With FreeBSD 7″ by Bryan J. Hong. I have two posts related to it:

Tags: ,

Back to the Original Server

May 15th, 2008 | No Comments | Posted in FreeBSD, Think

A few days back, I decided to move OfficeCafe to another server so I could rebuild this one. It’s done. I had about a half hour of down time while I made the old server stop listening for connections, powered up the new server, and made WordPress talk to MySQL again.

Again, Bryan J. Hong’s book, Building A Server With FreeBSD 7, came in real handy. I had rebuilt this server so that my standard directory structures could be implemented.

The main problem I had was that WordPress could not access the MySQL database. Checking back in the book, I realized that I had missed a step on page 215. I needed to create the wordpress.conf file and restart Apache. MySQL also needed to be restarted:

# /usr/local/etc/rc.d/mysql-server restart

That did the trick. We’re back and running. The preparation for the move back involved backing up the database(s), copying them to the new server, and restoring them.

There are a lot of details involved in moving a WordPress blog from one server to another (and back)! I don’t recommend making a habit of it. But in the process, I realized that having a backup of the database and the root directory of the blog is a great thing to do. If I need to move it to another server, I should be able to pick up the main files and drop them into place and keep going!

Tags: ,

Office Cafe Server Move

May 5th, 2008 | 1 Comment | Posted in FreeBSD, Think

Sometimes I insist on doing things the hard way. I needed to reinstall my server’s operating system. That is, I needed to update the FreeBSD installation on one particular machine. Just to make things interesting, I also updated to the latest version of WordPress at the same time. So to accomplish the reinstallation, I first moved my entire WordPress blog to another physical server. We’ll see, but I may never move it back! For now, everything is back to normal. Now that everything is working, I will go back to the original server and rebuild the entire server. Why do I need to do everything over again? Since the time I built that server, I have standardized my installations and that machine was no longer conforming to the new standard.

Yes, I am hosting my own web server (servers actually). I am doing this mainly for the instructional value. (It also keeps my brain thinking along some very technical lines. I suppose I could just settle for Sudoku, but there is something very therapeutic about hosting your own web server)!

And to make sure that the job would be complicated, I configured FreeBSD and Apache to serve up Name-Based as well as IP-Based Virtual Hosts simultaneously. What that means is that this server is hosting multiple domains on at least two distinct IP addresses from the same physical machine. Crazy? For sure! Why do it? Let’s just say that there is a lot of educational value in digging into the details.

Bryan J. Hong’s book, Building A Server With FreeBSD 7, sure came in handy. Although he doesn’t cover the Virtual Hosts in any detail, lots of information about the topic is available at the Apache web site.

There are a lot of moving parts to servers. The details are pretty intense. Fortunately, Hong keeps things pretty simple and nearly complete. Check it out.

Anyway, moving the installation from one server to another server was not simple, but neither was it impossible. The fact that you can even see these words is proof enough for me that I got a few things right along the way. It was also fun to make it all happen.

I suggest trying this yourself, just for the fun of it (and if you are into technical things like Unix, virtual servers, intrusion detection, honeypots, bringing new life to old hardware, etc.)!

Tags: