Announcement

Collapse
No announcement yet.

Different PHP versions per directory (WHM error)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • yzhcable
    replied
    Hello,

    Thank you for your cooperation.

    --
    Regards,
    Felix O.

    Leave a comment:


  • bogdan.sh
    replied
    It appears cpanel use own syntax checker when processing any includes from WHM. I was able to cheat it wrapping around with IfModule, use this:

    Code:
    <IfModule mod_suphp.c>
    
    <Directory />
    
    suPHP_AddHandler application/x-httpd-php52
    
    suPHP_AddHandler application/x-httpd-php53
    
    suPHP_AddHandler application/x-httpd-php54
    
    suPHP_AddHandler application/x-httpd-php55
    
    suPHP_AddHandler application/x-httpd-php56
    
    </Directory>
    
    </IfModule>
    But, you know... that is a right way to add such directives as they should be applied only if suphp enabled, and should not brake apache functionality if in future you switch to fastcgi. We are going to correct our blogpost to reflect this.

    Thanks for reporting!

    Leave a comment:


  • yzhcable
    replied
    Hello,

    Yes, sure. We use suphp. Please take a look at the listing bellow:

    Code:
    $ /usr/local/cpanel/bin/rebuild_phpconf --current
    
    Available handlers: suphp cgi none
    
    DEFAULT PHP: 5
    
    PHP4 SAPI: none
    
    PHP5 SAPI: suphp
    
    SUEXEC: enabled
    
    RUID2: not installed
    
    $ grep alt /opt/suphp/etc/suphp.conf
    
    application/x-httpd-php52="php:/opt/alt/php52/usr/bin/php-cgi"
    
    application/x-httpd-php53="php:/opt/alt/php53/usr/bin/php-cgi"
    
    application/x-httpd-php54="php:/opt/alt/php54/usr/bin/php-cgi"
    
    application/x-httpd-php55="php:/opt/alt/php55/usr/bin/php-cgi"
    
    application/x-httpd-php56="php:/opt/alt/php56/usr/bin/php-cgi"
    
    $ cat /usr/local/apache/conf/includes/pre_main_global.conf
    
    suPHP_AddHandler application/x-httpd-php52
    
    suPHP_AddHandler application/x-httpd-php53
    
    suPHP_AddHandler application/x-httpd-php54
    
    suPHP_AddHandler application/x-httpd-php55
    
    suPHP_AddHandler application/x-httpd-php56
    
    $ /usr/local/apache/bin/apachectl -t
    
    Syntax OK
    
    $ /usr/local/cpanel/cpanel -V
    
    11.48.4 (build 4)
    We use the directive like AddHandler application/x-httpd-php54 .php .php5 (.htaccess) in order to switch php version per directory base and no errors are noticed in the server logs and local error_logs. The php version switches well, only one error (see the first post) has been noticed when we use WHM menu (Apahce Configuration => Inclde Editor -> "Pre Main Include" and "All Version" option) in order to add suPHP_AddHandler directives into pre_main_global.conf file.

    Thanks in advance.

    --
    Regards,
    Felix O.

    Leave a comment:


  • bogdan.sh
    replied
    Do you really use suphp? Could you please post full output from /usr/local/cpanel/bin/rebuild_phpconf --current command?

    Not sure if it works if you edit the file manually, maybe you just do not notice an error.

    Leave a comment:


  • yzhcable
    started a topic Different PHP versions per directory (WHM error)

    Different PHP versions per directory (WHM error)

    Hello,

    We are trying to use the following guide in order to implement multiple per directory php versions functional ( https://www.cloudlinux.com/blog/clne...p-selector.php ). As we can see it works perfectly when we edit /usr/local/apache/conf/includes/pre_main_global.conf using SSH console, but we have noticed an error when we use WHM. We use the following menu cPanel => Apahce Configuration => Inclde Editor -> "Pre Main Include" and "All Version", then we put the following block into editor:

    Code:
    suPHP_AddHandler application/x-httpd-php52
    
    suPHP_AddHandler application/x-httpd-php53
    
    suPHP_AddHandler application/x-httpd-php54
    
    suPHP_AddHandler application/x-httpd-php55
    
    suPHP_AddHandler application/x-httpd-php56
    and press "Update". The following error arrise:

    > Clearing post_virtualhost_2.conf
    >
    > Clearing post_virtualhost_global.conf
    >
    > Clearing pre_main_2.conf
    >
    > Saving pre_main_global.conf
    > Sorry, your changes have introduced a syntax error in pre_main_global.conf. Please correct the issue.
    > Error:
    > Configuration problem detected on line 2 of file /usr/local/apache/conf/includes/pre_main_global.conf.tmp: Invalid command suPHP_AddHandler, perhaps misspelled or defined by a module not included in the server configuration --- /usr/local/apache/conf/includes/pre_main_global.conf.tmp --- 1 2 ===> suPHP_AddHandler application/x-httpd-php52 <=== 3suPHP_AddHandler application/x-httpd-php53 4suPHP_AddHandler application/x-httpd-php54 5suPHP_AddHandler application/x-httpd-php55 6suPHP_AddHandler application/x-httpd-php56 7 --- /usr/local/apache/conf/includes/pre_main_global.conf.tmp ---
    >
    > Clearing pre_virtualhost_2.conf
    >
    > Clearing pre_virtualhost_global.conf
    > Apache Version: 2.4.10

    As it has been noticed before this functional works without any problem if we ipmplement this via remote console, but what WHM error can be related with?

    Thanks in advance.

    --
    Regards,
    Felix O.
Working...
X