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.
PHP installation fileinfo extension steps:
The first step is to view the source code path of fileinfo
Command:
find / -name fileinfo
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
The third step is to execute the phpize command
Command:
/usr/local/php/bin/phpize
The fourth step is to execute configure configuration
Command:
./configure --with-php-config=/usr/local/php/bin/php-config
(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
The sixth step modifies the PHP configuration file
Modify the php.ini file and add
extension=fileinfo.so
Seven steps to restart nginx and php
nginx restart command:
systemctl restart nginx
php restart command:
systemctl restart php-fpm
(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!