Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×

Four Steps to Build a Test Web Server

Free Apache Software Is Easy to Install, Easy to Use

While many people maintain their websites through a hosting provider, you still need to know how it works. This month, we’ll use the free and open source Apache Project to build a Web server.

Most people think of a Web page as eye candy arranged for viewing in a browser. But have you ever wondered what HTML actually looks like, and how it’s actually sent to that browser? “HTML” stands for HyperText Markup Language, which is the standard for Web pages. An actual “.html” or “.htm” file is plain text with embedded commands such as “add an image here” or “use this size font there.” The server uses the HyperText Transfer Protocol, or HTTP, to deliver HTML pages to your browser, which then translates them into viewable content. The original HTML 1.0 specification was limited and was intended for “static” Web pages: simple text with embedded images, with minimal formatting. Later HTML incarnations have allowed more control over the display of the page, and Cascading Style Sheets (CSS) are often used now to specify layout and appearance. CSS acts as a template, telling the browser how to display content; this way your site has a more consistent “look” from one page to the next. For example, CSS might be used to say, “Always put my header image at the top of the page and the table of contents here on the left.”

Provided that the browser supports it (and most do), Web content creators can also embed commands, such as JavaScript, into HTML to build interactive pages. On the server end, things like PHP can be used to generate content on demand. “PHP” originally came from “Perl Home Pages” (Perl is a popular programming language). Nowadays, the acronymn doesn’t mean anything; PHP is just the name of a special language that’s ideal for building Web pages.

The bleeding edge for interactive Web applications combines the two: The browser sends user input back to the server, which then creates active content on the fly. In the open source world, “AJAX” is the mantra for software requirements (“Apache, JavaScript and XML”) and Microsoft offers ASP.NET for the same thing. This article won’t concentrate on content. Entire books have been written about AJAX, PHP, JavaScript, Adobe Flash and other “tricks” that a modern Web developer uses to create a professional-looking website. We’re going to look at the basic Web server itself.

PLAY AND LEARN

The Apache Web server is one of the most successful of all open source projects. Like Linux itself, it’s a free download and it’s developed by a dedicated (fanatical) group of programmers from around the world. OpenSUSE Linux supports it fully and is ready to install it as soon as you say “Go.” I’ll assume that you’ve installed openSUSE Linux on a PC on your office network, and that it has Internet access. Given that, Yet Another Setup Tool (good ’ol YaST) makes it easy.

Step 1: Installing Apache

Click Computer > YaST, then scroll down to the Software section. Click “Software Management.” In the window that appears, enter “Apache” in the search (“find”) box at the top. Everything Apache-related will appear in the lower selection screen; all we need is “Apache 2” (see Fig. 1). Click that, then “Apply.” The Apache Web server will be downloaded and installed.

Fig. 1: Installing Apache on OpenSUSE Linux

We’ll also install the YaST Apache module, so next enter “yast” in the search box. Scroll down to find “yast2-http-server”; click that, then “Apply.” Now you can close YaST, then restart it. When it comes back up, scroll down to the Network Services section. You should see an “HTTP Server” entry. Click that and, for this example, we’ll configure a very basic (but quite functional) Web server.

Step 2: Apache Configuration

Fig. 2 is the first screen of the HTTP Configuration module. This lists the available network interfaces (127.0.0.1 is the Local interface on the server itself). Just accept the default here, which is to listen on all interfaces. Be sure that the “open port in firewall” button is checked. The next page is where you enter some server-specific information. For this test, you’re just playing with the Web server on your local network, and we can accept the defaults. If you expose this server to the Internet, though, you should change the server name and the contact email address. Click on those lines and select the “Edit” button. The next configuration page allows you to set up virtual hosts. Don’t touch this; this is an advanced trick that we won’t need here. Basically, you could create and register many different domain names with DNS — forums.myserver.com, events.myserver.com and so on — and have the Apache server use a different home directory (or even a different server) for each one. We won’t need that for this example. That final configuration page is the summary of proposed changes. If you missed anything, you can click the “Back” button to fix it. You should check the “Start Apache2 Server When Booting” button, or you’ll have to manually start the Web server each time you restart the machine.

Fig. 2: Configuring the Apache Web Server — just accept the defaults here.

Step 3: Test Your Server

I recommend that you reboot your Web server before continuing: click Computer > Shutdown and select “Restart The Computer.” When it finishes rebooting, click Computer > Firefox to open the browser and enter “127.0.0.1” in the address bar. (You could also try browsing to your server’s IP address from another PC on your local network.) Most Apache installations include a default page that says, “It Works”; for some reason, my installation of openSUSE 11.3 didn’t. But an error page still proves that Apache is running (if it weren’t, your Web browser would complain that it couldn’t connect at all). Note that the default base directory for HTML is /srv/www/htdocs. You’ll have to log in as the root to put Web pages there. Fortunately the openSUSE build of Apache supports personal Web pages by default. Enter “127.0.0.1/~username” and you’ll see a directory of that user’s home “public.html” directory. This is where we’ll put our HTML files.

Step 4: Create Your Web Pages

The word processor LibreOffice (the successor to OpenOffice) can create HTML. Click Computer > LibreOffice Writer. In LibreOffice, select File > New and choose “HTML Document.” Enter some text, then save the file in your home directory, in the “public_html” folder, with the name “index.html.” Now click Computer > Firefox to open the Web browser. Enter “127.0.0.1/~(yourusername)” and you should see your new page. If you want to see what the actual HTML looks like, right click anywhere in the page and click “View Page Source” (don’t be surprised if there’s a lot of stuff there just to display a few lines of text).

As I said above, Apache is quite reliable and you could, if you wanted to, expose this to the Internet as a for-real Web server. If you’re on an extreme budget (or just want complete control of content), you can do this. But don’t skimp on the security: Make sure the firewall is running, use very good passwords, and regularly click Computer > YaST and check for updates.

WEB HOSTING AT AN OUTSIDE COMPANY

In the good old days (just 10 years ago!), you installed the Apache HTTP Server on a decent PC and put up your own website in no time flat. Nowadays, you are more likely to use a hosting provider like Go Daddy or your own ISP. They provide the bandwidth, the hardware and the DNS (Domain Name System) work. All you have to do is create the content and upload it (or, in many cases, you can use their online content editor to create a professional-looking Web page very quickly). Maintaining a top-quality website takes a lot of work. Unless you have staff who are really good with website design, you probably ought to consider using someone like Intertech Media to do the wizardry for you, too. It’ll cost, but you may decide that it’s worth it. Nowadays, especially if your station is popular, you can expect for your website to be quite busy at times. Big active Web pages with lots of eye candy mean larger files. A simple DSL line with less than 1 megabits of upload will be inadequate for more than a few “hits” at a time. This is another reason you might consider using a hosting provider; they’ll be clamped directly onto the Internet with a “big pipe” that can provide lots of bandwidth. Finally, there’s the old security issue. Apache itself is rugged and reliable, but it still requires maintenance. Unless you’re willing to peruse the logs for hacker attempts and to keep the server software updated, your site will eventually be hijacked by a Bad Guy. A hosting provider takes care of these headaches for you, too.

FIND OUT WHAT IT CAN DO

In this article, as usual, we only barely scratched the surface. Books have been written about HTML, creating effective websites, and how to configure an Apache server in any of dozens of different ways. But this “test” server will work fine to learn the fundamentals. Try creating different Web pages with LibreOffice. Save your filenames with the “.html” extension into your public_html folder, then enter “127.0.0.1/~yourname/pagename.html” to view them. Have fun!

Stephen M. Poole, CBRE-AMD, CBNT, is chief engineer of Crawford Broadcasting in Birmingham, Ala. Read past Radio IT Management columns at radioworld.com under the Business tab.

Close