User-Managed Webserver HOWTO

This document details how to configure a user-managed webserver at CSLab. If you'd like to learn more, please see the User-Managed Webservers Overview page.

Remember, if you want to setup reverse proxying for your new user-managed webserver, you must contact your POC. Please see the Overview document linked above for more information on this.

For any help in setting up or configuring a user-managed webserver, please contact your POC.

Here are the contents for this page:


Configuring a User-Managed Webserver

Log onto colony.cs.toronto.edu, the webserver, and run the following script:

$ /opt/webserver/makesite

The script will create a mini filesystem hierarchy rooted at /u/[username]/site. There you will find configuration files in /u/[username]/site/etc/, scripts in /u/[username]/site/bin/, log files in /u/[username]/site/var/log/, etc.

Note that at this point the Apache server has been started, but the MySQL server has not, nor has it been configured (see next section for this). Please note the information given at the end of the installation regarding starting/stopping Apache, as well as other important information.

The most critical piece of information you need to retrieve from the installation information is the given port number on which your Apache process is running. If you lose this information, you can always find it again by examining the contents of the ports.conf configuration file in your site's etc/apache2 directory. You can also look at the installation log itself at:

    /u/[username]/site/var/log/installation.log

Furthermore, note that the Apache server has the mod_python and mod_php modules loaded by default. The former is required for reverse proxying to work. For more information, see the section on mod_python in the Overview document referenced at the beginning of this page.

Finally, note that the makesite script installs a line in your crontab to start apache2 when the host machine reboots, so you don't have to worry about implementing such a feature yourself.

Managing Your Webserver

You can start, stop, and manipulate your Apache servers using the following following script:

    /u/[username]/site/bin/apache2ctl

Once started, you may access your site from the following URL:

    http://www.cs.toronto.edu:[portnum]/

where [portnum] is the port number your Apache instance is running on. See the previous section on configuring your user-managed webserver for how to find out the port number your server is running on. Please see the top of this page for information on how to setup reverse proxying on your site so you do not need to type the port number in URLs.

Please examine the contents of your site's bin directory for useful scripts in managing your site.

Note that, by default, your Apache document root is set to:

    /u/[username]/site/var/www/

Configuring MySQL

Although MySQL is setup when you run the makesite script, it is not fully configured and is not running by default. To enable it, run the following command in your site's bin directory. For example, assuming your site's prefix path is /u/[username]/site:

    /u/[username]/site/bin/mysql-init

This command will initialize your database and set the root password, which is set to be blank by default and is thus very insecure. It will also add a line to your crontab to start mysqld upon system reboot, just as with the apache2 setup in the previous section of this document.

The information displayed during the setup procedure, as well as any errors encountered, will be saved in the MySQL installation log, located in your site's hierarchy as follows:

    /u/[username]/site/var/log/mysql-installation.log

Note that this logfile will also contain the port number under which your mysqld server process is running, in case you need to know it in the future. The number can also be gleaned by looking at the my.cnf configuration file for your MySQL instance, which defines the port number explicitly. You can find it here:

    /u/[username]/site/etc/mysql/my.cnf

Managing MySQL

You can start, stop, and manipulate your MySQL server using the following script:

    /u/[username]/site/bin/mysqladmin

You can connect to your MySQL server, once started, using the following command:

    /u/[username]/site/bin/mysql -u root -p

Please see the above section on configuring MySQL for information regarding how to find the port number your MySQL server instance is running on, which may be required by any web application you may be setting up or programming yourself.

Also note that when connecting to your MySQL server, please use the 127.0.0.1 address as the host address rather than localhost. The mysql and mysqladmin scripts in your custom site already use 127.0.0.1 by default.

Removing a User-Managed Webserver

To delete your user-managed webserver, and if you're sure you wish to, follow the steps below, replacing all instances of /u/[username]/site with your actual site's prefix path.

  1. Stop all running instances of Apache2 and MySQL (if applicable):

        /u/userone/site/bin/apache2ctl stop
        /u/userone/site/bin/mysqladmin stop

    If you've installed any other associated daemon software, stop them as well.

  2. Remove your site's directory hierarchy. Please be careful when typing the following command, as any mistakes can be catastrophic:

        $ rm -rf /u/userone/site
  3. Remove the files create to reserve ports for your use. This will be any files in /opt/webserver/ports that are owned by you.

  4. Finally, remove all crontab entries for starting apache2, mysqld, and any associated daemons you may have added.

That should be it!