Home > Backend Development > PHP Problem > How to install fileinfo extension in PHP

How to install fileinfo extension in PHP

醉折花枝作酒筹
Release: 2023-03-11 06:26:01
forward
3832 people have browsed it

The fileinfo function under PHP obtains the MIME information of the file by looking for a specific magic byte sequence at a given location in the file. Let's learn with the editor how to install the fileinfo extension.

How to install fileinfo extension in PHP

PHP installation fileinfo extension steps:

The first step is to view the source code path of fileinfo

Command:

find / -name fileinfo
Copy after login

Result:/home/soft/php-7.1.3/ext/fileinfo

The second step is to enter the source code location

Command:

cd /home/soft/php-7.1.3/ext/fileinfo
Copy after login

The third step is to execute the phpize command

Command:

/usr/local/php/bin/phpize
Copy after login

The fourth step is to execute configure configuration

Command:

./configure --with-php-config=/usr/local/php/bin/php-config
Copy after login

(If the prompt php-config command does not exist configure: error: Cannot find php-config. Please use --with-php-config=PATH)

You can execute yum install php-devel to install php-devel. After the installation is complete, execute this command

The fifth step compiles and installs

Command:

make && make install
Copy after login

The sixth step modifies the PHP configuration file

Modify the php.ini file and add

extension=fileinfo.so
Copy after login

Seven steps to restart nginx and php

nginx restart command:

systemctl restart nginx
Copy after login

php restart command:

systemctl restart php-fpm
Copy after login

(Note: check the process number before and after restarting to see if the restart is successful)

Recommended learning: php video tutorial

The above is the detailed content of How to install fileinfo extension in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:imooc.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template