I have php5.6 on yosemite via brew running on Apache, but yet my phpinfo file shows php5.5
I have updated the /private/etc/apache2/httpd.conf file load module to:
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
I have restarted apache. I have restarted the terminal after adding both:
export PATH="/usr/local/opt/php56/bin/:/usr/local/sbin:/usr/local/bin:$PATH"
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
which php returns
/usr/local/opt/php56/bin/php
I have restarted the entire computer and when running a phpinfo file returns
PHP Version 5.5.20
Related
I have installed php7.2 using homebrew. But when i run php -v i still get php7.1. Of which i think it wasn't installed with Homebrew. How can i enable disable 7.1 and enable 7.2.
I have tried this as suggested by the install.
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php7_module /usr/local/opt/php#7.2/lib/httpd/modules/libphp7.so
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Finally, check DirectoryIndex includes index.php
DirectoryIndex index.php index.html
Also tried, uncommenting this line in /etc/apache2/httpd.conf
LoadModule php7_module libexec/apache2/libphp7.so
I have solved this by linking the new installed version.
After installing the new php version(7.2) with homebrew, you have to run
brew link php#72 --force
if your previous version was a installed with homebrew, you have to unlink it also. E.g for php 7.1
brew unlink php71
This is for the php CLI(command line), for the Apache PHP you need to edit /etc/apache2/httpd.conf
When you run php -v, you get the version of PHP that is executed from the command line, not the version of PHP executed from Apache.
If you run:
/usr/local/bin/php -version
You will have the version of the PHP installed by Homebrew. To set it as the default PHP interpreter from the command line, your PATH environment variable should contain /usr/local/bin/ before /usr/bin.
To check the version of PHP executed within Apache run phpinfo by browsing the following PHP file:
<?php
phpinfo();
I am using https://github.com/wilmoore/php-version to switch between php versions on my local machine, installed within ~/php/versions. Currently setting up separate VMs with different versions of php installed is not an option.
When I switch php version through the command line using the linked tool, I see it listed as php 7. This also works when using php -v. I have restarted terminal and the machine and it still says php 7.
I have updated composer.json to require php 7.0.2 and greater. Yet when I use phpinfo() in my laravel application, it always states the default PHP Version 5.5.9-1ubuntu4.14.
Where is laravel pointing to the php distribution in my Ubuntu 14.04.3 machine and where can I change this path?
EDIT: I am using Apache. I can see in the phpinfo() output that it is reading the ini file from /etc/php5/apache2/php.ini. I have looked in this file but cannot see where to point to the php distribution.
first make sure that php7.*.conf and php7.*.load files are exist in /etc/apache2/mods-available directory.
then use sudo a2enmod php7.* to enable the mod
use sudo a2dismod php5.* to disable the mod
after running the two commands restart your apache2 server
using sudo systemctl restart apache2
The Apache loads the php5_module library in /etc/apache2/mods-available/php5.load.
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
If you know the loactions of your alternative libraries you can change them in this file.
After editing you need to restart your apache. sudo service apache2 restart or sudo systemctl restart apache2.service
Had the same issue on ubuntu16.
ls -l /etc/apache2/mods-available/php7* ,
showed 2 versions -
/etc/apache2/mods-available/php7.0.conf
/etc/apache2/mods-available/php7.2.conf
Deleted the /etc/apache2/mods-available/php7.0.conf, restarted apache2, and phpinfo() via apache2 showed php7.2
Dumb question I think, but I have PHP 5.6.14 running on El Capitan.
I have installed xdebug with
brew install php56-xdebug
But there is no mention of xdebug in phpinfo
phpinfo reveals:
Configuration File (php.ini) Path: /etc
When I run brew install php56-xdebug again, I get
homebrew/php/php56-xdebug-2.3.3 already installed
So I'm guessing that brew has installed xdebug on a path (where?) which is for a different version of PHP which I'm not actually running.
Can somebody help me understand what brew has done, and how I can configure the version of PHP that I'm running to include xdebug.
OK, so I fixed this. Any comments welcome on whether I did it right.
1) Found where the brew install of php is using
brew info php56
This reports:
To enable PHP in Apache add the following to httpd.conf and restart Apache:
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
Update version of php loaded by apache:
sudo nano /etc/apache2/httpd.conf
Replaced
LoadModule php5_module libexec/apache2/libphp5.so
with
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
For those who use different version of php type in terminal
--> brew search xdebug
and choose yours version.
after installing your version of xdebug you've to active it by placing the installed extension path to your php.ini file.
print your phpinfo() and look for "Loaded Configuration File".
Open the file shown for "Loaded Configuration File" ( mine is /etc/php.ini ) and paste extension path anywhere you like.
for me the xdebug installed extension path is "/usr/local/Cellar/php56-xdebug/2.5.1/xdebug.so"
so i pasted {zend_extension="/usr/local/Cellar/php56-xdebug/2.5.1/xdebug.so"}.
restart your apache server and check your phpinfo() for xdebug, thats all.
I installed php 5.4 using homebrew, and verified version 5.4 via terminal php -v.
I commented out the previously used load modules for php4/5, and inputted the suggested line in httpd.conf for apache:
LoadModule php5_module /usr/local/opt/php54/libexec/apache2/libphp5.so
But my localhost is still using php5.6.11 according to phpversion().
I am on a mac running Yosemite.
Any ideas?
I installed Homebrew and decided to upgrade php version to 5.5. Make it through the command:
brew install php55
All went well, and then I ordered a .bash_profile:
export PATH="$(brew --prefix homebrew/php/php55)/bin:/usr/local/bin:$PATH"
Next in the directory /Library/WebServer/Documents/ I created info.php file:
<?php phpinfo(); ?>
And opened it through the browser, but display the old version of php 5.4.30. How to enable php5.5 or delete old version php5.4.30? Help me!
I solved the problem, in the Apache configuration file nttpd.conf was need to set the path to the new version of php:
#LoadModule php5_module libexec/apache2/libphp5.so
LoadModule php5_module /usr/local/Cellar/php55/5.5.19/libexec/apache2/libphp5.so