{"id":1044,"date":"2024-12-05T06:59:41","date_gmt":"2024-12-05T06:59:41","guid":{"rendered":"https:\/\/blog.trustedhosting.in\/?p=1044"},"modified":"2024-12-05T06:59:41","modified_gmt":"2024-12-05T06:59:41","slug":"installing-php-modules","status":"publish","type":"post","link":"https:\/\/www.webystrata.com\/blog\/installing-php-modules\/","title":{"rendered":"Installing PHP modules"},"content":{"rendered":"<h1><a href=\"https:\/\/www.trustedhosting.in\/cpanel-hosting.html\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1042 size-full\" title=\"Installing PHP modules\" src=\"https:\/\/blog.trustedhosting.in\/wp-content\/uploads\/2024\/12\/1013994_OJ8XXC0.jpg\" alt=\"Installing PHP modules\" width=\"1300\" height=\"1300\" srcset=\"https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/1013994_OJ8XXC0.jpg 1300w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/1013994_OJ8XXC0-300x300.jpg 300w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/1013994_OJ8XXC0-1024x1024.jpg 1024w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/1013994_OJ8XXC0-150x150.jpg 150w, https:\/\/www.webystrata.com\/blog\/wp-content\/uploads\/2024\/12\/1013994_OJ8XXC0-768x768.jpg 768w\" sizes=\"auto, (max-width: 1300px) 100vw, 1300px\" \/><\/a><\/h1>\n<h1>Installing PHP modules<\/h1>\n<p>The default installation of PHP as described in\u00a0<a href=\"https:\/\/www.trustedhosting.in\/cpanel-hosting.html\" target=\"_blank\" rel=\"noopener\"><span class=\"doc\">Installing PHP<\/span>\u00a0<\/a>will install the following PHP modules:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"gp\">[root@websrv ~]# <\/span>php -m\r\n<span class=\"go\">[PHP Modules]<\/span>\r\n<span class=\"go\">bz2<\/span>\r\n<span class=\"go\">calendar<\/span>\r\n<span class=\"go\">Core<\/span>\r\n<span class=\"go\">ctype<\/span>\r\n<span class=\"go\">curl<\/span>\r\n<span class=\"go\">date<\/span>\r\n<span class=\"go\">ereg<\/span>\r\n<span class=\"go\">exif<\/span>\r\n<span class=\"go\">fileinfo<\/span>\r\n<span class=\"go\">filter<\/span>\r\n<span class=\"go\">ftp<\/span>\r\n<span class=\"go\">gettext<\/span>\r\n<span class=\"go\">gmp<\/span>\r\n<span class=\"go\">hash<\/span>\r\n<span class=\"go\">iconv<\/span>\r\n<span class=\"go\">json<\/span>\r\n<span class=\"go\">libxml<\/span>\r\n<span class=\"go\">mysql<\/span>\r\n<span class=\"go\">mysqli<\/span>\r\n<span class=\"go\">openssl<\/span>\r\n<span class=\"go\">pcntl<\/span>\r\n<span class=\"go\">pcre<\/span>\r\n<span class=\"go\">PDO<\/span>\r\n<span class=\"go\">pdo_mysql<\/span>\r\n<span class=\"go\">pdo_sqlite<\/span>\r\n<span class=\"go\">Phar<\/span>\r\n<span class=\"go\">readline<\/span>\r\n<span class=\"go\">Reflection<\/span>\r\n<span class=\"go\">session<\/span>\r\n<span class=\"go\">shmop<\/span>\r\n<span class=\"go\">SimpleXML<\/span>\r\n<span class=\"go\">sockets<\/span>\r\n<span class=\"go\">SPL<\/span>\r\n<span class=\"go\">sqlite3<\/span>\r\n<span class=\"go\">standard<\/span>\r\n<span class=\"go\">tokenizer<\/span>\r\n<span class=\"go\">xml<\/span>\r\n<span class=\"go\">zip<\/span>\r\n<span class=\"go\">zlib<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<p>That\u2019s quite a lot of modules, thanks to\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">php-common<\/span><\/code>, but different websites often need different modules installing, and there are a couple of ways to install them.<\/p>\n<section id=\"package-manager-method\">\n<h2>Package manager method<\/h2>\n<p>In the below example, we\u2019ll install the\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">SOAP<\/span><\/code>\u00a0extension using the systems default package manager,\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">yum<\/span><\/code>.<\/p>\n<p>After using\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">php<\/span>\u00a0<span class=\"pre\">-m<\/span><\/code>\u00a0as above, we can see that\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">SOAP<\/span><\/code>\u00a0is not in the list.<\/p>\n<p>To install, use the following command:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"go\">yum install php-soap<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<p>The format of that command could be changed to install<a href=\"https:\/\/www.trustedhosting.in\/cpanel-hosting.html\" target=\"_blank\" rel=\"noopener\"> different modules<\/a>, so you could install\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">imap<\/span><\/code>\u00a0or\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">snmp<\/span><\/code>\u00a0with the following commands:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"go\">yum install php-imap<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"go\">yum install php-snmp<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<p>After you\u2019ve accepted this, the install will run and you can re-run\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">php<\/span>\u00a0<span class=\"pre\">-m<\/span><\/code>\u00a0to confirm that the module is now in the list.<\/p>\n<p>A restart of your web server will be needed to load this new module in before your web server can access it:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"go\">service httpd restart<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/section>\n<section id=\"pecl\">\n<h2>PECL<\/h2>\n<p>Some modules may not be available in your standard repositories, but fear not. As long as you have the\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">php-pear<\/span><\/code>\u00a0package installed, you\u2019ll have access to\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">pear<\/span><\/code>\u00a0and\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">pecl<\/span><\/code>, which are like package managers especially for PHP.<\/p>\n<p>In this example, we\u2019ll be installing the Memcached module for PHP.<\/p>\n<p>The command to start it all off is:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"go\">pecl install memcache<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<blockquote>\n<div>\n<div class=\"admonition note\">\n<p>Using pecl will often need you to install a few dependencies.<\/p>\n<p>Which ones will depend on what\u2019s installed on your system already, but in the above example on a CentOS minimal install, I had to install\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">gcc<\/span><\/code>,\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">make<\/span><\/code>\u00a0and\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">zlib-devel<\/span><\/code><\/p>\n<\/div>\n<\/div>\n<\/blockquote>\n<p>PECL installs often ask a few questions during the install process. If you\u2019re not too sure what to put, hitting enter will accept the default value.<\/p>\n<p>Once this has finished, you\u2019ll have to tell PHP where it can find it\u2019s new module, as the text on complete will tell you.<\/p>\n<p>In the Memcached example, the following line needs to be added to your PHP configuration:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"go\">extension=memcache.so<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<p>This could just be added to the bottom of\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">\/etc\/php.ini<\/span><\/code>, but to keep things neat I opted to put it in the following file:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"go\">\/etc\/php.d\/memcache.ini<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<p>The file likely won\u2019t exist, and you can call it what you want as long as it ends in\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">.ini<\/span><\/code><\/p>\n<p>After you\u2019ve done this, the install will run and you can re-run\u00a0<code class=\"docutils literal notranslate\"><span class=\"pre\">php<\/span>\u00a0<span class=\"pre\">-m<\/span><\/code>\u00a0to confirm that the module is now in the list.<\/p>\n<p>A restart of your webserver will be needed to load this new module in before your webserver can access it:<\/p>\n<div class=\"highlight-console notranslate\">\n<div class=\"highlight\">\n<pre><span class=\"go\">service httpd restart<\/span><\/pre>\n<\/div>\n<\/div>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>Installing PHP modules The default installation of PHP as described in\u00a0Installing PHP\u00a0will install the following PHP modules: [root@websrv ~]# php&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1042,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1044","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-latest-updates"],"_links":{"self":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts\/1044","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/comments?post=1044"}],"version-history":[{"count":1,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts\/1044\/revisions"}],"predecessor-version":[{"id":1045,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/posts\/1044\/revisions\/1045"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/media\/1042"}],"wp:attachment":[{"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/media?parent=1044"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/categories?post=1044"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webystrata.com\/blog\/wp-json\/wp\/v2\/tags?post=1044"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}