Apache is the most widely used web server on the planet — and with good reason. Not only is Apache flexible and powerful, but it's also quite easy to get running and to start serving up content.
The idea of using a web server that relies so heavily on the command line and flat text file configuration might be rather daunting, but it doesn't need to be. I'll walk you through setting up a basic website with the latest iteration of Apache on Linux or Windows (I'm assuming you have a Linux or Windows machine ready for the task). After you follow this tutorial, you'll have either a Windows, Apache, MySQL, PHP (WAMP) or a Linux, Apache, MySQL, PHP (LAMP) server running and a "Hello World" page greeting your users.
There are lots of WAMP servers you can install to get your Windows-based Apache server set up, but my favorite is the WampServer package, which installs everything you need for a web development environment. Here's how to install WampServer.
- Download the WampServer installer.
- Double-click the installer to start the process.
- Walk through the user friendly installer wizard (it's a typical Windows application installation).
Once the installation is complete, you should see an entry for WampServer in your Start menu's All Programs section. In that menu, click the start WampServer entry. When the WampServer starts, left-click the icon in the System Tray to see the menu (Figure A); from this menu, you can start or stop the services and gain quick access to the server's configuration files.
The WampServer menu.
To get your website set up and running, the most important information you need is:
- Document Root: This is where your website files will live. For the WampServer, these files will be in C:\wamp\www.
- index.html: This is the most basic page for your website and should reside within the Document Root.
By default, WampServer will use the index.php file for its default page. Within the C:\wamp\www directory, rename the index.php file to OLD_index.php. In that same directory, create the index.html file and put this single line in the document:
Save that file and make sure your WampServer is running. Open your web browser and point it to the address of your WampServer. You should see the text (in bold):
If you do, congrats! Your WampServer is up and running.
I'll demonstrate how you can have a full-blown LAMP server up and running with just a couple of commands. For simplicity sake, I'll be demonstrating this on a Ubuntu 13.04 server. Here are the installation steps.
- Open a terminal window.
- Issue the command sudo apt-get install tasksel.
- Type your sudo password and hit Enter.
- Accept the installation.
After tasksel completes the installation, go back to the terminal window and do the following:
- Enter the command sudo tasksel.
- In the resulting window, use the down arrow key and move to LAMP Server (Figure B).
- Press the Tab key to move down to OK and hit Enter.
- When prompted, enter the passwords for MySQL.
When this installation completes, your LAMP server will be running.
What you need to know:
- Document Root: /var/www/
- Index: The LAMP defaults to index.html for its main page. You can edit that page directly for your website.
- To start and stop Apache, issue these commands: sudo apachectl start or sudo apachectl stop.
Congratulations! You now have a web server. I bet you had no idea setting up Apache for simple web pages was that easy.
Keep in mind that Apache isn't limited to basic web pages; it's also just as easy to serve up robust and dynamic sites with this powerhouse server.
Also read: 8 tips to make SMB websites better
Jack Wallen is an award-winning writer for TechRepublic and Linux.com. He’s an avid promoter of open source and the voice of The Android Expert. For more news about Jack Wallen, visit his website getjackd.net.