Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SOLVED PHP7 Per Directory?

Discussion in 'EasyApache' started by celiac101, Apr 28, 2017.

Tags:
  1. celiac101

    celiac101 Active Member

    Joined:
    Dec 19, 2012
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    I am running cpanel and EasyApache 4 and know how to change the version of PHP per site, but what I really need to do is to be able to run PHP7 in a sub-directory of as site. For example, the root site runs PHP 5.6, but I would like /directory to run PHP7. Does anyone know a way to do that?
     
  2. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    604
    Likes Received:
    94
    Trophy Points:
    103
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    In the MultiPHP Manager in cPanel, simply set the directory that you want to run PHP70, and change it over.
     
  3. celiac101

    celiac101 Active Member

    Joined:
    Dec 19, 2012
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    I just went into the MultiPHP Manager and do not see any way to add a directory/path. I do see per domain, but not per directory. Sorry, but more details would be helpful.
     
  4. cPJacob

    cPJacob cPanel Product Owner
    Staff Member

    Joined:
    May 2, 2014
    Messages:
    604
    Likes Received:
    94
    Trophy Points:
    103
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    Hi,

    If the directory doesn't have an associated document root, you can copy the .htaccess AddHandler that we add and place it in the .htaccess file of the directory you're wanting to change.

    The UI's don't support per-directory, but the handlers will, no problem.
     
  5. celiac101

    celiac101 Active Member

    Joined:
    Dec 19, 2012
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    If you mean that I should be able to add the code below to that directory's .htaccess file, I tried this and it does not work. I got a "Site not working" error:

    # php -- BEGIN cPanel-generated handler, do not edit
    # Set the “ea-php70” package as the default “PHP” programming language.
    <IfModule mime_module>
    AddType application/x-httpd-ea-php70 .php .php7 .phtml
    </IfModule>
    # php -- END cPanel-generated handler, do not edit
     
  6. celiac101

    celiac101 Active Member

    Joined:
    Dec 19, 2012
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    This also did not work, it just kept popping open a file download box:
    AddHandler application/x-httpd-php7 .php
     
  7. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,419
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    Could you let us know the full error message you noticed? Did you see a corresponding error message in /usr/local/apache/logs/error_log or within any individual error_log files in the corresponding directory? Also, can you confirm PHP 7.0 is installed on the system?

    Thank you.
     
  8. celiac101

    celiac101 Active Member

    Joined:
    Dec 19, 2012
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    I do have PHP 7 installed (I did a ticket with you to upgrade from Easy Apache 3 to 4, and your team verified this), and this is the only thing I see in the error log:

    [Mon May 01 13:44:58.176827 2017] [include:warn] [pid 19874] [client xxx.xxx.xxx.xxx:65288] AH01374: mod_include: Options +Includes (or IncludesNoExec) wasn't set, INCLUDES filter removed: /404.shtml, referer: mydomain.tld
     
    #8 celiac101, May 2, 2017
    Last edited by a moderator: May 2, 2017
  9. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,419
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello @celiac101,

    Feel free to open a support ticket if you'd like us to take a closer look and determine why the per-directory setting for the PHP version in your .htaccess file isn't working.

    Thank you.
     
  10. celiac101

    celiac101 Active Member

    Joined:
    Dec 19, 2012
    Messages:
    44
    Likes Received:
    0
    Trophy Points:
    6
    cPanel Access Level:
    Website Owner
    The issue turned out to be that mbstring was not installed for PHP7. This is how I installed it, and it fixed the issue:
    yum install ea-php70-php-mbstring.x86_64
     
  11. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,419
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    I'm happy to see the issue is now solved. Thank you for updating us with the outcome.
     
Loading...

Share This Page