Apache (HTTP server)

Table of contents

Child pages

Related pages

  • ...



How Paul set up the web.py server with Apache on Digital Ocean

  1. Remember that the default Apache config file is located at /etc/apache2/apache2.conf, but Paul said you generally don't need to make changes to it.
  2. Instead, because we're using a Ubuntu instance (and Ubuntu is based on Debian), the note at the top of the apache2.conf relates to us when it says that the configuration can be broken into separate files, and that in particular, we can use the option that says IncludeOptional sites-enabled/*.conf
  3. So what he did was to create a /etc/apache2/sites-available/oorklecom.conf file and a /etc/apache2/sites-available/ioorklecom.conf file, and then create symlinks to those files in the /sites-enabled/ folder that had the same names as the original files.
  4. The /sites-available/ folder had a file named 000-default.conf which had these contents:
    1. <VirtualHost *:80>
              # The ServerName directive sets the request scheme, hostname and port that
              # the server uses to identify itself. This is used when creating
              # redirection URLs. In the context of virtual hosts, the ServerName
              # specifies what hostname must appear in the request's Host: header to
              # match this virtual host. For the default virtual host (this file) this
              # value is not decisive as it is used as a last resort host regardless.
              # However, you must set it for any further virtual host explicitly.
              #ServerName www.example.com
      
              ServerAdmin webmaster@localhost
              DocumentRoot /var/www/html
      
              # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
              # error, crit, alert, emerg.
              # It is also possible to configure the loglevel for particular
              # modules, e.g.
              #LogLevel info ssl:warn
      
              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined
      
              # For most configuration files from conf-available/, which are
              # enabled or disabled at a global level, it is possible to
              # include a line for only one particular virtual host. For example the
              # following line enables the CGI configuration for this host only
              # after it has been globally disabled with "a2disconf".
              #Include conf-available/serve-cgi-bin.conf
      </VirtualHost>
      
      # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  5. He set up the oorklecom.conf file to look like this:
    1. <VirtualHost *:80>
              # The ServerName directive sets the request scheme, hostname and port that
              # the server uses to identify itself. This is used when creating
              # redirection URLs. In the context of virtual hosts, the ServerName
              # specifies what hostname must appear in the request's Host: header to
              # match this virtual host. For the default virtual host (this file) this
              # value is not decisive as it is used as a last resort host regardless.
              # However, you must set it for any further virtual host explicitly.
              ServerName www.oorkle.com
              ServerAlias oorkle.com
      
              ServerAdmin webmaster@localhost
              DocumentRoot /var/www/oorkle
      
              WSGIDaemonProcess oorklemobile threads=5
              WSGIScriptAlias / /var/www/oorkle/oorkle.py
      
              Alias /static /var/www/oorkle/static/
      
              # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
              # error, crit, alert, emerg.
              # It is also possible to configure the loglevel for particular
              # modules, e.g.
              #LogLevel info ssl:warn
      
              ErrorLog ${APACHE_LOG_DIR}/error.log
              CustomLog ${APACHE_LOG_DIR}/access.log combined
      
              # For most configuration files from conf-available/, which are
              # enabled or disabled at a global level, it is possible to
              # include a line for only one particular virtual host. For example the
              # following line enables the CGI configuration for this host only
              # after it has been globally disabled with "a2disconf".
              #Include conf-available/serve-cgi-bin.conf
      </VirtualHost>
      
      # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  6. The Web.py WSGI deployment docs mention the WSGIScriptAlias command, and he said that he'd already known about the WSGIDaemonProcess command from having worked with Flask.
    1. More info on WSGIDaemonProcess here.
  7. At that point I assume you can just restart the Apache server with /etc/init.d/apache2 restart (Source)