skip to Main Content

I have used below commands to upgrade php in my mac machine.

brew tap homebrew/homebrew-php
brew unlink php71
brew install php72 --with-argon2 
brew install php72-xdebug

PHP 7.2 has been successfully installed. I have checked with the command php -v and getting the version PHP 7.1 in my terminal. Please help.

3

Answers


  1. brew unlink php71 and brew link php72 will tweak your php command line to the right path and version, but Apache will not be affected until you change its config file.

    First, locate your httpd.conf file path:

    httpd -V | grep SERVER_CONFIG_FILE
    

    You may also check:

    apachectl -t -D DUMP_INCLUDES
    

    Then:

    Open your httpd.conf file and locate the line starting with LoadModule
    php Comment this line with #, and add your 7.2 line instead.

    You can get your line from querying the following command in the Terminal:

    brew info [email protected] | grep LoadModule it should look like: LoadModule
    php7_module /usr/local/opt/[email protected]/lib/httpd/modules/libphp7.
    

    so Finally, restart Apache:

    sudo apachectl restart your script should now
    

    be runing with php7.2 version There’s also detailed instructions about
    using a php switcher here. Once installed, you can switch from one
    version to another like this (it will link both Apache and the command
    line automatically):

    sphp 7.1

    sphp 7.2

    sphp 5.6

    etc..

    Login or Signup to reply.
  2. As per your comments, php7.2 successfully installed and only issue with your /usr/bin/php symlink. Please do the following steps.

    nano ~/.bash_profile
    

    append the below line

    alias php="/usr/local/opt/[email protected]/bin/php" 
    

    save and exit .bash_profile then run

    source ~/.bash_profile
    

    Now you can run php7.2 in your terminal.

    Login or Signup to reply.
  3. You can use curl to update php version.

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

    Last Step:

    export PATH=/usr/local/php5/bin:$PATH
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search