Objective

The objective is to show how to enable and disable PHP curl module with Apache on Ubuntu Linux

Operating System and Software Versions

  • Operating System: - Ubuntu 16.04

Requirements

Privileged root access to your Ubuntu server is required in order to install, enable and disable PHP curl module.

Difficulty

EASY

Conventions

  • # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - requires given linux commands to be executed as a regular non-privileged user

Instructions

Installation of Curl module

Let's install Apache curl module along with Apache 2 webserver and PHP.
# apt install libapache2-mod-php php-curl
Restart the Apache webserver:
# service apache2 restart


Check for curl module state

Insert the following lines into a new PHP script eg. curl-check.php within /var/www/html/ directory:
<?php
echo 'Curl: ', function_exists('curl_version') ? 'Enabled' . "\xA" : 'Disabled' . "\xA";
?>
Make the script executable and use curl command to render the output of curl-check.php php code:
# chmod +x /var/www/html/curl-check.php
# curl localhost/curl-check.php
Curl: Enabled

Disable PHP curl module

To disable curl php module execute:
# phpdismod curl
# service apache2 restart
# curl localhost/curl-check.php
Curl: Disabled

Enable PHP curl module

To enable curl php module execute:
# phpenmod curl
# service apache2 restart
# curl localhost/curl-check.php
Curl: Enabled
ARE YOU LOOKING FOR A LINUX JOB?
Submit your RESUME or create a JOB ALERT on LinuxCareers.com job portal.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in:



Comments and Discussions