How can I get PHP working again in the command line?

前端 未结 5 1515
再見小時候
再見小時候 2020-12-08 11:54

I\'m completely at loss here and am about to wipe my hard drive clean and start from a fresh OS install. I\'ve been trying for two days to create a new yii app in the termin

5条回答
  •  遥遥无期
    2020-12-08 12:01

    There is one of two things going on here, either you didn't install PHP, or PHP is installed and not currently in any of system aware paths. First I would try to find PHP and make sure it exists:

    $ find / -name php -type f
    

    You should see something like:

    /path/to/your/php/bin/php
    

    If PHP binary does exist, check your path:

    $ echo $PATH
    

    If it does not exist, recompile php.

    If PHP exists on your system, make sure the path to the /bin/php file is included. You can edit your ~/.bash_profile and add the custom path like this:

    PATH=$PATH:/path/to/your/php/bin/
    ....  
    export PATH
    

    Then save and reload the file to ensure your current session has access to new path changes:

    $ source ~/.bash_profile
    

    With any luck you can now do a php -v and see the version response.

    -- Update --

    Setting actual path:

    $ vi ~/.bash_profile
    
    ...
    # Add your custom php path
    PATH=$PATH:/bitnami/mampstack-osx-x86/output/php/bin/
    ....  
    export PATH
    

    Save and close, then source it:

    $ source ~/.bash_profile
    

    And now you should be able to run PHP from cli:

    $ php -v
    

提交回复
热议问题