简体   繁体   中英

Apache is running the wrong version of PHP on Mavericks

I'm trying to update my PHP version from 5.4 to 5.5, but Apache is not playing along. I've searched this on other places and it seems that the solution should be adding the following line to httpd.conf :

LoadModule php5_module    /usr/local/opt/php55/libexec/apache2/libphp5.so

I did, and it's still not working. From the command line everything seems to be correct:

Andres-MacBook-Air:~ fratelli$ which php
/usr/local/opt/php55/bin/php
Andres-MacBook-Air:~ fratelli$ php -v
PHP 5.5.16 (cli) (built: Sep 12 2014 04:34:10) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
Andres-MacBook-Air:~ fratelli$ 

As I said, I added the LoadModule directive to the https.conf file, located in /private//etc/apache2 , and then I restart apache:

sudo apachectl restart

In my page I call phpinfo() , which is telling me that I'm using PHP Version 5.4.24. Does anybody know how to fix this?

Best.

Edit: Does this help?

Andres-MacBook-Air:apache2 fratelli$ apachectl -M | grep php
[Sat Sep 13 03:11:50 2014] [warn] module php5_module is already loaded, skipping
httpd: Could not reliably determine the server's fully qualified domain name, using Andres-MacBook-Air.local for ServerName
Syntax OK
 php5_module (shared)

Edit: I have no idea where Apache is loading PHP from. I just edited my /private/etc/httpd.conf file removing all LoadModule directives referent to PHP and it still works (5.4, though). I'm pretty sure this is the wrong file.

Edit: it does seem to be the wrong file. There's another one in /etc/apache2 . Will give that a try.

Edit: Now I'm confused:

Andres-MacBook-Air:apache2 fratelli$ ls -l /private/etc/apache2/httpd.conf
-rwxrwxrwx  1 root  wheel  18196 Sep 13 03:29 /private/etc/apache2/httpd.conf
Andres-MacBook-Air:apache2 fratelli$ ls -l /etc/apache2/httpd.conf
-rwxrwxrwx  1 root  wheel  18196 Sep 13 03:29 /etc/apache2/httpd.conf

Editing one also changes the other, but neither seems to be a symlink..

Use this website. http://php-osx.liip.ch/ You can update to 5.5 or 5.6 I have updated several Macs using their one line ssh command. This should fix everything on your mac and get you on either 5.5 or 5.6 which is now stable.

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6

or

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.5

My Apache has a file here. /etc/apache2/other/+php-osx.conf with the following path.

LoadModule php5_module  /usr/local/php5/libphp5.so

In you command line

which php

and it should

/usr/local/php5/bin/php

In my httpd.conf, the libphp5.so is actually commented out and there is no reference to PHP.

#LoadModule php5_module        libexec/apache2/libphp5.so

Also make sure you "RESTART APACHE" to see any changes occur. If you dont it wont reload the PHP5.5 library and you wont see any changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM