Warning : curl_init() has been Disabled for security reasons

Warning : curl_init() has been Disabled for security reasons

 

root@server [/home/user/public_html]# tail -f error_log

Warning : curl_init() has been Disabled for security reasons on line 15

 

I saw the above PHP warning in error_log of my website. Warning shows the PHP function curl_init() is disabled for your website.
 

How to enable curl_init() for all Websites on the server

 
1. Log into your linux server via SSH

2. Type “php –ini” command to check the main PHP configuration file.

On my server PHP configuration file is in /usr/local/lib directory.

==================
root@server [/]# php –ini
Configuration File (php.ini) Path: /usr/local/lib
Loaded Configuration File: /usr/local/lib/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
root@server [/]#
=================

3. Edit the file /usr/local/lib/php.ini using vi editor

4. Remove ‘curl_init’ from disable_functions in PHP.

root@server [/]# vi /usr/local/lib/php.ini
Change disable_functions =curl_init
TO
disable_functions =

Remove curl_init from PHP disable_functions and save the file. Now “curl_init” function is enabled server wide for all domains.
 


 

How to Enable curl_init function only for a single domain

 
1. Contact your hosting company and ask them to create a custom php.ini for the website by copying the main php.ini of the server to document root of the website.

2. Change the ownership of the copied php.ini file
 

root@server [/]# cp -a /usr/local/lib/php.ini /home/user/public_html/
root@server [/]# chown user:user php.ini

 
3. Open the custom php.ini file using vi editor

4. Remove curl_init from disable_functions line

5. Save the php.ini file and exit

Now “curl_init” is enabled only for the domain and not server-wide.