If you are running a cPanel server, you are able to use EasyApache to add and remove many PHP extensions. cPanel has the ability to also install and uninstall PHP modules on the fly using the phpextensionmgr, which can be found at /scripts/phpextensionmgr. You are able to see the usage and option by using the –help flag, as shown below.
[email protected] [~]# /scripts/phpextensionmgr --help Usage: phpextensionmgr [options] [action] [extension] Options: --help Help message --prefix Installation prefix for PHP (normally /usr/local or /usr/local/php4) Actions: install Install or update the extension uninstall Uninstall the extension status Display the installation status of the extension list Show available extensions
As you can see, you are able to install, uninstall, display whether or not the extension is installed, or list all of the available modules. Running the list command as below will show all of the modules that are available to be added on your server.
[email protected] [~]# /scripts/phpextensionmgr list Available Extensions: EAccelerator IonCubeLoader Zendopt Xcache SourceGuardian PHPSuHosin
You can also find the status of a single module by using the status flag.
[email protected] [~]# /scripts/phpextensionmgr status Xcache Updating md5sum list Fetching http://httpupdate.cpanel.net/cpanelsync/easy/targz.yaml (connected:0)....... (request attempt 1/12)...Using dns cache file /root/.HttpRequest/httpupdate.cpanel.net ......searching for mirrors (mirror search attempt 1/3)...... mirror search success......connecting to 69.72.212.10... @69.72.212.10......connected......receiving...100%......request success......Done Downloading tarball for Xcache Fetching http://httpupdate.cpanel.net/cpanelsync/easy/targz/Cpanel/Easy/Xcache.pm.tar.gz (connected:0)....... (request attempt 1/12)......connecting to [email protected] receiving...100%......request success......Done Determining status of Xcache Xcache extension is NOT installed
If we wanted to install Xcache, we would use the install flag, which will take care of the entire install process. Keep in mind that we are only using Xcache as an example and it’s usage will depend on your server configuration as well.
[email protected] [~]# /scripts/phpextensionmgr install Xcache Installing Xcache Determining PHP version Configuring for: PHP Api Version: 20090626 Zend Module Api No: 20090626 Zend Extension Api No: 220090626 Will now run system( ./configure,--with-php-config=/usr/local/bin/php-config ) checking for egrep... grep -E checking for a sed that does not truncate output... /bin/sed checking for cc... cc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether cc accepts -g... yes checking for cc option to accept ANSI C... none needed ..... ..... (More compiling stuff) .... .... /bin/sh /home/cpeasyapache/phpextensions/xcache/xcache-1.3.2/libtool --mode=install cp ./xcache.la /home/cpeasyapache/phpextensions/xcache/xcache-1.3.2/modules cp ./.libs/xcache.so /home/cpeasyapache/phpextensions/xcache/xcache-1.3.2/modules/xcache.so cp ./.libs/xcache.lai /home/cpeasyapache/phpextensions/xcache/xcache-1.3.2/modules/xcache.la PATH="$PATH:/sbin" ldconfig -n /home/cpeasyapache/phpextensions/xcache/xcache-1.3.2/modules ---------------------------------------------------------------------- Libraries have been installed in: /home/cpeasyapache/phpextensions/xcache/xcache-1.3.2/modules If you ever happen to want to link against installed libraries in a given directory, LIBDIR, you must either use libtool, and specify the full pathname of the library, or use the `-LLIBDIR' flag during linking and do at least one of the following: - add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution - add LIBDIR to the `LD_RUN_PATH' environment variable during linking - use the `-Wl,--rpath -Wl,LIBDIR' linker flag - have your system administrator add LIBDIR to `/etc/ld.so.conf' See any operating system documentation about shared libraries for more information, such as the ld(1) and ld.so(8) manual pages. ---------------------------------------------------------------------- Build complete. Don't forget to run 'make test'. Got ret value 0 from system( make ) Will now run system( make,install ) Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20090626/ Got ret value 0 from system( make,install ) Will now run system( make,clean ) find . -name \*.gcno -o -name \*.gcda | xargs rm -f find . -name \*.lo -o -name \*.o | xargs rm -f find . -name \*.la -o -name \*.a | xargs rm -f find . -name \*.so | xargs rm -f find . -name .libs -a -type d|xargs rm -rf rm -f libphp.la modules/* libs/* Got ret value 0 from system( make,clean ) Xcache extension activated ./cpanel-install exiting with exit code 0
If you wanted to remove that module, you could do so with the uninstall flag.
[email protected] [~]# /scripts/phpextensionmgr uninstall Xcache
Uninstalling Xcache
Removing xcache from /usr/local/lib/php.ini
Using /scripts/phpextensionmgr can help you to add, remove, find the status of particular modules and list the available modules. In you day to day work, this can help you to save time by not needing to run EasyApache to install the PHP modules which can save time and unnecessary load on your server.