Web Serving I: First Web Page, Web Script

Robert D. Cameron
January 14, 2004

1. Firewall

First, configure your Firewall. Under Mandrake 9.2, run Mandrake Control Center. Choose Security, the Choose Firewall. Select only web server and SSH, deselect "everything." Click OK and exit.

For advanced applications, you may wish to learn more about firewalling. Mandrake uses the Shorewall firewall system, basically a GUI interface to the iptables facility of the Linux 2.4 kernel.

2. Web Server Installation

Install apache and mod-php. Under Mandrake 9.2, run Mandrake Control Center. Choose Software Management and use the graphical installer.

The Apache web server documentation gives you all the information you need for web server configuration. The initial configuration under Mandrake 9.0 may be found in /etc/httpd/conf/httpd.conf and related files. The initial configuration is fine. Note that the root of all web documents is defined by the following configuration entry.

DocumentRoot /var/www/html
You don't need to change the configuration. But in order to install web pages under your own account (say webmaster) rather than as root, the following command should be issued.
chown webmaster  /var/www/html

3. Your First Web Page

Create the file /var/www/html/index.html with contents similar to the following.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html>
<head>
<title>An Introductory Web Page</title>
</head>
<body>
<h1>An Introductory Web Page</h1>
<p>This is an introductory web page.</p>
</body>
</html>

This is a page marked up using XHTML, the XML representation of HTML 4. You should be able to access this page using your web browser at http://localhost/.

3. Your First Web Script

PHP is a server-side scripting language that provides for dynamic content in web pages.

Create the file /var/www/html/script1.php with contents similar to the following.

<html>
<head>
<title>An Introductory Web Script</title>
</head>
<body>

<h1>An Introductory Web Script</h1>
<p>Here are the results of phpinfo() on my web server.</p>
<?php
  phpinfo()
?>
<p>Pretty cool, huh?</p>
</body>
</html>

Now check it out at http://localhost/script1.php.