I've got a MAC OSX (Capitan to be precise).
I have installed PHP7 by using this line of code in the terminal:
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.0
After it installed I run this:
export PATH=/usr/local/php5/bin:$PATH
After this when I run:
PHP -v
I get PHP 7.0.10 (cli) (built: Aug 31 2016 10:25:51) ( NTS )...
when is what I need it to do, so great BUT my problem is that as soon as I close my terminal and I run PHP -v again I get PHP 5.5
Why doesn't it keep PHP 7.0 ?
Add export PATH=/usr/local/php5/bin:$PATH to your ~/.profile dotfile so that the PATH variable is exported when you start your system (requires restart).
Or add it to ~/.bashrc file so that it gets exported when you start you start bash.
I recommend using ~/.profile.
Related
I just successfully upgraded my server php version from 5.3 to 5.6
When I run:
php -v
I get:
PHP 5.6.40 (cli)
But when I create a file write
echo phpInfo();
The php version showing is 5.3.3
How do I set the php version on phpinfo() to show 5.6
Thanks,
Try this..
rm /usr/bin/php
ln -s /usr/bin/php56 /usr/bin/php
service httpd restart
And then run
php -v
Recently I updated the default PHP version on MacOS X 10.11 to the newer 7.1.4, but when I do php -v on the terminal it says this: PHP 5.5.38 (cli) (built: Aug 21 2016 21:48:49).
I created the phpinfo on the web root and it says that the version is actually the 7.1.4.
What should I do to resolve this issue? Is this a real issue?
Since you said:
I used the command curl -s php-osx.liip.ch/install.sh | bash -s 7.1
I took a look at https://php-osx.liip.ch, which says:
Why does php -v on the command line still show my old version?
php-osx doesn't overwrite the php binaries installed by Apple, but
installs everything in /usr/local/php5. The new php binary is
therefore in /usr/local/php5/bin/php.
You can also adjust your PATH do include that directory, eg. write
into your ~/.profile file the following
export PATH=/usr/local/php5/bin:$PATH
To install php7 I run:
curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
php -v
It show php 5.6.30
Then, I run this in my terminal:
export PATH=/usr/local/php5/bin:$PATH
php-v
It show the latest version of php : 7.1 .
When I closing the terminal and run the php -v again.
it show the old version php again 5.6.30
Why is this happening?
I am trying to setup deployer php on a shared server. And having trouble running php remotely on the server.
The server is running php 7.0.6 for normal http requests. And if I SSH in via terminal and run php -v on the remote server I get:
# php -v
PHP 7.0.6 (cli) (built: May 2 2016 02:11:49) ( NTS )
this seems good to go but if I run a remote command from my local machine:
$ ssh 'user#domain.com' 'php -v'
PHP 5.3.28 (cli) (built: Mar 29 2014 12:18:37)
obviously the remote command is not using the right php version. I found the version is set in the .bash_porfile:
export PATH=/usr/local/lib/crucial-php/php-7.0.600/bin:$PATH
but I don't know how to get the ssh remote command to respect the .bash_profile. Is there anyway to get the remote command to use the modified PATH without forcing it with source ~/.bash_profile
This turned out to be pretty simple, after reading this post:
Why does an SSH remote command get fewer environment variables then when run manually?
I copied the PATH var into my ~/.bashrc file and it worked like a charm.
After the Yosemite update yesterday, something is messed up with the Mcrypt extension.
The PHP based artistan CLI of the Laravel framework returns:
Mcrypt PHP extension required.
The PATH variable seems to be correct. Where is the misconfig? Before the update everything worked fine.
++++ Configs ++++
Output of 'which php':
/Applications/MAMP/bin/php/php5.6.1/bin/php
'php -v':
PHP 5.6.1 (cli) (built: Oct 13 2014 18:41:35) Copyright (c) 1997-2014
The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend
Technologies
Content of .bash_profile:
export EDITOR=nano export
PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/usr/local/mysql/bin
export PATH=/Applications/MAMP/bin/php/php5.6.1/bin:$PATH
phpinfo():
MAMP PRO Version:
3.0.7.1
UPDATE:
Mamp-log says for every extension enabled in php.ini:
PHP Warning: PHP Startup: Unable to load dynamic library
'/Applications/MAMP/bin/php/php5.6.1/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so'
- dlopen(/Applications/MAMP/bin/php/php5.6.1/lib/php/extensions/no-debug-non-zts-20121212/mcrypt.so,
9): image not found in Unknown on line 0
I've contacted MAMP support, and this is what they responded.
Hi,
Our php.ini file is messed up for 5.6.1. Go to your template files and change this line
/Applications/MAMP/bin/php/php5.6.1 ....
to
/Applications/MAMP/bin/php/php5.6.1/lib/php/extensions/no-debug-non-zts-20131226
We will have a full fix in a few days. You can also just downgrade to php 5.5. in the meantime.
I just had the same problem.
Just use PHP Version 5.5.17 in MAMP and everything should work fine again.
Remember to switch the version in your .bash_profile too:
export PATH=/Applications/MAMP/bin/php/php5.5.17/bin:$PATH
The hotfix was applied this morning MAMP & MAMP PRO 3.0.7.2 Published: 2014-10-21.
Default php 5.6.2
Don't forget to update .bash_profile
export PATH=/Applications/MAMP/bin/php/php5.6.2/bin:$PATH
Everything works fine on my local and it also works fine with drush (for those that use it)
the same error with you, but I perfect sloved it now:
Stop your MAMP
Open /Applications/MAMP/bin/php/php5.6.1/conf/php.ini
Find all "no-debug-non-zts-20121212" replace by "no-debug-non-zts-20131226"
Open /Applications/MAMP/bin/php/php5.6.1/conf/pear.conf
Find "no-debug-non-zts-20100525" replace by "no-debug-non-zts-20131226"
Start your server
I recommend you unistall OS X's default php and apache
Path:
/etc/apache2
/usr/include/apahce2
/usr/libexec/apache2
/usr/php
/usr/bin/php
/usr/bin/php-config
/usr/bin/phpize
/usr/include/php
/usr/lib/php
/usr/share/man/man*/php*
/usr/bin/phar.phar
then
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/pear /usr/bin/pear
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/peardev /usr/bin/peardev
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/pecl /usr/bin/pecl
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/phar.phar /usr/bin/phar.phar
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/php /usr/bin/php
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/php-cgi /usr/bin/php-cgi
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/php-config /usr/bin/php-config
sudo ln -s /Applications/MAMP/bin/php/php5.6.1/bin/phpize /usr/bin/phpize
1) First check what php.ini file is loaded:
php --ini
You will probably see that none of the files have been loaded.
2) If you don't mind reinstalling php you can do this:
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
3) Then set the path to your new php installation in order to avoid using the native php that comes with OSX.
In order to set the path use this command - something like this, bear in mind that your path could be different:
export PATH=/usr/local/php5/bin:$PATH