Tuesday, May 31, 2016

How to enable extensions in PHP 7

Lets see how to enable cURL extension in PHP7


When yo update ubuntu on 16.04 or latest version then php upgrade to 6 to 7. 

Note: This guide is for those who have FULL access to the server, when system configuration can be changed. If you are using shared hosting, please contact your hosting provider.
Step 1: Check whether cURL extension is installed/enabled or not
To create a phpinfo file, open a plain text file, add the following lines, and save:
Filename: phpinfo.php
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
Visit the page in your browser. If you uploaded it to your html directory, you should now visithttp://www.example.com/phpinfo.php, replacing example.com with your own domain name.
At this point, search for the keyword “curl” and if it does not appear on the page, the extension might not be installed/enabled. Please proceed to the next step.
P.S: In this step, you are also able to locate where the “php.ini” configuration file is. Search forLoaded Configuration File” and you might end up with something like:
Step 2: Ensure cURL extension for PHP is installed
On Windows, people often use WAMP (Windows, Apache, MySQL, PHP) bundles for local development. Fortunately, cURL extension is pre-installed with those bundles, so you can proceed to Step 3.
On Linux, it depends on which Linux distro the server is installed with, so you might need to run the appropriate command.
For example, with Ubuntu/Debian server, you need to run this command:
for php7:-
sudo apt-get install php7.0-curl
After that, restart the Apache server:
sudo service apache2 restart
for php5:-
sudo apt-get install php5-curl
After that, restart the Apache server:
sudo /etc/init.d/apache2 restart
After the Apache server has restarted, the extension should be enabled by default. You might use the method at Step 1 to check, and if not, please proceed to the next step.
Step 3: Enable cURL extension in “php.ini” file
Load the “php.ini” file located in Step 1 into your favorite text editor (if you are using Windows, we suggest Notepad++), then search for “php_curl”. At this point, you need to uncomment the line by removing the semicolon at the beginning of the line, as below.
After saving the file, restart the Apache server. Go to phpinfo page again to see if the extension is enabled.
If you see something like that, then congratulations, you have successfully enabled PHP cURL!