I just try to switch from php7.4 to php8.2 changing .httaccess like this:
DirectoryIndex index.php
AddHandler application/x-httpd-php82 .php
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
I am not succeeding. This is output of
sudo update-alternatives --config php
.htaccess is stored in same folder info.php is stored. Why is php8.2 not version being used for? I want to switch between different php versions depending on code being used for different subdomains. This is output of info.php:
Here is an extraction of Vhost:
<Directory /var/www/testshop.leitner-sales.at>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
2
Answers
T.Miles, your solution suggested throws out 500 Server Error. In /var/log/apache2/error.log will be deposited following error message
I fixed it fireing following commands:
but it din't change output of info.php Just PHP version 7.4.33 is using, not php version 8.2! Ur solution doesn't throw out error, but it seems to be ineffective. I implemented ur suggestion in VHost
/etc/apache2/sites-available/shop.conf
I noticed, php8.2 is not loaded, at all:First off, welcome to Stack Overflow and good on you for updating, a little late to the party tho ;P You’ll love php ^8.
Now, typically, php can be run in multiple ways like CLI and GUI (there are actually many more, but off-topic), which is the server context. In a stock installation of
apache
withphp
the users request is forwarded to PHP’s.so
file. This file is actually the artifact of compiling PHP directly from its source code written in C.This is all to say if you have not restarted
apache
that new compiled handler may not be found.Let’s dig in deeper. You’re adding a
handler
in apache to the.htaccess
file, which is cleaver I’ve never seen that, but this handlers definition (aka the executable it points to) is defined in the server config. Typicallyhttpd.conf
. Many things can not be added to the.htaccess
but must be loaded at startup, not call-time. When you typephp
in the command line you are actually using a different executable php than apache should. Thus yourphp-cli
vsphp-cgi
.