Hướng dẫn exif extension php

Chào các bạn,
Việc cài đặt thêm module hay extension cho Directadmin sử dụng custombuild rất có thể dẫn tới lỗi do phải build php. Vì vậy mình hướng dẫn các bạn cài đặt extension trên directadmin như sau để an toàn mà vẫn đáp ứng được yêu cầu sử dụng của người dùng. Các bước thực hiện như sau:

# cd /usr/local/directadmin/custombuild
# ls -l | grep php

Bước này nếu grep PHP ra vài phiên bản PHP thì bạn cần xác định cài cho phiên bản PHP 5.x hay 7.x. Ở dây mình đang sử dụng là 7.x nên sẽ cài. Còn nếu các bạn là 5.x thì cần thay thế thư mục của php 5.x tương ứng nhé.

# tar xvzf php-7.0.27.tar.gz
# ls -la
# cd php-7.0.27
# cd ext/exif/
# /usr/local/php70/bin/phpize
# ./configure --with-php-config=/usr/local/php70/bin/php-config
# make
# make install
# vi /usr/local/php70/lib/php.ini

Thêm dòng sau vào:

... ; extension_dir = "ext" extension=exif.so ...
#service httpd restart

Như vậy là đã hoàn thành việc cài đặt. Để check lại các bạn dùng lệnh

#php -m | grep exif

Hoặc dùng file phpinfo để check nhé.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Ở trên mình hướng dẫn các bạn cài đặt PHP 7.x còn các lệnh dưới đây sẽ cài đặt trên PHP 5.x:

Bước 1:

[root@webserver ~]# cd /usr/local/directadmin/custombuild

Bước 2:

[root@webserver custombuild]# ls -l | grep php
-rw-r--r-- 1 root root 18428932 Jun 23 18:40 php-5.6.23.tar.gz

Bước 3:

[root@webserver custombuild]# tar -xvzf php-5.6.23.tar.gz

Bước 4:

[root@webserver custombuild]# cd php-5.6.23
[root@webserver php-5.6.23]#

Bước 5:

[root@webserver php-5.6.23]# cd ext/exif/
[root@webserver exif]#

Bước 6:

[root@webserver exif]# /usr/local/php56/bin/phpize
Configuring for:
PHP Api Version: 20131106
Zend Module Api No: 20131226
Zend Extension Api No: 220131226

Bước 7:

[root@webserver exif]# ./configure --with-php-config=/usr/local/php56/bin/php-config
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out

Bước 8:

[root@webserver exif]# make
...
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/directadmin/custombuild/php-5.6.23/ext/exif/modules
Build complete.
...

Bước 9:

[root@webserver exif]# make install
Installing shared extensions: /usr/local/php56/lib/php/extensions/no-debug-non-zts-20131226/
[root@webserver exif]# cd /usr/local/php56/lib/php/extensions/no-debug-non-zts-20131226/
[root@webserver no-debug-non-zts-20131226]# ls
exif.so opcache.a opcache.so

Bước 10: Chèn thêm đoạn trên vào php.ini của bạn.

...
; extension_dir = "ext" extension=exif.so
...

Như vậy là đã cài xong rồi đó.

Chúc các bạn thành công!

I moved my website to a vps and I used exif function but look like in this new server exif not installed or enabled.. I tied many ways to enable it but no success:

Nội dung chính

  • Not the answer you're looking for? Browse other questions tagged linux centos apache-2.4 centos7 or ask your own question.
  • User Contributed Notes
  • User Contributed Notes
  • How do I install exif extension?
  • What is EXIF PHP extension?
  • How do I enable PHP extensions in cPanel?

Information:

Linux, Apache, Centos7

First, I run php -m but there is no exif in list.

options.conf

php1_release=7.2
php1_mode=mod_php

configure.php72

--enable-mbstring \
--enable-exif

php.ini

extension=php_mbstring.dll
extension=php_exif.dll   

But still I got:

PHP Fatal error: Uncaught Error: Call to undefined function exif_read_data() in...

Any idea?

asked Mar 19, 2019 at 6:12

1

If php.ini contents is like this:

1   extension=php_mbstring.dll
2   extension=php_exif.dll

make sure in your PHP installation ext directory php_exif.dll is present.

If it's not there, get it from here.

answered Mar 19, 2019 at 8:02

OvermindOvermind

2,9702 gold badges15 silver badges24 bronze badges

I'm using PHP 8 here.

Edit your php.ini which is probably in /etc/php

Page down to "Dynamic Extensions"

Uncomment this line...

extension=exif

Save.

Exif is included, so there's nothing to install.

Restart php-fpm for the changes to take effect.

answered Feb 26 at 9:44

PJ BrunetPJ Brunet

5561 gold badge5 silver badges15 bronze badges

Not the answer you're looking for? Browse other questions tagged linux centos apache-2.4 centos7 or ask your own question.

Change language:

Submit a Pull Request Report a Bug

To enable exif-support configure PHP with --enable-exif

Windows users must enable both the php_mbstring.dll and php_exif.dll DLL's in php.ini. The php_mbstring.dll DLL must be loaded before the php_exif.dll DLL so adjust your php.ini accordingly.

+add a note

User Contributed Notes

There are no user contributed notes for this page.

Change language:

Submit a Pull Request Report a Bug

Your PHP must be compiled in with --enable-exif. To enable multibyte support in EXIF tags, the mbstring extension must be enabled by compiling PHP with --enable-mbstring. PHP does not require any additional library for the exif module.

Windows only: The mbstring extension must always be enabled. Note that mbstring extension must be loaded prior to EXIF in php.ini.

+add a note

User Contributed Notes

There are no user contributed notes for this page.

  • #1

Hi,

I have my own VPS on da-debian 9. I have Directadmin installed and I'm using php7.2.

I would like to enable the php exif extension.

I tried to do it according to the instructions: https://help.directadmin.com/item.php?id=252

but after entering these commands nothing happens.

Code:

cd /usr/local/directadmin/custombuild
mkdir -p custom/fpm
cp -fp configure/fpm/configure.php72 custom/fpm/configure.php72

Screenshots:
https://ibb.co/gALEFK
https://ibb.co/h4agvK

  • #2

but after entering these commands nothing happens.

Correct. That is because you forgot step 3 and 4 from the help file.

  • #3

How should I add the "--enable-exif" line?

  • #4

edit configure.php72:

Code:

nano /usr/local/directadmin/custombuild/custom/fpm/configure.php72

The last line is probably:

Add a backslash and add --enable-exif on the line below, so it looks like this:

Code:

--enable-intl \
--enable-exif

After this is done, follow the remaining steps in the guide.

How do I install exif extension?

Save. Exif is included, so there's nothing to install. Restart php-fpm for the changes to take effect.

What is EXIF PHP extension?

The EXIF (Exchangeable image file format) PHP extension enables to work with the metadata from the images taken by digital devices like digital cameras, cell phones, etc. It depends on the image file format. We can retrieve embedded thumbnails of images.

How do I enable PHP extensions in cPanel?

Steps to Install PHP Extension in cPanel.

Step 1: Select the cPanel and login..

Step 2: Go to PHP version..

Step 3: Pick your ideal PHP version and click on Set as Current and select the extensions..

Step 4: Select the required Extensions..