Indiana University Bloomington

School of Informatics and Computing


Computer Science Program







 Home

 Contacts

 Courses

 Academics

 Careers

 Research

 People

 Calendar

 Facilities
   New KB
   Legacy FAQ

CSG FAQ

Q: How do I set up a web server on the Burrow?

Before you begin, please note that some CS classes require students to build and manage their own version of apache. This FAQ does not address that case but, rather, describes the process of setting up a web server using the version of apache installed with the operating system. This provides a very simple way you can run your own server without the overhead of managing the apache software.

You are also encouraged to read the Server FAQ that discusses general issues related to running your own server on the CS systems.

What follows is a cookbook example of setting up an apache web server that you can follow.

  1. Create directories - You need to create a directory that will contain your apache configuration files, logs, html files, and cgi/php scripts. In this example, we will use a directory named httpd in your home directory but you can use any name you like.

    $ mkdir ~/httpd
    $ cd ~/httpd
    $ mkdir html conf conf.d logs cgi-bin run
    $ ln -s /usr/lib/httpd/modules modules

  2. Create configuration file - You will need an apache configuration file and we have provided one you can use as a starting point. You can copy that file with:

    $ cp /etc/httpd/conf/httpd.conf.template ~/httpd/conf/httpd.conf

    Please note that this template file is only available on silo (aka. burrow.cs.indiana.edu) so you must be logged into that system when you run this cp command.

    Once you have copied this file, you MUST edit the file and make the following substitutions:

    1. Replace all occurances of the string "USERNAME" with your real username.
    2. Replace all occurances of the string "GROUP" with your primary group. You can get this by running groups at a command prompt and you want to use the first group listed. If you are a student, you should use "students".
    3. Replace the string "PORT" with the port number your server will use. Please see the associated FAQ entry for information about choosing and registering your port number.
    4. If you used a directory other than ~/httpd from step 1, you will have to make the appropriate edits to change that as well.

  3. Start/Stop the server - You can now start and stop apache by running the httpd command using the -f flag to specify the location of your configuration file. You can start the server with:

    $ /usr/sbin/httpd -f ~/httpd/conf/httpd.conf -k start

    You can stop the server with:

    $ /usr/sbin/httpd -f ~/httpd/conf/httpd.conf -k stop

    If you make configuration changes, you can restart the server with:

    $ /usr/sbin/httpd -f ~/httpd/conf/httpd.conf -k restart

  4. Testing - html - You can create a test index.html file with:

    $ echo Test html file > ~/httpd/html/index.html

    If the server is running and everything is set up right, you will be able to access this test page using the url:

    http://silo.cs.indiana.edu:PORT/

    You will need to replace PORT with the port number you selected for your server.

  5. Testing - php - You can create a test php file with:

    $ echo '<? phpinfo(); ?>' > ~/httpd/html/test.php

    If the server is running and everything is set up right, you will be able to access this test php script using the url:

    http://silo.cs.indiana.edu:PORT/test.php

    You will need to replace PORT with the port number you selected for your server. This test php script will display the php version details.

  6. Testing - cgi - If you will be using cgi scripts, you can create a test script named ~/httpd/cgi-bin/test.cgi with the following contents:

    #!/bin/sh
    echo "Content-type: text/html"
    echo
    echo Test cgi script

    This cgi script needs to executable, which you can do by running:

    $ chmod +x ~/httpd/cgi-bin/test.cgi

    If the server is running and everything is set up right, you will be able to access this test php script using the url:

    http://silo.cs.indiana.edu:PORT/cgi-bin/test.cgi

  7. Debugging - If you are getting server errors, you should consult the apache logs. These files are in ~/httpd/logs and server errors should be logged to the file name error_log.

  8. Cleaning up - Note that the log files in ~/httpd/logs will continue to grow so you may want to clear the files periodically. You can just stop the running server and remove these files and they will be recreated when you start the server again.



See an error in this FAQ entry? Please report it.

[Return to the FAQ index]









Valid HTML 4.01!