FAMP (for Piwigo): PHP extension "mysqli" is not loaded

carrabta

Dabbler
Joined
Jan 12, 2018
Messages
10
Hi all,
not too sure where best to post this thread, so I though I'd try this one....
I'm trying to install Piwigo which requires an operational FAMP. I've largely followed the excellent guide by Samuel Dowling (https://www.samueldowling.com/2020/...n-freenas-iocage-jail-with-hardened-security/) on installing Nextcloud to get the FAMP base running.
It all looks rahter operational (I can access the server and load the PHP info webpage page to demonstrate that PHP is also operational).
So next step is, like for NextCloud, to run, via the webpage a script to configure Piwigo. on a browser, I type 192.168.1.80/ => it finds it has to access 192.168.1.80/install.php, but displays a page saying :
Piwigo encountered a non recoverable error
PHP extension "mysqli" is not loaded

Mysqli is installed.
php -r 'phpinfo();' |grep mysqli gives the following output:
Code:
/usr/local/etc/php/ext-20-mysqli.ini,
mysqli
mysqli.allow_local_infile => Off => Off
mysqli.allow_persistent => On => On
mysqli.default_host => no value => no value
mysqli.default_port => 3306 => 3306
mysqli.default_pw => no value => no value
mysqli.default_socket => no value => no value
mysqli.default_user => no value => no value
mysqli.max_links => Unlimited => Unlimited
mysqli.max_persistent => Unlimited => Unlimited
mysqli.reconnect => Off => Off
mysqli.rollback_on_cached_plink => Off => Off
API Extensions => mysqli,pdo_mysql
root@Piwigo:/ # php -v
PHP 7.2.34 (cli) (built: Oct 10 2020 01:11:56) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.34, Copyright (c) 1999-2018, by Zend Technologies


php -m gives the following output:
Code:
[PHP Modules]
apcu
bcmath
bz2
Core
ctype
curl
date
dom
exif
fileinfo
filter
gd
gmp
hash
iconv
imagick
intl
json
ldap
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
posix
redis
Reflection
session
SimpleXML
SPL
standard
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache


I can see 'mysqli' appears and is loaded, so not sure what is missing for Piwigo.....
Could anybody give me a hint as to where to look ?

Many thanks in advance !
(Config: FreeNAS 11.2. All above installed in a dedicated jail)
 

AfroUSA

Dabbler
Joined
Mar 27, 2017
Messages
28
Hi there,
After few days of seting up my Piwigo Photo Server with over 58k photos, I have made this easy and working guide on how to set up Piwigo on TrueNAS in a jail with [FAMP] Nginx, MariaDB, PHP [tested on Jail - Release 11.3]. Hope this will help.

You all are welcome to post improvements and corrections ;)
______________________________________________________________________________________________________

Prepare the Environment

Add new jail in TrueNAS, name piwigo, release 11.3.
Check DHCP in Configure Networking and click Submit to build your new jail.

Now SSH to your new jail or use Shell in TrueNAS.

Before installation of the components, make sure everything is up to date using the following command:
pkg update -f && pkg upgrade

Install a couple dependencies:
pkg install git ImageMagick7-nox11

Create the piwigo user:
pw user add -n piwigo -s /sbin/nologin -c "Piwigo"
______________________________________________________________________________________________________

Install Nginx

Starting by installing small and robust WWW server:
pkg install nginx

Start and enable nginx at boot:
echo 'nginx_enable="YES"' >> /etc/rc.conf
service nginx start

Create a configuration directory to make managing individual server blocks easier
mkdir /usr/local/etc/nginx/conf.d

Edit the main nginx config file:
vi /usr/local/etc/nginx/nginx.conf

And strip down the config file and add the include statement at the end to make it easier to handle various server blocks:
Code:
load_module /usr/local/libexec/nginx/ngx_mail_module.so;
    load_module /usr/local/libexec/nginx/ngx_stream_module.so;

   worker_processes  1;
   error_log  /var/log/nginx-error.log;

   events {
      worker_connections  1024;
   }

   http {
      include       mime.types;
      default_type  application/octet-stream;
      sendfile        on;
      keepalive_timeout  65;

      # Load config files from the /etc/nginx/conf.d directory
      include /usr/local/etc/nginx/conf.d/*.conf;
   }

______________________________________________________________________________________________________

Install MySQL Server

Start by installing the mariadb105-server and mariadb105-client packages:
pkg install mariadb105-{server,client}

Copy a base MySQL configuration to use:
cp /usr/local/etc/mysql/my-small.cnf /usr/local/etc/mysql/my.cnf

Enable and start mysql at boot:
echo 'mysql_enable="YES"' >> /etc/rc.conf
service mysql-server start

Prepare the database for use by running the secure installation:
mysql_secure_installation
NOTE: Choose a strong root password and answer yes to all questions.

Create Databases and Users
Login to MySQL and create appropriate databases and users.
mysql -u root -p

and run the following SQL queries to create the piwigodb database and piwigouser user:[/ICODE]
CREATE DATABASE piwigodb CHARACTER SET utf8;
CREATE USER 'piwigouser'@'localhost' IDENTIFIED BY 'SuperSecretPassword';
GRANT ALL PRIVILEGES ON piwigodb.* TO 'piwigouser'@'localhost';
FLUSH PRIVILEGES;
quit
______________________________________________________________________________________________________

Install PHP

Install PHP 7.3 and a few extensions:
pkg install php73 php73-{exif,filter,gd,hash,mbstring,mysqli,json,session,zip,zlib}

Configure the default PHP settings
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Edit the php config file:
vi /usr/local/etc/php.ini

And make sure the following values are set:
Code:
date.timezone = "Europe/London"
    max_execution_time = 200 ;I set this to 300
    max_input_time = 60 ;I set this to 300
    post_max_size = 100M
    upload_max_filesize = 100M
    memory_limit = 256M ;I set this to 512M with 16GB ECC RAM


Create a directory for the php-fpm configs:
mkdir /usr/local/etc/php-fpm.d

Edit the php-fpm config file:
vi /usr/local/etc/php-fpm.conf

Make the following changes:
include=/usr/local/etc/php-fpm.d/*.conf

Enable PHP-FPM at boot:
echo 'php_fpm_enable="YES"' >> /etc/rc.conf

Restart nginx:
service nginx restart
______________________________________________________________________________________________________

Install Piwigo

Download Piwigo version 11.x from GitHub:
cd /usr/local/www
git clone -b 11.x https://github.com/Piwigo/Piwigo.git

Create an piwigo.example.com server block config file:
vi /usr/local/etc/nginx/conf.d/piwigo.example.com.conf

Add the following:
Code:
upstream piwigo-handler {
    server unix:/var/run/piwigo.example.com-php-fpm.sock;
}

server {
  listen 80;
  server_name piwigo.example.com;
  root /usr/local/www/Piwigo/;
  index index.html index.php;

  # Set size for max uploaded content
  client_max_body_size 0;
  client_header_timeout 30m;
  client_body_timeout 30m;

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
  }

  location ~ ^/(?:CHANGELOG\.md|config|README.md|.git){
    deny all;
  }

  location / {
    try_files $uri $uri/ =404;
  }

  location ~ \.php(?:$|/) {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_pass piwigo-handler;
            fastcgi_intercept_errors on;
            proxy_connect_timeout 600s;
            proxy_send_timeout 600s;
            proxy_read_timeout 600s;
            fastcgi_send_timeout 600s;
            fastcgi_read_timeout 600s;
  }
}


Create the piwigo php-fpm pool config file:
vi /usr/local/etc/php-fpm.d/piwigo.example.com.conf

And add the following:
Code:
[piwigo.example.com]
    user = piwigo
    group = www
    listen = /var/run/piwigo.example.com-php-fpm.sock
    listen.owner = piwigo
    listen.group = www
    pm = dynamic
    pm.max_children = 35
    pm.start_servers = 15
    pm.min_spare_servers = 15
    pm.max_spare_servers = 20


Edit the WWW config file:
vi /usr/local/etc/php-fpm.d/www.conf

And make sure the following value is without semicolon and is set to 300:
Code:
request_terminate_timeout = 300


Change the ownership of the piwigo directory:
chown -R piwigo:www /usr/local/www/Piwigo

Restart nginx and start php-fpm:
service nginx restart
service php-fpm start

Now open up a web browser and go to http://your_Jail_IP_address to finish the setup process.
Ennter database details (If you will get an error with database, try to change localhost to 127.0.0.1), user name and password to your database. Than set up new user to login to Piwigo.
After saving your settings, page may go blank, then put your jail IP in the address again to go to the start page of Piwigo.

When all is working, you can set the static IP address in - TrueNAS - Jails - piwigo - edit - uncheck DHCP,
set IP address, than IP of your router and mask [in my case 225.225.225.0 will be 24].

I have photos folder on my second Pool from where I hold jails. So I have set Mount Points for Piwigo Jail, and pointed them to gallery folder, which I have create.
For me it looks like this:
/mnt/POOL1/Photos/MyFirstPhotos -> /mnt/POOL2/iocage/jails/piwigo/root/usr/local/www/Piwigo/galleries/MyFirstPhotos
______________________________________________________________________________________________________
Resources

https://project.altservice.com/issues/861
http://piwigo.org/doc/doku.php
http://piwigo.org/doc/doku.php?id=user_ … stallation
http://piwigo.org/basics/installation_manual
______________________________________________________________________________________________________

Piwigo 11.3.0
Operating system: FreeBSD
System: HP MicroServer Gen8, Xeon E3-1220L V2, 16GB RAM ECC
PHP: 7.3.27 (Show info) [2021-02-13 14:39:51]
MySQL: 5.5.5-10.5.8-MariaDB [2021-02-13 14:39:51]
Graphics Library: External ImageMagick 7.0.10-24
 
Last edited:
Top