简体   繁体   中英

How do I update PHP version without homebrew and using ZSH?

I'm trying to update my PHP version from 7.1.x to 7.3.x. Unfortunately once I run the curl command to update the version, my php -v still outputs the following.

PHP 7.1.23 (cli) (built: Nov 27 2018 16:59:25) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

Heres the curl command I'm using and the reference of where I found this command.

curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3

Reference: https://php-osx.liip.ch/

I've then added the following to my .zshrc file to update my path with ZSH's built in mapping. See: https://stackoverflow.com/a/18077919/6572260

# Append to Path PHP
path+=("/usr/local/php5/bin")

# Export the PATH
export PATH=$PATH

This doesn't work either and I have no idea what I'm doing wrong.

So after much headbanging on my desk, I finally figured it out. 5 hours later.

I tried many methods, but what I didn't realize was that the path for php has to be prepended and not appended to the path .

So the line in my .zshrc file needed to be changed from

# Append to Path PHP
path+=("/usr/local/php5/bin")
# Prepend the Path for PHP
path=("/usr/local/php5/bin" $path)

Also a little note, that the $path can also be $PATH inside the mapping.

Hopefully this helps someone along the way who was running into the same issue and hitting a giant wall.

Reference first Question in FAQ section here: https://php-osx.liip.ch/#faq

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