Is Gallery3 Compatible with PHP7? Yes!

Gallery3 (http://galleryproject.org/)  is a free easy-to-manage photo gallery web application. It managed the photos like the way you put them in a HDD, but allows you to make a linkage to the file with website assess. I've used it for many years as the photo storage places for blog. However, I faced some problems after the OS was upgraded from Ubuntu 16.04 Server to Ubuntu 18.04 Server, while the PHP was upgraded from PHP5 to PHP7 in Ubuntu 18.04. The gallery3 version I've installed was version 3.0.9.

After the OS was upgraded, Gallery3 service showed an error message of HTTP Error 500. I've tried to debug the reason with xdebug, but it didn't show any helpful messages. I tried to find out some information from Google, but it is said that someone said Gallery 3 is not compatible to PHP7. It was sad of the compatibility bad news.

However, I didn't give up, when there are too many photos was linked. It is a lot of works to upgrad it. After searched Good, I found this website Gallery The Revival where the revival version of 3.1.2 seems compatible with then new PHP7. But unfortunately after I forced overwrite all the files, the Gallery3 website still showed the same error. I've checked that the var/database.php uses mysqli as the connection. It is obviously not the reason of the error.

The setting looks no problem.
$config['default'] = array(
  'benchmark'     => false,
  'persistent'    => false,
  'connection'    => array(
    'type'     => 'mysqli',
    'user'     => 'admin',
    'pass'     => 'admin',
    'host'     => 'localhost',
    'port'     => false,
    'socket'   => false,
    'database' => 'gallery3',
    'params'   => null,
  ),
  'character_set' => 'utf8',
  'table_prefix'  => '',
  'object'        => true,
  'cache'         => false,
  'escape'        => true
);

So, it seems installing a clean 3.1.2 is the way to verify the compatibility issue.

In the installation page, I found the reasons immediately. It was just simply related to the uninstalled PHP modules! I was stupid! There are 3 modules need to be installed by the apt commands on Ubuntu 18.04:
sudo apt install php-gd
sudo apt install php-xml
sudo apt install php-mbstring

After restarted the apache2 server by the command:
sudo service apache2 restart

The Gallery 3.0.9 server worked perfect with PHP7! It was back. Very nice! :) I can upgrade it to 3.1.2 later :)

If you are using Gallery 3 in Ubuntu 20.04 server, you have to enable the setting short_open_tag. Find this line by editing /etc/php/7.X/apache2/php.ini and just simple modify this line to:
short_open_tag = On

沒有留言:

張貼留言