Daily Lucky Numbers:

SMF 2.0 - Enable PHP7.2+ Compatibility version 1.1

Started by Chen Zhen, April 22, 2018, 11:49:22 PM

Previous topic - Next topic

Chen Zhen

SMF 2.0 - Enable PHP7.2+ Compatibility version 1.1
Version 1.1 released April 22/2018.

This update includes many more code changes to facilitate PHP 7.2+ compatibility.

Changes to ../Sources/Subs-Db-sqlite.php to replace sqlite_create_function with modern standard.
ie. PDO::sqliteCreateFunction or SQLite3::createFunction

Please uninstall and delete v1.0 prior to using this version.
Report any issues with this modification in this thread.


Available to members only.



Hmmm, I didn't know there was a first version. LOL

So is this SMF 2.0.15 with updated code or a mod to be installed as usual?

EDIT: Nevermind, I answered my own question. LOL I'll check it out.


Ok, been playing with this and it doesn't work on my server for PHP 7.1 or 7.2. There may be something causing this on my server but not sure what yet...

Chen Zhen

Can you be more specific?

What do you mean it does not work?
Is your SMF installation functioning after installing this modification?
It should work for either PHP 7.1 or PHP 7.2.

It replaces code that would otherwise flag a warning for PHP 7.2.


Sorry, been a bit busy... What I get when I switch to php 7.1 or 7.2 is:

Service Unavailable
The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

Additionally, a 503 Service Unavailable error was encountered while trying to use an ErrorDocument to handle the request.

Chen Zhen

QuoteWhat I get when I switch to php 7.1 or 7.2 ...

That statement sounds like you attempted to enable (/switch to) PHP 7.2 after having a previous version working.

Please make sure you have PHP 7.2 installed and enabled then install SMF 2.0.15 with no modifications.
If everything is working fine at that point then install this mod and if you have issues at that point then report back.


That's exactly what I did. I did it that way because I was using Docskillz.com and it would screw up my forum when I switched to it. So, I'll try one of my domains i'm not using for this sometime this weekend and see how it goes...

Chen Zhen

If no php will work after switching to the newer version then that means you do not have it set up properly in Apache or Nginx.
You need specific modules and commands to run different versions of PHP at the same time.

You can use mod_php, cgi or fcgi.
mod_php will only let you run 1 version of php for all your domains.
cgi or fcgi are more secure (fcgi is recommended) and will let you run different versions of php for each virtual server domain.

When everything is installed properly you can use Virtualmin -> [domain] -> Server Configuration -> Website Options to opt FCGI mode.
Virtualmin -> [domain] -> Server Configuration -> PHP Versions will let you select PHP 7.2.5 (<- latest).

What OS are you using? Is it Centos 7?

Chen Zhen

Centos 7
Assuming you have yum installed...

install Webmin & Virtualmin:
cd /tmp
wget http://software.virtualmin.com/gpl/scripts/install.sh
/bin/sh install.sh
install PHP 7.2:
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-utils
yum-config-manager --enable remi-php72
yum update
yum search php72 | more
yum search php72 | egrep 'fpm|gd|mysql|memcache'
yum install php72-php-fpm php72-php-gd php72-php-json php72-php-mbstring php72-php-mysqlnd php72-php-xml php72-php-xmlrpc php72-php-opcache php72-php-pecl-zip php72-php-pecl-apcu curl libzip libzip5
yum install php72-php-common
php --version


Actually, I can use different PHP versions for different domains and was using WHM. The problem was I was using it in a test site in a subdirectory under docskillz. I'm just used to creating test sites there and wasn't thinking about using a separate domain. LOL I just needed to setup on off my domains that i'm not using for this. But i
m still thinking something is not setup right if php 7.2 makes my site not work at all...I'm missing something and will investigate.

Btw, I do have cent 7 minimal and yum is installed. I already have webmin installed on a vps but have not put any sites/domains on it yet until I get everything setup properly.


Thank you for the instructions as it saved me a ton of work installing each one in webmin manually. Everything is finally installed and I just need to make sure it's all configured properly. I had to do it 3 times because a command or dependency was missing and needed to be installed before continuing. But it finally worked and I've learned a few things in the process which is always a good thing. :)

Chen Zhen

No problem. I've had some experience with installing newer PHP versions where things I needed were not installed.
I've kept the above install notes so that I can do it quickly each time I reinstall an OS or move to a new host.
Some of the above modules may be disabled by default in PHP in which case you need to enable them in php.ini.
For your multiple virtual servers they may be configured in apache or nginx to use their own specific php.ini file.
There will be a master php.ini file but it won't use that one if configured to use another.


In WHM there is a master php.ini and you can can use individual ones.

Tonight I've been playing with webmin/virtualmin. I just need to get let's encrypt working properly then I can set the site up.

Getting a little tired and hungry so I'll eat and rest and come back to this in a few hours...


Chen Zhen

Install certbot to use Letsencrypt.

Assuming you are using apache:
yum install certbot-apache
certbot --apache certonly

Then you need to tell it what domains you want to use it for and where to put the files:

example.com located in a site directory named example
also if the host and fqdn are set up properly it will be something like: example.example.com as well
certbot certonly --webroot -w /home/example/public_html/ -d example.com -d www.example.com -d example.example.com

It needs to be renewed every 90 days but I believe letsencrypt will let you renew every 30 days.
You can set a cron job at the first of every month with the following command:
certbot renew

... which will renew all you certificates that you entered via certbot

It will tell you where it put the certificate files.. make sure you note the directory.
Then you need to configure apache or nginx to use those files in apache/nginx configuration for each wesbite.