Local App. Right click on your site in the Site Sidebar and select
Open Site Shell. It will open a terminal
2) In that terminal, enter the command
which php. It will output the path of PHP. e.g. in my case, it shows this path:
/opt/Local/resources/extraResources/lightning-services/php-7.3.5+8/bin/linux/bin/php. Remove trailing /bin/php from that path and then note down remaining path somewhere. So for me, the path to note down will be
3) Now enter command
which phpize. It will return path of
phpize. Open that path in the editor of your choice. Under
#Variable Declaration section, you will see a variable
prefix. Change path of that variable with the path we noted down in step 2. Similar changes need to be done in the path of
datarootdir. Replace path up to
build fragment of
datarootdir variable with path noted in step 2. Save the file.
4) Next, we have to change paths in php-config . Run the following command to find the path of phpconfig: which php-config . Open that path in the editor of your choice. Change path of
prefix variable with the path we obtained in Step 2. Replace path up to
build fragment of
extension_dir variables with path noted in Step 2. After making these changes, save the file.
5) Let’s install dependencies required for pecl to work properly. Run command
sudo apt-get update && sudo apt-get install gcc g++ make autoconf libc-dev pkg-config build-essential
app directory and run command
mkdir pear && wget http://pear.php.net/go-pear.phar && php go-pear.phar . This will create pear directory, download pear installation file and start the installation process. It will show where pear is going to be installed and ask if any path needs to be changed. We need to change two things
Installation base ($prefix) &
Name of configuration file . Enter
1 in terminal to change Installation Base. Set this path to pear directory created inside app directory. Once this is done enter
12 to change Name of Configuration file. Essentially, we are going to set path of
.pearrc file. We want to store
.pearrc inside pear directory created in app folder. Once this is done, press Enter to continue.
7) It will ask if you want to alter php.ini file, press
Y and enter. Now installation will complete. Once it is complete, it will show success output & that output will have information about installed
pear's path which might look like below image. Note down
bin directory path shown in that output. That directory contains
pecl shell scripts. These scripts are used to install pear and pecl extensions.
Output after installing pear
8) We’ll have to set proper php path & extend
PATH env in pecl, pear-dev and pear’s shell scripts. Let’s start with pear first. So open pear file in your favorite editor, replace php paths in that file with path found from
which php command & add PATH env with path found in step 2. Check image below how it would look
9) In the same directory, you would find
pecl shell scripts. Follow above step for those scripts too.
10) Now we can install pecl & pear extensions we want. e.g. run command
sudo /path/to/pear/bin/pecl install psr . Once the extension is installed open php.ini file inside
/app/conf/php directory & add line
extension=/absolute/path/to/psr.so. Thats’ it! We are done!