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

Reply
9 replies

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.

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?

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.

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!

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.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

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

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.