Php version via ssh not same as domain

sephen

Verified User
Joined
Nov 12, 2019
Messages
15
I'm running into a problem when trying to install packages via composer. When running the script via ssh it tells me the php version is 7.3.3 while the version of the domain is 8.2.

Where in the settings can I change this?

Thanks in advance!
 
Check the /usr/local/directadmin/custombuild/options.conf file.
Set the php version you want for SSH als first php version. You might need to do the rewrite_confs command again after that or more, I have to look that up, but having dinner right now.
 
Check the /usr/local/directadmin/custombuild/options.conf file.
Set the php version you want for SSH als first php version. You might need to do the rewrite_confs command again after that or more, I have to look that up, but having dinner right now.
Thanks for your reply,
I cannot find that option, do I have to add it? if so can you tell me what to add?

Sorry I'm not that skilled with directadmin.
 
Sorry I'm not that skilled with directadmin.
That's no problem, we all had to learn it at a certain time.

Best is to login via SSH as root, however, you can also use the custombuild plugin if I'm correct.

Login to your server as admin.
Then in the admin screen, scroll down and look under Extra Features. Click on Custombuild there.
Then click on Options.
Then scroll down to PHP Settings. It will look like this:

1691596856671.png


Now php1_mode defines which mode is used as default by Directadmin and thus also via SSH if you run it as root.
So if you want to have php 8.2 as default version for all installations and thus also in SSH, you have to change php1_release to 8.2.

This means that at this moment most likely 7.3 is as php1_release, you have to set this to php2_release or php3_release.
However, keep in mind that users who are using 7.3 at this moment, must also be set to php3_release after making the change.

When ready then click Save under the php Settings (right side), I guess things will go automatically further there because PHP needs to be rebuild.

Afterwards, suppose you set php 7.3.3 to php3_release then you have to move the users who used php 7.3 to the 3rd option. This can be done via this script (in SSH as root).
Code:
#!/bin/sh
for i in `ls /usr/local/directadmin/data/users/*/domains/*.conf`; do
{
       if ! grep -q ^php1_select $i; then
               echo php1_select=3 >> $i
               continue
       fi

       perl -pi -e "s/^php1_select=1/php1_select=3/" $i
};
done
exit 0

Once that is done you have to update the config files.
Code:
cd /usr/local/directadmin/custombuild
./build update
./build rewrite_confs

Good luck.
 
Thanks, I had to update Directadmin because i got a "License check failure See the Debug Guide" error.
I checked but all my php version are not 7.3.3 and the first one is 8.2 but the issue remains.

Code:
php -v
PHP 7.3.33 (cli)...

Screenshot 2023-08-09 at 18.57.06.png


But when I go to system information:
Screenshot 2023-08-09 at 19.20.27.png


Also after the update custombuild is missing in the admin area so I cannot make changes anymore.
 
Last edited:
Well, the way PHP is accessed through the web server is completely different from the way that PHP is accessed from the command-line.

If you review the web server configuration file for the domain in question, you'll note that it's pointing PHP access to a specific version of PHP.

The phrase "default PHP" in the sense from the web server's perspective is what PHP version is pointing to when creating a new account or domain.

The phrase "default PHP" in the sense from the command-line is based on what php binary it runs into first through the $PATH variable. I'm really not sure how DirectAdmin makes that determination

(Run

ls -al $(which php)

from the command to see the default PHP that is run when you execute the php command in the command-line. I suspect it's a symlink to a /usr/local/phpXX/bin/php binary)

To run a specific version of PHP from the command line, it's always a good idea to just use the full path - /usr/local/phpXX/bin/php - i.e. for PHP 8.2 - /usr/local/php82/bin/php
 
Also after the update custombuild is missing in the admin area so I cannot make changes anymore.
Then you probably are using the Enhanced skin, it's not present in the Enhanced skin anymore, you have to use Evo to be able to use the custombuild plugin now.

So system information is correct. It's odd that system info is not the same as the options.conf file.
Probably missend some php build and/or rewrite_confs as far as I can see.

However to run a php script from a specific php version, you have to do what @sparek said.

Normal CLI as root normally always uses the first php version of directadmin's options.conf.
 
Back
Top