contao / contao-manager

Contao Manager
GNU Lesser General Public License v3.0
85 stars 33 forks source link

Detecting the wrong php path causing server to become unresponsive #608

Closed rburch closed 2 years ago

rburch commented 4 years ago

After recent updates to Contao manager we noticed last week the it was crashing our whole server. Contao Manager detects the wrong PHP path and then run several tests that cause an infinite loop of new php processes being started. Contao Manager incorrectly selects /usr/local/bin/php as the php version to use. In previous versions of Contao Manager the path was detected correctly and the user was given a chance to confirm before it moved forward with the installation.

aschempp commented 4 years ago

yes, version 1.3 automatically detects the path. How can running a binary cause an infinite loop?

johannes-bittner commented 3 years ago

I have a similar problem that the path indicated by the server admin was not accepted by the manager. In previous versions, the input field would simply not accept the given value, since v1.3, the manager remains stalled and in the log files, it states the timeouts.

By further checkings, I found that the server might by misconfigurated. Running: echo PHP_SAPI; gives me apache2handler and running: <?php PHP_SAPI === 'cli' or die('not allowed'); ?> gives not allowed

Could this be a possible cause (that PHP was not compiled/configured correctly, e.g. not including the cli) for the manager to stall?

rburch commented 3 years ago

I think our issue is that CPanel allows us to run multiple versions of PHP. Seems like Contao manager detects the correct version, but doesn't detect the correct path to it, it just uses a generic path. Our solution thus far is is to click the change button when it appears and manually add the path to the correct version of PHP. I don't bellive our server is misconfigured, but we'll take a second look just in case.

aschempp commented 3 years ago

Seems like Contao manager detects the correct version, but doesn't detect the correct path to it, it just uses a generic path.

Different PHP versions never use the same path. If a path has a correct PHP version, why should we not use that?

rburch commented 3 years ago

That's the issue, it's not finding the correct path for me. It incorrectly chooses /usr/local/bin/php instead of /opt/cpanel/ea-php73/root/usr/bin/php. I have to manually add it that path in. If I don't it seems like Contao Manager looks for it creating a infinite loop and crashes the server.

Toflar commented 3 years ago

Is /usr/local/bin/php a symlink to /opt/cpanel/ea-php73/root/usr/bin/php? :)

rburch commented 3 years ago

No, it is not.

aschempp commented 3 years ago

but /usr/local/bin/php is exactly the same version as /opt/cpanel/ea-php73/root/usr/bin/php?

rburch commented 3 years ago

It can be but isn't always because Cpanel runs multiple versions of PHP. So if 7.3 is the default yes, but the accounts isn't running the default version of php than the paths are not the same. We have some accounts running 7.2 and some 7.3 or 7.4 depending on what is needed. Cpanel handles versions via .htaccess

aschempp commented 3 years ago

I'm aware of that. The Contao Manager runs a check on the PHP version, and a found path is only used if that PHP version is (exactly) the same as the current web process. However, none of that explains why this would result in the server to become unresponsive?

rburch commented 3 years ago

On our server it looks like Contao Manager runs an endless loop of several tests when it can't find it, eventually the processes overwhelm the server. When we kept running into it it happened after several minutes not right away, it just got slower and slower until it became unresponsive.

aschempp commented 3 years ago

I'm sorry about that! You can run the same test manually, what happens if you run /path/to/php /path/to/contao-mangager.phar.php test ? Also, does your server have a PHP CLI binary or are you perhaps running on fcgi?

aschempp commented 3 years ago

any feedback on the topic?

rburch commented 3 years ago

Sorry I stalled on this. I have to ask my server admin and he's been swamped. I'll get you feedback as soon as I can.

fritzmg commented 3 years ago

I also actually experienced a similar problem recently. On my local system I still have older versions of XAMPP lying around. The Contao Manager automatically detects the php.exe from there, but ultimately uses the php.exe from my actual setup.

However, even though the Contao Manager initially discovers the correct php.exe, it then continues to use the one from XAMPP, which causes timeouts - because the php.exe from XAMPP is much older and only 32-bit, and for some reason the PHP extensions from my actual setup are being used, causing all sorts of errors which eventually lead to a timeout.

I was only able to fix it by manually adding

{
    "php_cli": "C:\\ProgramData\\scoop\\apps\\php74\\current\\php.exe",
}

to the contao-manager/manager.json. May be this problem is related?

aschempp commented 3 years ago

The Manager should use the first binary that matches your current web server version. If both places have the exact same version, I wonder why it would use the wrong one – maybe because PHP_BINARY etc. is not defined? I think we would need to analyse this locally …

aschempp commented 2 years ago

since this is rather old and we were unable to reproduce, I'm closing the issue. Feel free to reopen if it still happens and someone can add more details.