Installing PHP Package on Azure Website Using PEAR Package Manager
1. Download go-pear.phar for Windows from https://pear.php.net/manual/en/installation.getting.php
2. Copy "go-pear.phar" file to website root (/site/wwwroot)
3. Run "php go-pear.phar" at website root.
Navigate to Kudu console (https://<your-site-name>.scm.azurewebsites.net/DebugConsole ), select a command interface from "Debug console":
Select "local" to install a local copy, confirm your selection
You may see some warning message, and ask you to alter php.ini file, enter "n" for not altering php.ini
You should see "Thanks for using go-pears!" message at the end of installation.
4. Use "pear list" command to check if the package(s) you need is installed.
Run "pear install <package name>" to install more packages.
Installation option "-a" (--alldeps) will install all required and optional dependencies, for example,
Mail package has dependency with Auth_SASL, Net_SMTP,
"pear install -a Mail" will help you solve the dependencies, so that you do not need to install them separately.
Note: To make "pear install" use current pear.ini, add -c option, eg. "pear -c D:\home\site\wwwroot\pear.ini install -a Mail"
You can use installation option "-f" (--force) to overwrite newer installed packages, use it when needed.
Check your packages with the command "pear list" again after installation to make sure they are installed properly.
All installed packages are located under "/wwwroot/pear", you can find them from there.
5. In the case you use default PHP runtime environment on Azure, you cannot modify php.ini to include pear path,
you will need to do this in .user.ini, add following line in your .user.ini:
include_path=".;D:\home\site\wwwroot\pear"
6. When use the package in your php code, you should give the partial path name as well, for example:
require_once "pear/Mail.php";
Note: To use composer, refer to https://blogs.msdn.com/b/azureossds/archive/2015/04/02/setting-up-email-client-in-wediamiki.aspx
Comments
- Anonymous
July 13, 2017
This doesn’t work. When I follow these steps, after entering “php go-pear.phar” in the bash console, it comes up with this:“/home/site/wwwroot>php go-pear.pharBelow is a suggested file layout for your new PEAR installation. Tochange individual locations, type the number in front of thedirectory. Type ‘all’ to change all of them or simply press Enter toaccept these locations.1. Installation base ($prefix) : /home/pear2. Temporary directory for processing : /tmp/pear/install3. Temporary directory for downloads : /tmp/pear/install4. Binaries directory : /home/pear/bin5. PHP code directory ($php_dir) : /home/pear/share/pear6. Documentation directory : /home/pear/docs7. Data directory : /home/pear/data8. User-modifiable configuration files directory : /home/pear/cfg9. Public Web Files directory : /home/pear/www10. System manual pages directory : /home/pear/man11. Tests directory : /home/pear/tests12. Name of configuration file : /home/.pearrc1-12, ‘all’ or Enter to continue: Beginning install…PEAR_Config::writeConfigFile fopen(‘/home/.pearrc’,’w’) failed (fopen(/home/.pearrc): failed to open stream: Permission denied)”How do I resolve this issue?