Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • I ISPConfig 3
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 563
    • Issues 563
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 53
    • Merge requests 53
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ISPConfig
  • ISPConfig 3
  • Issues
  • #6233
Closed
Open
Created Sep 11, 2021 by Collin Machine@TechManPro

Fix socket path on PHP 7 systems Starts with oldest version

Basically the "Fix socket path on PHP 7 systems" section of /usr/local/ispconfig/server/plugins-available/apps_vhost_plugin.inc.php is written so that it replaces the socket path of PHP5 for the PHP7 socket paths but if multiple versions of PHP7 exist on the system, it uses the oldest version, as it performs a string replace on the $content variable and the string is no longer found when later PHP7 sockets are found and a replace is attempted.

Summary

I would assume you'd want the socket for the latest version of PHP7, and possible PHP8 to be added as well?

Steps to reproduce

Pretty self-explanatory

Correct behaviour

Perhaps rewrite to a if/elseif statement, starting with the newest version working backwards, as the other lines are useless if the string replace has already occurred on $content

Environment

Server OS + version: Ubuntu 20.04 ISPConfig version: 3.2.6

Software version of the related software: Server version: Apache/2.4.48 (Ubuntu) Server built: 2021-07-01T19:16:08

PHP 7.4.23 (cli) (built: Aug 26 2021 15:51:37) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.23, Copyright (c), by Zend Technologies

Proposed fix

I don't know if this is how you want to do it but maybe something like this:

// Fix socket path on PHP 7 systems
$php7_socket = false;
if(file_exists('/var/run/php/php7.4-fpm.sock')) {
    $php7_socket = '/var/run/php/php7.4-fpm.sock';
} elseif(file_exists('/var/run/php/php7.3-fpm.sock')) {
    $php7_socket = '/var/run/php/php7.3-fpm.sock';
} elseif(file_exists('/var/run/php/php7.2-fpm.sock')) {
    $php7_socket = '/var/run/php/php7.2-fpm.sock';
} elseif(file_exists('/var/run/php/php7.1-fpm.sock')) {
    $php7_socket = '/var/run/php/php7.1-fpm.sock';
} elseif(file_exists('/var/run/php/php7.0-fpm.sock')) {
    $php7_socket = '/var/run/php/php7.0-fpm.sock';
}
if(!empty($php7_socket)) $content = str_replace('/var/run/php5-fpm.sock', $php7_socket, $content);

--- Notice the $php7_socket variable is set to false by default just because if you do decide to add PHP8 to the beginning of this set, it doesn't throw an error for undefined variable.

Edited Sep 11, 2021 by Collin Machine
Assignee
Assign to
Time tracking