OpenMediaVault in current version 4.1.12 is based on Debian Stretch which uses (unfortunately) PHP 7.0 as default. If you want to upgrade the version of PHP to version 7.2, the following tutorial is what you are looking for. Let’s play…
1. Add PHP 7.2 repository
Personally, I use SURY repositories. Add SURY repo to yours.
apt-get -y install apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
apt-get update
apt-get install php7.2-cli php7.2-fpm
And voila! PHP7.2 is now our default CLI interpreter. Let’s check.
root@omv:/home# php -v
PHP 7.2.11-2+0~20181015120801.9+stretch~1.gbp8105e0 (cli) (built: Oct 15 2018 12:08:03) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.11-2+0~20181015120801.9+stretch~1.gbp8105e0, Copyright (c) 1999-2018, by Zend Technologies
2. Config build-in OMV Nginx
Because I use build-in Nginx service in my OMV, we have to not only install FPM but also override default configuration using GUI.
Open OMV control panel. Go to Services on the left sidebar and click Nginx section. Edit your server, and add section in config file.
location ^~ / {
index index.php indec.html;
try_files $uri $uri/ =404;
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass "unix:/var/run/php/php7.2-fpm.sock";
}
}
Adding a caret and tilde (^~) to your location directives tells NGINX, if it matches a particular string, to stop searching for more specific matches and use the directives here instead. Other than that, these directives work like the literal string matches in the first group. Even if there’s a more specific match later, if a request matches one of these directives, the settings here will be used. See more cases in official documentation.
Now we can check new php fpm engine. Create new file index.php in your root directory defined in General section in Nginx server configuration.
<?php
echo phpversion();
Go to browser and open page http(s)://OMV_IP. You should see something like this
7.2.11-2+0~20181015120801.9+stretch~1.gbp8105e0
Notice: This changes work only for our defined locations, not for OpenMediaVault GUI.
Useful and worked – Thanks for this 🙂
About what?
Thanks
How to learn about Nginx as a beginner?
How do I make this work if my config file already has other options set (for nginx). If I use ^~ / it will override the other sections and nextcloud won’t start.
when i am follow the instruction using this text on Nginx configuration file below . It will show the error on NExtcloud page
Internal Server Error
The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.
{code}
Open OMV control panel. Go to Services on the left sidebar and click Nginx section. Edit your server, and add section in config file.
location ^~ / {
index index.php indec.html;
try_files $uri $uri/ =404;
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass “unix:/var/run/php/php7.2-fpm.sock”;
}
}
{/code}
thanks for coding