Mamp Pro Install PHP extension steps detailed

Source: Internet
Author: User
Tags install php ini install homebrew install mongodb mongodb phpinfo redis install redis
These days because of the need to use the Mac to do PHP development, installed a trial version of Mamp Pro, the overall feeling very good, but also free to choose the PHP version, Apache expansion, very convenient to create a website and automatically modify the system hosts files.

Mamp and Mamp Pro are two independent software, Mamp can run separately, supporting simple operations such as PHP version switching, Apache/nginx switching, start/stop services, etc. Mamp Pro can not run independently, it needs to rely on Mamp software, in fact, Mamp Pro is mamp a powerful control panel, and provides some mamp itself does not support the functions (such as the modification of hosts, DDNS, easy to modify the PHP operating mode and the Apache module, Easy to add and manage virtual sites, etc., the price is less than 400 yuan, you deserve to have ~

Because my project many depend on Redis do cache and queue, occasionally also have the need to use MongoDB, or install Phalcon framework and so on, and mamp do not support these extensions, and did not provide any way to install these extensions, can only go toss ~ ~ All kinds of information, look at the document ....
The following is an example of installing Redis, as in other extension methods.

First need to install Redis, I am lazy, directly with the brew installed

Brew Install Redis

Next installs the Php-redis extension, this can download the source code to compile by oneself, or look for corresponding own PHP version of redis.so.
Because the mamp inside the integrated PHP version does not include the header file, download their own compiled words will certainly be wrong, the specific solution to find information on their own. Of course, I am lazy, so:


Brew Install Homebrew/php/php56-redis

Because I am using PHP5.6, so it is Php56-redis, this method is very convenient, simple, but the problem is that brew will automatically install a PHP5.6.19 to/usr/local/cellar directory.
And the installed Redis extension is placed in the/usr/local/cellar/php56-redis/2.2.7_1/redis.so
The next step is to modify the PHP configuration file. In front of the mamp inside each PHP version of the corresponding directory has a Conf/php.ini file, is naturally PHP configuration file, so modify this file, in the extension of the section to add the following code


Extension=/usr/local/cellar/php56-redis/2.2.7_1/redis.so

After the test, Php-m said that the Redis extension has been loaded and that the Mamp boot service can load the Redis extension normally, but the extension cannot be loaded with Mamp Pro.
This is always really a headache for a while, finally think of phpinfo to see which configuration file is loaded, and eventually navigate to the location of the configuration file in/Library/Application Support/appsolute/mamp Pro/conf/php.ini. It is also found that the configuration files that are loaded using module mode and CGI are not the same, but they are all under this directory. So try to modify this file to add the Redis extension path.
The problem arises, or failed to load Redis expansion, and then to see just modified the php.ini file, found that all the changes are missing (visible Mamp Pro every time the service will be regenerated this configuration file, so just the changes have disappeared).
There is no way, can only go to the official online to find a way out, the English document a variety of turn, and even basic operations have looked at, and finally found a way to ~~--template ~

Although the official website does not say what this template can do, it is obvious that this is the template that is used to regenerate php.ini and httpd.conf files each time the service is started.

To modify the method:

Click menu –> file–> Edit template–> php–> PHP 5.6.10 php.ini

Then a warning pops up and a file like PHP.ini is opened, and you can see that many of the key places in this file have been replaced with mamp variables. Directly as before, add the contents of the Redis extension to the extended section, save and restart the Mamp service.
Once again Phpinfo found that the Redis extension was finally successfully loaded ... Really all the way toss, but also be to Mamp Pro this software has a deeper layer of understanding, later in use will also be more convenient.
Install MongoDB and so on it extends the method also similar to this, a brief summary:
    • If you do not use Mamp Pro, you can modify the php.ini directly in the/application/mamp/bin/php/php-x.x.x/conf directory, and it will take effect
    • If you use Mamp Pro you must modify the template to take effect
The first edition is the following processes:
    1. Download or compile an extension (typically. so file)
    2. Modify the php.ini template for Mamp Pro

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.