The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,482 other followers

Apache2 on openSUSE 12.x: some notes

Posted by jpluimers on 2014/04/24

Getting Apache configured on a *nix installation like openSUSE installation is always a bit of a challenge.

A few things I observed:

  • The “Initializing HTTP Server Configuration” part of YaST -> “Network Services” -> “HTTP Server” can take a long time to load (often minutes or longer).
    Same for writing back the configuration settings.
  • Configuration is stored in the directory tree under “/etc/apache2” where all “*.conf” will be loaded
  • If you change or add any “*.conf” file there, be sure to restart apache:
    – first perform a “rcapache2 configtest”, then a “rcapache2 extreme-configtest”
    – then perform a “rcapache2 probe” (to check if a restart actually is needed: note that sometimes this things no reload is needed, even if .conf files have been changed for virtual servers)
    – finally perform a “rcapache2 graceful”, “rcapache2 reload”, “rcapache2 restart-graceful”, or “rcapache2 restart”
  • After each configuration change, test these from your web-browser:
    – root directory
    – files in root directory
    – sub directory
    – files in sub-directory
    – script directory
    – files in script directory
  • Default configuration has “Options None”, and overrides Options in the Virtual Hosts configurations.
  • “Options None” means that if a directory does not contain an “Index” document like “index.html”, it will not generate a directory listing, and generate a http 403 error forbidden.
  • Default configuration of a normal host is that it has an “index.html” (basically containing “It Works!”
  • Default configuration of a virtual host does not contain an index.html, so it will generate a 403.
  • When enabling a virtual host, it overrules the normal host configuration.
  • The first found virtual host will match if none of the others match. It can make sense to add a “00-default” entry that has either a simple “index.html” indicating is default, or no documents at all (and generate a 403).
    There cannot be underscores in the server name, and it has to contain at least one dot, so on my system,
    – I have named it “00-default.servername”
    – It serves from “/srv/www/vhosts/00-default.servername/htdocs”
    – Created an initial “/srv/www/vhosts/00-default.servername/htdocs/index.html”
  • Note I use the “htdocs” directory, as it is a wise thing to split your DocumentRoot from any applications as explained with the WSGIScriptAlias: if you ever have a configuration error, your source code won’t be on the streets.
  • A DocumentRoot, an Alias and a WSGIScriptAlias directive need a Directory directive covering the directory that specified the access allowed for the physical path of the DocumentRoot/Alias/WSGIScriptAlias
    I usually have one Directory directive per DocumentRoot/Alias/WSGIScriptAlias directive
  • If you ever get this error message:
    Job failed. See system journal and 'systemctl status' for details.
    while performing rcapache2 restart or rcapache2 start, then look into /var/log/messages for any error messages.
    You probably put a wrong key/value somewhere in your /etc/apache2/vhosts.d/*.conf.
  • It helps to add these next to your ServerName in your virtual host config files:
    ServerAlias *

    That way, you can server multiple host names and subdomains with one virtual host.

  • ServerAlias is not a value in the YaST “Selected option” dropdown combobox when adding an Option.
    But you can enter it by typing ServerAlias in the edit portion of the combobox.
  • httpd2 -S
    lists the configured virtual hosts (including an indication of the default one)
  • httpd2 -M
    lists the configured server modules
  • DO NOT EVER use the “Set as Default” for a virtual host. See Apache Web Server on SLES why:

    Note: Within the Host tab there is a button to “Set as Default” the host that is highlighted. Be warned that this will override any configuration settings that are in the “Main Host” tab and this is probably not what you want. This can actually affect all of your virtual hosts and is very difficult to reverse. I highly recommend that you do not use this button – ever.

  • If you get a 404 error running Python scripts using WSGI, and your “/var/log/apache2/error_log” file contains “does not contain WSGI application ‘application’.”, then read  Setting up Python with WSGI on Apache for a directory.
  • Be aware of correct Directory directives, otherwise you get an Apache Error: Client denied by server configuration in your /var/log/apache2/error_log file.

snap:~/bin # httpd2 -S
VirtualHost configuration:
wildcard NameVirtualHosts and default servers:
: is a NameVirtualHost
default server 00-default.snap (/etc/apache2/vhosts.d/00-default.snap.conf:1)
port * namevhost 00-default.snap (/etc/apache2/vhosts.d/00-default.snap.conf:1)
port * namevhost (/etc/apache2/vhosts.d/
Syntax OK

Links used to get everything working:


2 Responses to “Apache2 on openSUSE 12.x: some notes”

  1. jefsnare said

    Interesting notes Jeroen, it’s a lot of configuration on this platform (openSUSE), but what’s the reason you didn’t choose for a more compliant version like Ubuntu?

    • jpluimers said

      Because I’ve been running SuSE for most of my Linux life. I especially like their Deutsche Gründlichkeit with respect to security issues. That has saved me numerous times. For a future installation, I might actually consider nginx over Apache.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: