Change PHP version of default virtual host

Firstly, my compliments to the designers of Nethserver! It is simply amazing and works almost out the box! So easy to configure, set up and use.
I do have a first issue though, I have a web application that needs PHP version 5.6 or higher, so I installed PHP 8.0 on a new Apache virtual host. However, the Apache default virtual host is still utilizing PHP 5.4. How do I change this please or remove the default virtual host?

not possible, use php-fpm with a virtulhost, eventually make a custom configuration to use php-fpm in /var/www/html

I’m sorry but your answer makes no sense to me, I do not understand your answer at all. I am new to Nethserver so if you could please explain what you mean?

no problem, in short if you want to break your system then you can go to install a major new php version.

Because we want a stable version we use php-fpm, a php version running behind a systemd service. Hence we do not modify the PHP version for the whole system but we use only inside a virtualhost

Ok, I still am lost. I installed PHP version 8.0 from the new virtual host setup option in Cockpit, so I’m not sure what you mean by “breaking the system”. Also, what exactly is php-fpm? I cannot find any major documentation online on this?

You know, never mind. I will simply not use the application I wanted. The link you sent to me is too complicated. As explained I am very new to this, so I do not even understand what is explained there. Thank you anyway

1 Like

you could probably use your custom application inside a virtualhost if it is a web application, or if it is a CLI application, then I suppose you could still use it

yum install nethserver-remi-php80-php-fpm.noarch

then use in the CLI
php80 -v

or from my repository stephdl

yum install nethserver-remi-php81-php-fpm.noarch --enablerepo=stephdl

Regarding your first answer, it is a web application and it IS IN A VIRTUAL HOST, one that I created from Cockpit, using “Create a Virtual Host” and that is also where I installed PHP 8.0 from. So what I don’t understand is why my application still sees PHP 5.4. This is actually my issue, sir. If I run phpinfo.php from either directory, either /var/www/html, or from the new virtual host directory /var/lib/nethserver/vhost/8d15d07d4a7a726/, it gives me the same version of PHP, 5.4

please use the command above and you will see that to use PHP80 you need to use another binary

Well, I ran the above and it says "Package nethserver-remi-php80-php-fpm-1.0.0-1.ns7.noarch already installed and latest version
Nothing to do
[root@server ~]#

This is how PHP-FPM works, you do not modify the default PHP version, you just install how many other versions you need. On /var/www/html it will be always PHP54 except if you customize your installation.

Ok, can you please explain how to customize my installation please?

1 Like

You need to adapt the tcp port of the tcp port of the relevant php-fpm version you use

For php80 it is 9008 tcp port

I do not have any reverse proxy settings and how would I share my virtual host settings please?

To output your virtual host settings on command line:

db vhosts show

I can’t reproduce. If I set PHP8 in the virtual host and then browse to https://<virtualhostname>/phpinfo.php I get the right PHP version. To browse to the virtualhost you need to browse by name not by IP.

How do you run phpinfo.php? Command line or browser?


Well, there I also have a problem, I cannot browse by name internally, only by IP. I run phpinfo.php through a browser

That’s the problem. If you go by IP you go to /var/www/html/ which has PHP5.4 by default.

If your clients use NethServer as DNS server you could add an alias name. If you use another DNS server then you could add a DNS entry for the virtualhost name pointing to the NethServer.

1 Like