Php modules or extensions are pieces of code for PHP, which extends the basic functions and add or improve the existing functions. Some of them are already bundled with PHP and can be easily enabled or disabled. There are also external PHP modules which can be installed to system and then enabled in PHP. Even though you now have installed the PHP you still may come across some issues. Some of the frameworks or libraries will possibly need use of some module which wasn’t added to php. Don’t stress here. It’s absolutely ok, as there are currently around 150 php modules out there. If you had all of them activated at once, they would rapidly slow down your system and eat all your memory. For that reason you should have enabled only modules which you really need.
How do I know which modules I need?
Well, that’s great question. Some frameworks will tell you at installation or in documentation. But anyway, you don’t need to know. Usually the framework or php script will throw you exception or issue warnings, so you will know exactly which modules to install. When you become a bit more professional, you will know these modules and you will want to use the features they add, so you will install them yourself.
Enable modules
You may come to this issue:
[PDO Exception]
Could not find driver
The above error message is caused by missing php5-mysql
extension. Before we turn it on we should check if it is
available in system. I do it usually by searching
Installing on CentOS
sudo yum -y install php5-mysql
Installing on Ubuntu or Debian systems
sudo apt-get -y install php5-mysql
Enable rewrite module with
sudo php5enmod php5-mysql
you will see the status of the module and message that you need to restart apache before the configuration change becomes active
Enabling module php5-mysql.
To activate the new configuration, you need to run:
service apache2 restart
so just simply run
service apache2 restart
Mcrypt module installation
If your system asks for mcrypt module, the step are very similar to above
sudo yum -y install mcrypt
sudo php5enmod mcrypt
sudo apachectl restart