einarso

Q: Should be running php7, but seems like I am running php5.5

I am having a problem making WP work with the right php version. I am running WP on a Mac mini server I recently updated. Checking the php in terminal I see the following:
server:~ xxxxServer$ php -v
PHP 7.0.4 (cli) (built: Mar 14 2016 08:14:23) ( NTS )
Looking good - I have upgraded to php7 so this was to be expected. But running the phpinfo file - not so good....:
http://altikost.no/phpinfo.php
According to this, I am still running php5.5

Anyone who has any tips?

Mac mini, OS X El Capitan (10.11.4), Server

Posted on Apr 23, 2016 5:42 AM

Close

Q: Should be running php7, but seems like I am running php5.5

  • All replies
  • Helpful answers

  • by Linc Davis,Helpful

    Linc Davis Linc Davis Apr 24, 2016 7:21 AM in response to einarso
    Level 10 (207,926 points)
    Applications
    Apr 24, 2016 7:21 AM in response to einarso

    The system PHP is version 5.5.31. You must have installed a newer version somewhere in your PATH. OS X Server won't use it.

  • by einarso,

    einarso einarso Apr 24, 2016 1:50 AM in response to Linc Davis
    Level 1 (12 points)
    Servers Enterprise
    Apr 24, 2016 1:50 AM in response to Linc Davis

    ...but how do I get OS X server to use php7?

  • by Linc Davis,

    Linc Davis Linc Davis Apr 24, 2016 7:11 AM in response to einarso
    Level 10 (207,926 points)
    Applications
    Apr 24, 2016 7:11 AM in response to einarso

    OS X Server is optimized for easy configuration, not for flexible configuration. The short answer to your question is, "You can't." If you want a server that you can configure any way you want, use a Linux- or BSD-based operating system.

     

    That said, if you're going to try it anyway, the Apache configuration files are in the folder /Library/Server/Web/Config/apache2, and the ones you probably want to modify are in the subfolder named "sites". I very strongly advise against modifying anything outside that subfolder, as you will probably wreck your installation.

     

    You would need to add a suitable "LoadModule" directive to one or more of those files. That's all I can tell you, and I won't be able to help with any problems that result. Make sure you know how to revert any changes you make when the web service stops working.

  • by einarso,Solvedanswer

    einarso einarso Apr 24, 2016 7:21 AM in response to Linc Davis
    Level 1 (12 points)
    Servers Enterprise
    Apr 24, 2016 7:21 AM in response to Linc Davis

    Thank you VERY much.  After hours of trying to make this work, I have really been messing up something that isn't a part of the setup at all. 

     

    I tried to edit the server http file (switching from php5 to php7), only for the server stopping publishing any of my sites.  Switched right back to the original file...

     

    I guess I will have to wait for an update from Apple.  Is there any chance Apple updates to use php7?

  • by Linc Davis,

    Linc Davis Linc Davis Apr 24, 2016 7:43 AM in response to einarso
    Level 10 (207,926 points)
    Applications
    Apr 24, 2016 7:43 AM in response to einarso

    I don't know any more than you do about future versions of Apple products.

  • by John Lockwood,

    John Lockwood John Lockwood Apr 25, 2016 4:34 AM in response to einarso
    Level 6 (9,230 points)
    Servers Enterprise
    Apr 25, 2016 4:34 AM in response to einarso

    Along the same lines as Linc said if you want more control then OS X Server.app is not the way to do things. Previously I have used Linux virtual machines which does give you control at the cost of ease of use, these days the new approach is to use 'Docker'. Effectively Docker is a mini stripped down form of virtual machine dedicated to running various open-source projects.

     

    Docker has recently been enhanced for OS X it used to require using VirtualBox which meant it created 'full-fat' virtual machines but now there is a new beta version of Docker for Mac which uses a much more efficient VM mechanism provided by xhyve. See https://blog.docker.com/2016/03/docker-for-mac-windows-beta/

     

    Not that it helps here but the same problem of dealing with multiple different language versions of in your case PHP also applies to Python, however for Python there is a standard mechanism to allow using multiple different versions at the same time by using a Python extension called VirtualEnv. This if used correctly is compatible with Apple's Server.app. Even with Python though the new Docker approach is probably better in the long run.

  • by Ivan Robertovich,

    Ivan Robertovich Ivan Robertovich May 11, 2016 10:08 PM in response to einarso
    Level 1 (48 points)
    Servers Enterprise
    May 11, 2016 10:08 PM in response to einarso

    Despite what you've been told, YES YOU CAN.

     

    I Installed php 7 with homebrew  What is happening is that your Apache conf is still loading php5 as mod_php when you click the "enable php"

     

    go to /Library/server/web/config/apache2. (Or some thing like that.. This from memory)

     

    sudo vi http.conf.  Find the string of lines that start LoadModule.  The last one loads php5.  If you have the check box unchecked, this line will be commented out.

     

    Add this line beneath (for homebrew...  Otherwise find your php7 module):

    LoadModule php7_module  /usr/local/opt/php70/libexec/apache2/libphp7.so

     

    then go to the bottom of the file and beneath the IfModule php5 block, add your own php7 file handler:

    <IfModule php7_module>
        AddType application/x-httpd-php .php
        <FilesMatch .php$>
            SetHandler application/x-httpd-php
        </FilesMatch>
        <IfModule dir_module>
            DirectoryIndex index.php index.html
        </IfModule>
    </IfModule>
    

     

    Works for me. 

     

    CAVEAT:   You WILL need to repeat this after a server upgrade. 

     

    I Know that this can be done with a webapp, and that would be the preferred way, but I haven't figured out how yet.  Perhaps the people that said no, and that server offers no control can figure it out and help us.  Meanwhile, enjoy php 7!!! 

     

    I also load the opcache and memcached.   Wordpress flies.  

     

    cheers!

  • by Ivan Robertovich,

    Ivan Robertovich Ivan Robertovich May 11, 2016 10:16 PM in response to Ivan Robertovich
    Level 1 (48 points)
    Servers Enterprise
    May 11, 2016 10:16 PM in response to Ivan Robertovich

    P.s.    I was also able to get server to run php7 through php-fpm

    it wasn't any faster than mod_php, however, that should be even easier to make happen with a webapp.  Perhaps this summer I will be able to figure it out

     

    Now that server 5.1 has TLS 1.2, I am less inclined to put nginx as a webapp in front, so I will be coming back to Apache tuning and making this webapp. 

     

    You dont need to waste time with docker.  Docker is fine, but totally a time waste for this issue.  Instead, tune the Apache configuration to handle load. 

     

    I ash Apple would give an option for the EVENT mpm on Apache.  It's faster than nginx and php-fpm can be better tuned for speed with it.