How to Prioritize MAMP PHP in the Terminal on Mac?

DDD
Release: 2024-10-30 03:51:28
Original
141 people have browsed it

How to Prioritize MAMP PHP in the Terminal on Mac?

Overriding the PHP Path to Use MAMP

Question:

After reconfiguring PHP on Mac to enable the SOAP module, the user must manually specify the MAMP directory path in command-line commands. How can the system be modified to enable use of just the "php" command instead of the entire MAMP path?

Answer:

To override the PHP path and prioritize MAMP, follow these steps:

  1. Create a .bash_profile file: In the user's home directory (e.g., "/Users/David"), create a ".bash_profile" file using a text editor (e.g., vim).
  2. Add environment variables: In the ".bash_profile" file, create two environment variables:

    • export MAMP_PHP=/Applications/MAMP/bin/php/php5.3.6/bin
    • export PATH="$MAMP_PHP:$PATH"
  3. Set the path precedence: The $PATH variable includes /usr/bin, where the system PHP resides. By placing the MAMP PHP path ahead of $PATH, the system will prioritize the MAMP version.
  4. Save and reboot Terminal: Save the ".bash_profile" file and restart Terminal.
  5. Verification: To confirm that the MAMP version is being used, run the following commands:

    • php -v: Should output the MAMP PHP version (e.g., 5.3.6).
    • which php: Outputs the path to the executable being used (should now be the MAMP PHP path).

The above is the detailed content of How to Prioritize MAMP PHP in the Terminal on Mac?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!