title: multiple apache ports for mediawiki 1.27.0
body: <p>I've been running Mediawiki for quite a few years. My server operates two ports: port <code>80</code> for the active site and port <code>81</code> for the test site, used when upgrading the MW software before 'going live'. I've not had any issues with this setup until recently. Both ports have worked fine, including an early test of MW 1.27 Alpha on port 81. Now that I'm trying to install MW 1.27.0 (Stable) I'm having issues.</p>
  
  <p>For some reason I can only get http served on one port. If I restart Apache either port will deliver content, but only that port and it's always the first port I visit. The other will then give some PHP error. For example: Restart Apache and go to the site on port 81. Works fine, but the port <code>80</code> site gives a PHP error. Change nothing, but restart Apache again and go to the port 80 site; works fine, but port 81 site now gives a PHP error. Either site gives a different PHP error, but always the same error.</p>
  
  <p>This is obviously something to do with my Apache setup, but I have no idea what. It's worked in the past and has not changed. There have been no changes/updates to the OS or Apache application files. Ports are defined in <code>apache2/ports.conf</code> with both sites defined in separate <code>VirtualHosts</code> conf files.</p>
  
  <p>Both sites are enabled and the config files have been read by Apache (<code>/usr/sbin/apache2 -S</code>).</p>
  
  <p><code>netstat -lep --tcp</code> shows that port <code>80</code> and <code>81</code> are being actively listened to, but both these facts are somewhat irrelevant as I have proved that both ports are able to serve, just not at the same time. I've checked the apache error log file, but there is only the PHP error recorded in there.</p>
  
  <p>I should add that the server has a third site running off another port (8083), which works just fine. All three configs are comparable, differing only in any specified paths (such as <code>DocumentRoot</code>) and port number. </p>
  
  <p>Anyone have any suggestions?</p>
  
  <p><strong>Code:</strong></p>
  
  <p><strong>ports.conf:</strong></p>
  
  <pre><code># If you just change the port or add more ports here, you will likely also
  # have to change the VirtualHost statement in
  # /etc/apache2/sites-enabled/000-default.conf
  
  Listen 0.0.0.0:80
  Listen 0.0.0.0:81
  Listen 0.0.0.0:8083
  Listen 0.0.0.0:8080
  
  &lt;IfModule ssl_module&gt;
      Listen 443
  &lt;/IfModule&gt;
  
  &lt;IfModule mod_gnutls.c&gt;
      Listen 443
  &lt;/IfModule&gt;
  
  # vim: syntax=apache ts=4 sw=4 sts=4 sr noet
  </code></pre>
  
  <p><strong>wiki.conf:</strong>
  NB: ServerAdmin variable has been altered for business/security reasons.</p>
  
  <pre><code>#Variable to store the top level server name
  Define TL_ServerName lgsim
  
  &lt;VirtualHost *:80&gt;
      # 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 abc@myDomain.com
      DocumentRoot /var/www/wiki
  
      ServerName ${TL_ServerName}
  #   ServerName 44.80.10.2
      ServerAlias ${TL_ServerName}
      DirectoryIndex index.php lgsim_redirect.html
  
      Alias /w /var/www/wiki
      Alias /wiki /var/www/wiki/index.php
      Alias /error_html/ /var/www/html/error_html/
      Alias /addSearch/ /var/www/html/addSearch/
  
      &lt;Directory "/var/www/wiki"&gt;
          Options Indexes FollowSymLinks Includes ExecCGI
          AllowOverride All
          Order allow,deny
          Allow from all
      &lt;/Directory&gt;
  
      # For security, deny access to the MW config directory.
      # Comment this out if you're running an upgrade.
      &lt;Directory "/var/www/wiki/mw-config"&gt;
          Order allow,deny
          Deny from all
      &lt;/Directory&gt;
  
      &lt;Directory "/var/www/wiki/images"&gt;
          Options -Indexes
      &lt;/Directory&gt;
  
      ErrorDocument 404 /error_html/custom404.html
  
      #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
  &lt;/VirtualHost&gt;
  
  # Template for the virtual host alias currently in use
  &lt;Macro VHost $name $redirectURL&gt;
  &lt;VirtualHost *:80&gt;
      DocumentRoot "/var/www/wiki"
      ServerName $name
  
      Redirect permanent / $redirectURL
  &lt;/VirtualHost&gt;
  &lt;/Macro&gt;
  
  #
  #Landing Gear Virtual Hosts
  #
  Use VHost LG http://${TL_ServerName}/wiki/LG:Main_Page
  Use VHost LGSIM http://${TL_ServerName}/wiki/LGSIM:Main_Page
  Use VHost LGMS http://${TL_ServerName}/wiki/LGMS:Main_Page
  
  UndefMacro VHost
  </code></pre>
  
  <p><strong>newWiki.conf:</strong></p>
  
  <pre><code>#Variable to store the top level server name
  Define TL_ServerName lgsim
  
  &lt;VirtualHost *:81&gt;
      ServerAdmin abc@myDomain.com
      DocumentRoot /var/www/wiki_test
  
  #   ServerName 44.80.10.2
      ServerName ${TL_ServerName}
      ServerAlias ${TL_ServerName}
      DirectoryIndex index.php # lgsim_redirect.html
  
      Alias /w /var/www/wiki_test
      Alias /wiki /var/www/wiki_test/index.php
      Alias /error_html/ /var/www/html/error_html/
      Alias /addSearch/ /var/www/html/addSearch/
  
      &lt;Directory "/var/www/wiki_test"&gt;
          Options Indexes FollowSymLinks Includes ExecCGI
          AllowOverride All
          Order allow,deny
          Allow from all
      &lt;/Directory&gt;
  
      # For security, deny access to the MW config directory.
      # Comment this out if you're running an upgrade.
  #   &lt;Directory "/var/www/wiki_test/mw-config"&gt;
  #       Order allow,deny
  #       Deny from all
  #   &lt;/Directory&gt;
  
      &lt;Directory "/var/www/wiki_test/images"&gt;
          Options -Indexes
      &lt;/Directory&gt;
  
      ErrorDocument 404 /error_html/custom404.html
  
      ErrorLog ${APACHE_LOG_DIR}/wiki_test_error.log
      CustomLog ${APACHE_LOG_DIR}/wiki_test_access.log combined
  &lt;/VirtualHost&gt;
  </code></pre>