Hướng dẫn php gd extension enable

Trang chủ » Hướng dẫn sửa lỗi The required PHP extension GD could not be found trên xampp và VPS

Hướng dẫn fix lỗi The required PHP extension GD could not be found. Please ask your host to install this extension khi cài xenforo trên xampp và máy chủ ảo [VPS]

Lỗi này có nghĩa là phần mở rộng [extension] GD chưa được kích hoạt trên xampp , thông thường thì PHP 7 trở lên sẽ không có sẵn phần mở rộng GD, khi cài đặt một số script ví dụ như xenforo thì sẽ báo lỗi như trên. Vậy làm sao để sửa lỗi này?

Cách sửa lỗi The required PHP extension GD could not be found. Please ask your host to install this extension trên Xampp:

  • Bạn tắt Apache đi rồi ấn vào config, sửa file php.ini
  • sau đó tìm dòng ;extension=gd
  • Xoá dấu chấm phẩy ; ở đầu dòng đi và lưu lại
  • Khởi động lại xampp là xong

Cách fix lỗi The required PHP extension GD could not be found. Please ask your host to install this extension trên Vps:

  • Đối với vps thì các bạn mở teminal lên và chạy lệnh sau

sudo apt-get install php7.0-gd

Trên đây tôi đã hướng dẫn anh em các fix lỗi The required PHP extension GD could not be found. Please ask your host to install this extension  trên xamppvà VPS rồi.

Chúc anh em cồng thanh!

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    XAMPP is a free, easy-to-install Apache distribution containing MariaDB, PHP, and Perl. It allows you to build WordPress sites offline, on a local web server on your computer. It was first released in 2002. It is owned by Apache Friends and The PHP GD Graphics Library is a graphics software library for dynamically manipulating images. Its native programming language is ANSI C. 

    In this article, we will know how can we install PHP GD in Xampp.

    Installing PHP GD in Xampp:

    Follow the below steps to install PHP GD in Xampp:

    Step 1: Openthe XAMPP Control Panel from the taskbar of your system.

    Step 2: Start Apache & MySQL

    Step 3: Click on Config of Apache

    Step 4: Click on php.ini Which will further open a document file.

    Step 5: Open that file search for extension=fileinfo

    Step 6: Add extension=gd on the next line after extension=fileinfo and then save the file and close it.

    Step 7: Again navigate to your Xampp control panel and restart the apache server.

    That’s it Now PHP GD is successfully installed in your XAMPP.

    I want to convert the image in low resolution with GD. I'm working on IBM Server under these speces Version: PHP 7.0.15-0ubuntu0.16.04.4 [cli] [ NTS ]
    and I have also comment out the extension from php.ini but can't enabled the GD on php server. I Just received this error.

    Run Command: sudo apt-get install libgd

    Reading package lists... Done

    Building dependency tree Reading state information... Done E: Unable to locate package libgd

    Second Command When I run give this message:

    1] packages have unmet dependencies

    and after running this command received this:

    Command: sudo apt-get install libgd-dev

    Reading package lists... Done

    Building dependency tree

    Reading state information... Done

    You might want to run 'apt-get -f install' to correct these:

    The following packages have unmet dependencies: libgd-dev : Depends: libgd3 [= 2.1.1-4ubuntu0.16.04.6] but it is not going to be installed

             Depends: libpng-dev
    
             Depends: libz-dev
    
             Depends: libjpeg-dev
    
             Depends: libfreetype6-dev but it is not going to be installed
    
             Depends: libxpm-dev but it is not going to be installed
    
             Depends: libx11-dev but it is not going to be installed
    
             Depends: libxt-dev but it is not going to be installed
    
             Depends: libfontconfig-dev
    
             Depends: libvpx-dev but it is not going to be installed
    
             Depends: libtiff-dev
    

    linux-image-virtual : Depends: linux-image-4.4.0-81-generic but it is not going to be installed

    E: Unmet dependencies. Try 'apt-get -f install' with no packages [or specify a solution].

    Cause of this Problem:

    PHP Fatal error: Uncaught Error: Call to undefined function imagecreatefromstring[]

    Note please anyone tell me the step-by-step command to enable this GD Library on my this Linus machine. thanks alot

    Cài đặt và kích hoạt thư viện GD cho PHP5

    In English…

    Mò cái này mất mấy tuần mới làm được, hehe. Lý do là các tài liệu google được đều chỉ hướng dẫn cài đặt GD mà không hề hướng dẫn kích hoạt. Trong bài viết này tôi sẽ hướng dẫn các bạn cài đặt và kích hoạt GD luôn. 😀

    Thư viện GD trong PHP được sử dụng vào các việc nên quan đến tạo ảnh, nén ảnh, chỉnh sửa ảnh,… trong PHP. Hầu hết các website hiện nay đều sử dụng script mà khi hoạt động cần phải có thư viện GD. Tôi lấy ví dụ khi bạn cài CMS NukeViet, nếu chưa cài đặt và kích hoạt GD cho PHP thì bạn sẽ bị chặn ngay ở bước cài đặt với thông báo “User Error GD not installed“. Một ví dụ khác là nếu không có GD thì cũng không thể sử dụng captcha trong các mã nguồn như VBB, MyBB,…

    Để kiểm tra thư viện GD đã được cài đặt và kích hoạt chưa các bạn có thể xem phpinfo bằng cách tạo 1 file tên là phpinfo.php với nội dung như sau:

    Sau đó chạy file này trên trình duyệt. Nếu thấy trong trang hiện ra không có GD thì tức là GD vẫn chưa được cài đặt và kích hoạt.

    Để cài đặt và kích hoạt thư viện GD cho PHP các bạn làm theo các bước sau:

    Bước 1: Cài đặt GD cho hệ thống.

    Các bạn cài đặt bằng lệnh sau:

    sudo apt-get install php5-gd

    Bước 2: Kích hoạt GD để nó làm việc với PHP

    Mở file php.ini để chỉnh sửa bằng lệnh sau:

    sudo gedit /etc/php5/apache2/php.ini

    Sau đó tìm dòng extension=mysql.so [khoảng dòng thứ 936 gì đó] và chèn đoạn này vào dòng bên dưới:

    extension=gd.so

    Bước 3: Restart Apache để nhận kết quả.

    sudo /etc/init.d/apache2 restart

    Bây giờ vào xem phpinfo các bạn sẽ thấy GD được kích hoạt 😉

    Chúc vui vẻ :”>

    1973 [BKF]

    Post navigation

    PHP is a server-side scripting language commonly used in development of websites. It is also used for creating and manipulating images files in different image formats such as JPEG, WBMP, PNG, GIF, etc. PHP handles all the image manipulation needs using the GD library. GD [stands for Graphic Draw] is an open-source code library that is required for creating and manipulating images in PHP. Along with creating JPEG, PNG, and GIF images, it can also create graphs, charts, and thumbnails. PHP and GD may also need additional libraries based on the image formats you want to deal with.

    This article covers how to use apt-get to install php-gd in Linux OS. We will perform the entire procedure on Ubuntu OS. However, you can also use this procedure on Debian and Mint OS.

    We will install the php-gd package from the Ubuntu default repositories. Let’s get started.

    1. First, update the local repository index using the command below:

    2. Then run the command below to install php and php-gd using the command below:

    $ sudo apt-get install php7.4 php7.4-gd

    It will list the php and php-gd packages along with dependencies that will be installed during this operation. Then it will ask for confirmation for the installation of these packages. Hit y and then Enter key to continue the operation.

    It might take some time for all the packages to be installed. Once installed, move on to the next step.

    3. Install Apache2 and libapache2-mod-php7.4 if not already installed on your system using the command below:

    $ sudo apt-get install apache2 libapache2-mod-php7.4

    Then verify if the Apache service is running using the command below:

    $ sudo systemctl status apache2

    If the service is not running, try to restart it.

    4. Then move inside the root directory of your website. We are using here the Apache default root directory /var/www/html:

    Then create test.php file using the command below:

    Add following line in the file:

    Now, save and close the test.php file.

    5. Open any web browser in your system and go to the following address:

    http://localhost /test.php

    or

    http://hostname-or-domain name>/test.php

    Once the above address opens, it will show you all the details about PHP installation on your system.

    Scroll down the webpage to the GD section. This section verifies that the GD library is installed on your system. It also tells all the details about the GD installation on your system.

    Another way to verify GD installation is to use the following command in your Terminal:

    The output similar to the following screenshot verifies that the GD library is installed in our system.

    This article covered how to use apt-get to install php-gd in Ubuntu OS. We also covered how to verify the installation of php-gd. I hope this will help you in the installation of php-gd on your Linux system.

    Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.

    Chủ Đề