Web Server Upgrade

Introduction

SENS will be upgrading all web servers running the CentOS 6 Linux distribution. The new operating system on these servers will be Ubuntu 20.04, another distribution of Linux with wide usage and support.

As part of the upgrade, the following software tools used by web developers will change:

SoftwareOld VersionNew VersionResources
Apache Web Server2.2.152.4.41Upgrading to 2.4 from 2.2
MySQL5.5.62MariaDB 10.3Upgrading from MariaDB 5.5 to MariaDB 10.0
PHP5.3.37.4.3Migrating from PHP 5.6.x to PHP 7.0.x
Perl5.10.15.30.0Perl 5 version history

The following sections will note some of the common issues that have been found in upgrading web software to these new versions.

Contributions to this document are welcomed and appreciated, as they will help other web programmers.

Apache

There are not a lot of user-side changes that need to be made when upgrading from Apache 2.2 to 2.4, but what follows are some to keep in your awareness.

Basic Access Control

If you have a ".htaccess" file that uses directives such as:

Order allow,deny
Allow from all

They will need to change to something like:

Require all granted

See this document for more details.

Password Access Control

If you have a ".htaccess" file that uses directives to enable network address access and/or password access such as:

      Order deny,allow
      Deny from all
      Allow from 127.0.0.1 128.205. .buffalo.edu

      AuthName "Restricted Access"
      AuthType Basic
      AuthUserFile /some/path/to/.htusers
      Require valid-user
You will need to rewrite it as something like:
      <RequireAll>
         <RequireAny>
            Require local
            Require ip 128.205.0.0/16
            Require host .buffalo.edu
         </RequireAny>

         AuthName "Restricted Access"
         AuthType Basic
         AuthUserFile /some/path/to/.htusers
         Require valid-user
      </RequireAll>
You can let the old code coexist with the new code by using something like this:
   <IfVersion >= 2.3>
      <RequireAll>
         <RequireAny>
            Require local
            Require ip 128.205.0.0/16
            Require host .buffalo.edu
         </RequireAny>

         AuthName "Restricted Access"
         AuthType Basic
         AuthUserFile /some/path/to/.htusers
         Require valid-user
      </RequireAll>
   </IfVersion>
   <IfVersion < 2.3>
      Order deny,allow
      Deny from all
      Allow from 127.0.0.1 128.205. .buffalo.edu

      AuthName "Restricted Access"
      AuthType Basic
      AuthUserFile /some/path/to/.htusers
      Require valid-user
   </IfVersion>

MySQL/MariaDB

There are several documents here that may be helpful when upgrading from MySQL 5.5 to MariaDB 10.3 on this page: MariaDB versus MySQL - Features

In particular, these might be useful:

PHP

This section details some of the PHP code changes that need to be made when moving from a server with PHP 5.x to PHP 7.x.

ereg() and Relatives Have Been Removed

If you have something like:

if (ereg('myname', $input)) {

Replace it with:

if (preg_match('/myname/', $input)) {

Note the following in addition to replacing the function name "ereg" with "preg_match":

  • The pattern inside the quotes must be delimited by slash characters at the beginning and the end.
  • Any slash characters in the pattern must be escaped with a backslash. For example:
    ereg('hello/world', $input)
    
    becomes:
    preg_match('/hello\/world/', $input)
    

For eregi(), follow the same steps as above, but add the modifier "i" after the closing slash delimiter:

preg_match('/hello\/world/i', $input)

For ereg_replace(), replace it with preg_replace() and modify the pattern in the same way as described above.

A reference can be found here: https://www.php.net/manual/en/pcre.pattern.php

each() Has Been Removed

If you have something like:

while (list($key, $value) = each($input)) {

Replace it with:

foreach($input as $key => $value) {

The MySQL Extension Has Been Removed

There are two extensions that can be used in place of MySQL: MySQLi and PDO.

Here is a page that shows how to convert mysql*() functions to mysqli*() functions: https://dzone.com/articles/convert-mysql-to-mysqli

Deprecated: Methods with the same name as their class

Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP.

This can be fixed by changing code like this:

class FooBar {
  public function FooBar($something) {
  ...
  }
}

To something like this:

class FooBar {
  public function __construct($something) {
  ...
  }

  public function FooBar($something) {
    self::__construct($something);
  }
}

Perl

Perl tries hard to stay backward-compatible. However, there are many changes between 5.10 and 5.30, some of which are new features that may help with existing code.

CGI.pm

The module "CGI.pm" was removed in version 5.22. Programs using it will have to be recoded, or we can manually install this module if too many things break.

@INC

The include path, @INC, no longer contains "." (the current working directory) by default, for security reasons.

$*

$* is a global variable that causes multi-line matching to be used by default by regex operations. It is no longer available in newer versions of Perl - instead, the /m and /s regex flags should be used.