Child pages
  • How do I set up a web server on the Burrow?
Skip to end of metadata
Go to start of metadata

If all you want to do is host your html, php, or cgi scripts on an SoIC web server, please note that you do NOT have to run your own web server. Please see the Web Hosting Options KB Page for information about using the existing SoIC web servers.

Background

This document provides information about setting up a web server using the SoIC Burrow systems. Before you begin, please note that some SoIC classes require students to build and manage their own version of apache. This KB document 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. Also, note that you can avoid the hassle of running your own server altogether by using the existing Web Hosting Options

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

If you have any questions about Linux systems within the school, please contact us.

Web Server Configuration

What follows is a cookbook example of setting up an apache web server on the Burrow system that you can follow. You should be logged into burrow.soic.indiana.edu (aka. silo) when you do this.

  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 conf.modules.d logs cgi-bin run
    $ ln -s /usr/lib64/httpd/modules modules 
    $ cp /etc/httpd/conf.d/php.conf ~/httpd/conf.d/
    $ cp /etc/httpd/conf.modules.d/* ~/httpd/conf.modules.d/
  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 burrow.soic.indiana.edu (aka. silo) 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:

    • Replace all occurances of the string "USERNAME" with your real username.
    • 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".
    • Replace the string "PORTNUMBER" with the port number your server will use. Please see the Server KB Document for information about choosing and registering your port number.
    • 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. Starting and Stopping 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
    

Testing and Debugging

  1. 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:


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

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

    $ echo '<?php 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:


    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.

  3. 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:

  4. 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.