Debian Clusters for Education and Research: The Missing Manual

Setting up a Web Server

From Debian Clusters

Jump to: navigation, search

Contents

Web Server Installation

Installing the web server software, Apache 2, is almost scarily easy. To install Apache, just run

apt-get install apache2

You won't be prompted for any options, but it's done, you should have Apache running on your system. Visit http://www.yourserver.com/ to see be redirected to a congratulatory "It works!" page. The install drops most of its important files in /etc/apache2, so head there next to take a look around.

The configuration specific to the web server is in /etc/apache2/apache2.conf and you'll add your additions this configuration in /etc/apache2/httpd.conf. Settings specific to the website are in /etc/apache2/sites-available/default. (If this seems like a subtle distinction, don't worry about the difference.)

To get rid of the annoying redirection to the "It works!" page, open up /etc/apache2/sites-available/default in your favorite text editor and delete these comments and the line responsible for that redirection:

# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
RedirectMatch ^/$ /apache2-default/

Go ahead and delete the directory it's redirecting to, too, with rm -rf /var/www/apache2-default/. Then restart Apache with apache2ctl restart.

More Bells and Whistles

At some point, you may need to install a program (by hand) or a package may be installed with PHP or MySQL as part of its requirements. These can also be manually installed.

PHP

PHP is a scripting language that builds on top of HTML and allows dynamic content. The web server interprets the script and generates HTML from the PHP code, which is then sent along as normal to clients (people opening the web page). Sometimes PHP gets a bad wrap as taking user input with PHP can introduce a lot of security holes. However, many people use it successfully with proper precautions.

PHP is installed on Debian with

apt-get install libapache2-mod-php5

MySQL

MySQL is a database implementation. It is often used in conjunction with PHP. Websites may pull from an SQL database in order to provide different types of content. To install MySQL and have it be compatible with PHP, run

apt-get install mysql-server-5.0 php5-mysql

Securing the Webserver

What's the first thing to do once the web server has been installed? Why, put some effort into securing it, of course!

Personal tools