Skip to main content


Where does /usr/bin/php actually point to, by whom is ist accessed (www-data?) and is there a way to change the reference it points to


This is entirely up to your operation system configuration. You can usually install multiple versions of (in this case PHP) alongside on the server that are called on /usr/bin/phpX.YZ (assuming /usr/bin being the place on your OS for executeables), but "the main" version should also be available at /usr/bin/php so that stuff that does not care for the exact version finds something.

The path /etc/php/8.1/fpm looks like pointing to the configuration files of PHP-FPM 8.1 but not to an executeable. That it looks quite right might be, that the default version that PHP links to at your system is currently version 8.1.

On Debian this is managed by the Alternatives systems.

@utopiArte while Ubuntu is Debian based and as such also uses the alternatives system, there are some differences (e.g. the snap packages you saw) - please read up the Ubuntu documentation for setting up a web server.

Regarding the differences of php and php-fpm see e.g. here. It depends on how you set up the server which package you need.

I thing there is a newer version installed and no package in the APD package tree explicitly wants that version of php.

> APD package tree

A quick search was a littel bit confusing, lots of APD's out there, I guess that means:
APT package dependency tree ?

In other words, there is no reference registered in APT of the instalation for these packages (anymore).
Gone have to dig into that a little bit more.

https://askubuntu.com/questions/402589/the-following-packages-were-automatically-installed-and-are-no-longer-required

If you want to suppress the message and keep those packages installed (perhaps you're now using them), use:
apt-get install <package-name>


@Tobias

@utopiArte yes it is APT - I will just stop trying to help if I'm not on my computer but online with the mobile. Which means I will likely stop helping at all because of my time constrains at the moment.
update for Mrs. Dodo:
Check if the installed php versions where actualy activated:
a2enmod phpX.XReplace “X.X” with the version number of the old PHP module you want to disable. For example, to disable PHP 7.2, you would run:
sudo a2dismod php7.2
Next, enable the new PHP module by running the following command:
sudo a2enmod phpX.X
Replace “X.X” with the version number of the new PHP module you want to enable. For example, to enable PHP 7.4, you would run:
sudo a2enmod php7.4
Finally, restart the Apache server to apply the changes:
sudo service apache2 restart

Notes about Alternatives systems:

https://gist.github.com/anwas/4873797fd515c69e6f05d9e6d2880e01
# For command line
## It's important to note that there are four important PHP commands you should update if changing the default versions.
## These include php, php-config, phpdbg and phpize. So, to fully migrate to PHP 8.0, execute the following:
sudo update-alternatives --set php /usr/bin/php8.0
sudo update-alternatives --set php-config /usr/bin/php-config8.0
sudo update-alternatives --set phpdbg /usr/bin/phpdbg8.0
sudo update-alternatives --set phpize /usr/bin/phpize8.0

sudo update-alternatives --set phar /usr/bin/phar8.0
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.0

if you get a working PHP with simply calling php on the commandline, you can then use which php on the same commandline to find out, which is the path used pointing to your PHP executable.
It then does not matter, if that is a symlink or how often it is redirected, you can simply use the result of the which command.

@M.Scheriau

When I enter in the console I just get a new blank line:
root@VPShosting:~# php

Same happens if I enter than
root@VPShosting:~# which php

The same is true for doing this inside the friendica folder.

Does that just mean that "I don't get a working PHP with simply calling php on the commandline" or should I worry?

Again, this is most likely related to the -fpm install and I'll have to dig into that.

@utopiArte do you have the php-cli package installed on your system? It is the package that makes PHP available on the command line. This is needed for the background process of Friendica. https://packages.ubuntu.com/search?keywords=php-cli

Tobias wrote:

do you have the php-cli package installed on your system?

Apparently yes @Tobias.

CLI wrote:

php-cli is already the newest version (2:8.3+95+ubuntu22.04.1+deb.sury.org+1)


btw, right now the instance(s) are working fine, so no worries, even more if you have time costrains.
Im working around this to get it in my head and right now I'm more like in a floating state of mind letting the information settle down. Once that "worst part" is over I most likely will bother with pimping up very very old instances, like 3.4.3 old instances, so you better hide somewhere and put this account into some temporary ignore and cool down mode.
😀

@M.Scheriau

Just now the command:
root@VPShosting:~# which php
resulted in:

/usr/bin/php

root@VPShosting:~# php -v

PHP 8.1.31 (cli) (built: Nov 21 2024 13:10:15) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.31, Copyright (c) Zend Technologies
with Zend OPcache v8.1.31, Copyright (c), by Zend Technologies

That's actually a little bit unexpected as the last setting set, if I remember well, was the one referenced in one of the comments bellow from two days ago adjusting default to 8.4:
rootname@VPShosting:~# update-alternatives --set php /usr/bin/php8.4

Maybe some settings were changed while installing the castopod instances, a installation that ultimately worked well suddenly and I actually attributed to the fact that 8.4 was activated.

In other words .. still digging into this and working on the best settings for each instance and software and which default version would be best.

rootname@VPShosting:~# ls -l /etc/apache2/mods-enabled/

fcgid.conf -> ../mods-available/fcgid.conf
fcgid.load -> ../mods-available/fcgid.load
Summary. Any program assigned to the handler fcgid-script is processed using the FastCGI protocol; mod_fcgid starts a sufficient number instances of the program to handle concurrent requests, and these programs remain running to handle further incoming requests.


php8.1.conf -> ../mods-available/php8.1.conf
php8.1.load -> ../mods-available/php8.1.load
LoadModule php_module /usr/lib/apache2/modules/libphp8.1.so


@utopiArte the Apache 2 module is not affected by the PHP version that you call on the CLI. That CLI executable points to the PHP executeable of your (alternatives) choice. So php --version should give you different versions depending on the version you selected with the alternatives system.

The PHP version used by Apache2 or as fpm is set in the Apache2 configuration files.

A brief and very fast tutorial on debian ubuntu 20.04lts php and php-fpm.

Once more or less worked thru the text's here, listening to this should help assimiliating the whole story.

One of the take aways from this right now is that phpX.Y-fpm [=> -fpm] has nothing to do with the extra ppa to integrate more php versions but is at least part of ubuntu. A recheck if it's part of debian itself is still on Dodo's list, as well how to handle this on a standard debian server as ppa is a ubuntu thing (?), because most likely there is a pure debian way to achieve the same.

One of the take aways from this right now is that phpX.Y-fpm [=> -fpm] has nothing to do with the extra ppa to integrate more php versions but is at least part of ubuntu.

add-apt-repository ppa:ondrej/php

https://host4geeks.com/blog/how-to-change-default-php-version-in-ubuntu-a-step-by-step-guide/
This command adds the “ondrej/php” repository, which contains the latest PHP versions. After running the command, you’ll need to update your system’s package list:

Maybe the need for the ppa is only about the latest newest php versions and not the actual and older ones?
🤔

A video that explains, apparently on pure debian, that -fpm -> FastCGI actually externalizes the PHP processes from the apache server and also sums up how to set it up correctly.

So on one hand there is installing different PHP versions, in that regard the -fpm PPA ppa:ondrej/php adds access to newer PHP versions that are still in development branch and than there is the fact that php-fpm itself at the same time is a specific independent version of PHP that separates the PHP handling and processes from the apache server and gives more options to tweak and speed up the PHP processes.

The digitalocean tutorial used inicially displayed two entries as variation of the standard entry in a sitedomain.registry.conf file robably only the second is/was neccessary fior the correct setup of php, this has to be checked again, for the friendica sites and the castopod site.

Entry that actually (probably) isn't about the php setting:

 <Directory /var/www/site1.your_domain>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
     </Directory>

Entry that affects the php entry:

    <FilesMatch \.php$>
        # From the Apache version 2.4.10 and above, use the SetHandler to run PHP as a fastCGI process server
         SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost"
    </FilesMatch>

@TupambAdminOrg [2024.03] you need two PHP's - or better say two ways to call it. The one that is called by the webserver directly (this is either php-fpm or the mod_php in case of Apache2 servers) and the other one in the terminal PHP that is called by the background job. Both should have the same version.

The one in the Friendica config is the client version for the background jobs. That will be used for the long running background processes. In the web server config files you define the one used by the foreground processes.