Interactive Web Sites

Last modified by Thomas Coelho (local) on 2024/07/03 10:58

By default you can put static web content in the public_html directory located in your home directory. This content is reachable with https://itp.uni-frankfurt.de/~username.

There may be reasons that you need some server site processing like php stuff. The following article describes how this is implemented and how you can interactive with it.

Design

It is based on systemd services. Like any system service, services can also run in a user context and under control of the user. Instead of a common web server which delivers files from the public_html directory, a dedicated Apache instance is executed in the users context. There are some prerequisites, which must configure by the admins:

  1. A lingering user session. Normally the session is started with the login of the user. A lingering session is started on boot. This allows the start the services at boot time.
  2. A Proxy redirect. The frontend reverse proxy must be configured to forward requests to the specific Apache instance. This allows also second level domains.

Setting up

On the web server (this is currently web3) the script install-apache-worker needs to be run to prepare the environment after the prerequisites have been set up. The main job of the script it to prepare the runtime environment below .apache-service and to install the systemd service file. This can be read (and modified if needed) in .config/systemd/user/apache-worker.service.

[Unit]
Description=Apache Userspace worker for thw
RequiresMountsFor=/home/thw
ConditionHost=web3

[Service]
ExecStart=/usr/sbin/apache2 -d/home/thw/.apache-service -DNO_DETACH
WorkingDirectory=/home/thw

[Install]
WantedBy=default.target

 On the host in ConditionHost you can control the service witch systemctl --user.

systemctl --user status apache-worker

Replace status with stop/start/restart to control the job,

Logfiles are written to .apache-service/log. The Logfiles are rotated by rotatelogs which is as a pipe for the logfiles,