Cara menggunakan enable curl php debian

Panduan cara install PHP 8.0 di Debian 9, 10 dan 11 serta extension PHP yang umum digunakan oleh website berbasis WordPress.

Membuat bash script untuk menambahkan paket PHP repository deb.sury.org

nano sury.sh

Isi dengan script berikut

#!/bin/sh # To add this repository please do: if [ "$(whoami)" != "root" ]; then SUDO=sudo fi ${SUDO} apt-get update ${SUDO} apt-get -y install apt-transport-https lsb-release ca-certificates curl ${SUDO} curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg //packages.sury.org/php/apt.gpg ${SUDO} sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] //packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' ${SUDO} apt-get update

CHMOD script bash tersebut

chmod 755 sury.sh

Eksekusi

./sury.sh

Install PHP 8.0

Berikut ini perintah untuk menginstall paket PHP 8.0 beserta extensionnya

apt install php8.0 -y apt install php8.0-bz2 -y apt install php8.0-curl -y apt install php8.0-gd -y apt install php8.0-imap -y apt install php8.0-intl -y apt install php8.0-imagick -y apt install php8.0-mbstring -y apt install php8.0-mysql -y apt install php8.0-odbc -y apt install php8.0-opcache -y apt install php8.0-tidy -y apt install php8.0-xsl -y apt install php8.0-xml -y apt install php8.0-xmlrpc -y apt install php8.0-soap -y apt install php8.0-zip -y

Install module Apache

Jika Anda menggunakan mod_php

apt install libapache2-mod-php8.0

Jika menggunakan PHP-FPM (FastCGI Process manager) install dan enable module Apache fcgid ini

apt install php8.0-fpm libapache2-mod-fcgid -y a2enmod proxy_fcgi setenvif a2enconf php8.0-fpm

Install PHP-FPM untuk Nginx

apt install php8.0-fpm -y

Selesai, semoga bermanfaat.

Often, web applications require HTTP based UserID and Password authentication, cookies, and form uploads. Even, user authentication with Google or Facebook sign-in is done via HTTP. In these types of cases, we need to request a particular service server(Like Google’s) for user validation and authentication token on our server. The entire process takes place through the service server’s APIs. The cURL helps our web applications to interact/communicate with those APIs on the HTTP level.

cURL: It is a library created by Daniel Stenberg. The cURL stands for client URL. It allows us to connect with other URLs and use their responses in our code. The cURL is a way that can hit a URL from our code to get an html response from it. The cURL is also used in command lines or scripts for data transfer. cURL with respect to PHP is a library that lets us make HTTP requests in PHP. It’s easier to do GET/POST requests with curl_exec to receive responses from other servers for JSON format data response and to download files.

Required to “enable” cURL: The cURL, by default, is not enabled in Apache. If we try to run CURL programs without enabling CURL in Apache, the browser will throw an error.

Fatal error: Call to undefined function curl_init()

.
To avoid this, we need to enable the CURL extension in the Apache server with the following methods in different environments.

Enable CURL in Apache: Enabling CURL in Apache by configuring php.ini file.

  • Step 1: Locate PHP.ini file, it is mostly in the server’s root folder or public_html then open the PHP.ini in a text editor
  • Step 2: Search or find the ;extension=php_curl.dll with Ctrl+F and remove the semi-colon ‘;’ before it to activate it.
  • Step 3: Save and Close PHP.ini with Ctrl+S and restart Apache from terminal/CMD

Enabling cURL in WAMP: WAMP is a software stack available for Windows that bundle Apache, MySQL, and PHP together. It’s an installation pack for installing the three web technologies on the Windows environment together in a hassle-free GUI guided fashion.

  • Step 1: Left-click on the WAMP server icon in the bottom right of the screen.
  • Step 2: PHP -> PHP Extensions -> curl.

Enabling CURL in Ubuntu: Run the following command:

  • This command installs the PHP CURL.sudo apt-get install php5-curl
  • This command starts with the Apache server.sudo service apache2 restart

Check if CURL is enabled or not: If we try to run a cURL PHP program without cURL being enabled, the browser will throw the following error.

  • Example:




    <?php

            // Create curl resource

            $ch = curl_init();

      

            sudo apt-get install php5-curl1

            sudo apt-get install php5-curl3$chsudo apt-get install php5-curl5sudo apt-get install php5-curl6sudo apt-get install php5-curl7

      

            sudo service apache2 restart0

            sudo apt-get install php5-curl3$chsudo service apache2 restart4

      

            sudo service apache2 restart7

            sudo service apache2 restart9 <?php0$chsudo apt-get install php5-curl7

      

            <?php5 sudo service apache2 restart9<?php7

      

                    0

                    2$ch        4

            5

  • Output: This page of GeekforGeeks is now rendered on my localhost running the Apache server. The HTML content is “echoed” as the output.

PHP is a server-side scripting language designed specifically for web development. You can learn PHP from the ground up by following this PHP Tutorial and PHP Examples.

Postingan terbaru

LIHAT SEMUA