php8安裝fileinfo


歡迎關注穎小主的個人博客
服務器環境: 寶塔7.7.0

操作系統: Alibaba Cloud (Aliyun ) 2.1903 LTS (Hunting Beagle) x86_64(Py3.7.9)

php版本: 8,0

安裝

  • 直接使用寶塔中的php擴展安裝

    image-20211027015725264

    但是在我安裝的情況下,一直安裝失敗。查看日志信息大概看到報錯原因是這樣的:

    ...
    /www/server/php/80/src/ext/fileinfo/libmagic/funcs.c: In function ‘file_checkfmt’:
    /www/server/php/80/src/ext/fileinfo/libmagic/funcs.c:97:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
      for (const char *p = fmt; *p; p++) {
      ^
      
    ...
    

    我從寶塔官網上,找到了有人關於這個bug的上報信息,給的回復大概意思就是阿里雲自己封裝后的系統,寶塔這里不兼容,建議使用centos8,有興趣點擊這里進行查看

    所以我就從網上開啟了面向百度編程模式,來了一波騷操作

  • 通過自己手動編譯的方式進行安裝fileinfo

    1. 先查找一下fileinfo擴展的安裝位置
    [root@iZ2zej0uggzcedouxtbhq4Z php]# find / -name fileinfo
    /www/server/php/74/src/ext/fileinfo
    /www/server/php/73/src/ext/fileinfo
    /www/server/php/80/src/ext/fileinfo
    
    1. 進入你需要安裝擴展版本的目錄下執行以下命令
      1. /www/server/php/80/bin/phpize
      2. ./configure --with-php-config=/www/serve/php/80/bin/php-config
      3. make && make install
    # 執行這個命令 /www/server/php/80/bin/phpize 
    [root@iZ2zej0uggzcedouxtbhq4Z fileinfo]# /www/server/php/80/bin/phpize 
    Configuring for:
    PHP Api Version:         20200930
    Zend Module Api No:      20200930
    Zend Extension Api No:   420200930
    # 接着執行一下這個命令 ./configure --with-php-config=/www/serve/php/80/bin/php-config
    [root@iZ2zej0uggzcedouxtbhq4Z fileinfo]# ./configure --with-php-config=/www/serve/php/80/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 pkg-config... /usr/bin/pkg-config
    checking pkg-config is at least version 0.9.0... yes
    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
    checking for suffix of object files... o
    ....
    # 執行一下這個命令 make && make install
    [root@iZ2zej0uggzcedouxtbhq4Z fileinfo]# make && make install
    ...
    /www/server/php/80/src/ext/fileinfo/libmagic/funcs.c: In function ‘file_checkfmt’:
    /www/server/php/80/src/ext/fileinfo/libmagic/funcs.c:97:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
      for (const char *p = fmt; *p; p++) {
      ^
    /www/server/php/80/src/ext/fileinfo/libmagic/funcs.c:97:2: note: use option -std=c99 or -std=gnu99 to compile your code
    # 依然報錯
    

    上邊依然報錯,解決辦法,修改Makefile文件

    大概在25行,將CFLAGS = -g -02 修改為 ``CFLAGS = -std=c99 -g -02`

    然后在執行一次make && make install 順利安裝成功

歡迎關注穎小主的個人博客


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM