【PHP】安裝phpoffice/phpspreadsheet環境OneinStack安裝ext-fileinfo這個擴展

安裝phpoffice/phpspreadsheet環境OneinStack安裝ext-fileinfo這個擴展

Composer安裝phpoffice/phpspreadsheet

1.添加"phpoffice/phpspreadsheet":"1.8.*"composer.json
2.執行composer install

報錯

1 首先出現下面的提示

Installation request for phpoffice/phpspreadsheet 1.8.2 -> satisfiable by phpoffice/phpspreadsheet[1.8.2].

1.8.*改成1.8.2即可

2 缺少擴展fileinfo

對應的提示如下

- phpoffice/phpspreadsheet 1.8.2 requires ext-fileinfo * -> the requested PHP extension fileinfo is missing from your system.
To enable extensions, verify that they are enabled in your .ini files:
- /usr/local/php/etc/php.ini
- /usr/local/php/etc/php.d/03-imagick.ini
- /usr/local/php/etc/php.d/05-memcached.ini
- /usr/local/php/etc/php.d/05-redis.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

也就是說 ,我沒有安裝 ext-fileinfo這個擴展
解決這個問題的方式就是去安裝這個擴展

官方地址 https://www.php.net/manual/zh/book.fileinfo.php

我的PHP是通過OneinStack安裝的

參考文檔
https://oneinstack.com/question/oneinstack-how-to-support-the-fileinfo/

[root@VM_0_15_centos oneinstack]# ./addons.sh
#######################################################################
#       OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+      #
#                    Install/Uninstall Extensions                     #
#       For more information please visit https://oneinstack.com      #
#######################################################################
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 18.5868 s, 116 MB/s
Setting up swapspace version 1, size = 2097148 KiB
no label, UUID=c25345f9-fe45-4252-9987-df3661c04525
swapon: /swapfile: insecure permissions 0644, 0600 suggested.
What Are You Doing?
         1. Install/Uninstall PHP opcode cache
         2. Install/Uninstall ZendGuardLoader/ionCube/SourceGuardian PHP Extension
         3. Install/Uninstall ImageMagick/GraphicsMagick PHP Extension
         4. Install/Uninstall fileinfo/imap/phalcon/mongodb PHP Extension
         5. Install/Uninstall memcached/memcache
         6. Install/Uninstall Redis
         7. Install/Uninstall swoole PHP Extension
         8. Install/Uninstall xdebug PHP Extension
         9. Install/Uninstall PHP Composer
        10. Install/Uninstall fail2ban
        11. Install/Uninstall ngx_lua_waf
         q. Exit
Please input the correct option: 4
Please select an action:
        1. install
        2. uninstall
Please input a number:(Default 1 press Enter) 1
Please select fileinfo/imap/phalcon/mongodb:
        1. fileinfo
        2. imap
        3. phalcon
        4. mongodb
Please input a number:(Default 1 press Enter) 1
[php-7.3.0.tar.gz] found
~/oneinstack/src/php-7.3.0/ext/fileinfo ~/oneinstack/src ~/oneinstack ~/oneinstack
Configuring for:
PHP Api Version:         20180731
Zend Module Api No:      20180731
Zend Extension Api No:   320180731
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling… no
此處省略
----------------------------------------------------------------------
Libraries have been installed in:
   /root/oneinstack/src/php-7.3.0/ext/fileinfo/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20180731/
Redirecting to /bin/systemctl restart php-fpm.service
PHP fileinfo module installed successfully!
What Are You Doing?
         1. Install/Uninstall PHP opcode cache
         2. Install/Uninstall ZendGuardLoader/ionCube/SourceGuardian PHP Extension
         3. Install/Uninstall ImageMagick/GraphicsMagick PHP Extension
         4. Install/Uninstall fileinfo/imap/phalcon/mongodb PHP Extension
         5. Install/Uninstall memcached/memcache
         6. Install/Uninstall Redis
         7. Install/Uninstall swoole PHP Extension
         8. Install/Uninstall xdebug PHP Extension
         9. Install/Uninstall PHP Composer
        10. Install/Uninstall fail2ban
        11. Install/Uninstall ngx_lua_waf
         q. Exit
Please input the correct option: q

擴展安裝完成
查看擴展是否安裝完成

[root@VM_0_15_centos oneinstack]# php -

然後繼續安裝

- Installing phpoffice/phpspreadsheet (1.8.2): Downloading (connecting...)Downloading (0%) Downloading (5%)Downloading (10%)Downloading (15%)Downloading (20%)Downloading (25%)Downloading (30%)Downloading (35%)Downloading (40%)Downloading (45%)Downloading (50%)Downloading (55%)Downloading (60%)Downloading (65%)Downloading (70%)Downloading (75%)Downloading (80%)Downloading (85%)Downloading (90%)Downloading (95%)Downloading (100%)

安裝完成。

參考資料

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章