站長(zhǎng)資訊網(wǎng)
        最全最豐富的資訊網(wǎng)站

        一步步教你如何搭建php8環(huán)境(附常見(jiàn)問(wèn)題解決辦法)

        本篇文章由php8教程欄目給大家詳細(xì)介紹如何一步步搭建php8環(huán)境,希望對(duì)大家有所幫助。

        一、下載

        1、https://www.php.net/distributions/php-8.0.0.tar.gz下載到本地,文件傳輸上傳到 /usr/local/src/

        2、wget -P /usr/local/src/ https://www.php.net/distributions/php-8.0.0.tar.gz

        二、解壓、編譯、安裝

        1、解壓縮

        > cd /usr/local/src/ > tar xzf php-8.0.0.tar.gz > cd php-8.0.0
        登錄后復(fù)制

        2、配置編譯參數(shù),參考https://www.php.net/manual/zh… 選擇自己需要的選項(xiàng)

        ./configure --prefix=/usr/local/php8 --with-config-file-path=/usr/local/php8/etc --with-fpm-user=www --with-fpm-group=www --with-curl --with-openssl --with-mysqli --with-pdo-mysql --with-iconv --with-mhash --with-zlib  --enable-mbstring  --enable-gd   --enable-gd-jis-conv --enable-sockets --enable-fpm --enable- --enable-xml  --enable-pdo  --enable-cli --enable-pcntl --enable-soap --enable-opcache --enable-fileinfo --disable-rpath --enable-mysqlnd --with-zip --enable-simplexml --with-libxml --with-sqlite3 --with-pdo-sqlite --enable-phar --enable-tokenizer --enable-cgi
        登錄后復(fù)制

        問(wèn)題1:

        configure: error: Package requirements (libxml-2.0 >= 2.9.0) were not met: Package 'libxml-2.0', required by 'virtual:world', not found Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBXML_CFLAGS and LIBXML_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.
        登錄后復(fù)制

        問(wèn)題1解決:

        > yum install libxml2-devel
        登錄后復(fù)制

        問(wèn)題2:

        configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
        登錄后復(fù)制

        問(wèn)題2解決:

        > yum install sqlite-devel
        登錄后復(fù)制

        問(wèn)題3:

        configure: error: Package requirements (libcurl >= 7.29.0) were not met:
        登錄后復(fù)制

        問(wèn)題3解決:

        > yum install libcurl-devel
        登錄后復(fù)制

        問(wèn)題4:

        configure: error: Package requirements (libpng) were not met:
        登錄后復(fù)制

        問(wèn)題4解決:

        > yum install libpng libpng-devel
        登錄后復(fù)制

        問(wèn)題5:

        configure: error: Package requirements (oniguruma) were not met:
        登錄后復(fù)制

        問(wèn)題5解決:

        > cd /usr/local/src/ > wget http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic/liboniguruma5-6.9.6-alt1.x86_64.rpm -O liboniguruma5-6.9.6-alt1.x86_64.rpm > rpm -ivh liboniguruma5-6.9.6-alt1.x86_64.rpm > wget http://ftp.altlinux.org/pub/distributions/ALTLinux/Sisyphus/x86_64/RPMS.classic/liboniguruma-devel-6.9.6-alt1.x86_64.rpm -O liboniguruma-devel-6.9.6-alt1.x86_64.rpm  > rpm liboniguruma-devel-6.9.6-alt1.x86_64.rpmcli
        登錄后復(fù)制

        問(wèn)題6:

        configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:
        登錄后復(fù)制

        問(wèn)題6解決:

        > yum install libzip libzip-devel
        登錄后復(fù)制

        配置編譯參數(shù)成功

        +--------------------------------------------------------------------+ | License:                                                           | | This software is subject to the PHP License, available in this     | | distribution in the file LICENSE. By continuing this installation  | | process, you are bound by the terms of this license agreement.     | | If you do not agree with the terms of this license, you must abort | | the installation process at this point.                            | +--------------------------------------------------------------------+ Thank you for using PHP.
        登錄后復(fù)制

        3、編譯源碼

        > make -j2 # 這里是依賴系統(tǒng)cpu核心數(shù)進(jìn)行編譯,對(duì)性能有一定提升,通常利用核心數(shù)不要超過(guò)一半,

        4、安裝

        make install
        登錄后復(fù)制

        安裝成功

        [root@54skyer php-8.0.0]# make install Installing shared extensions:     /usr/local/php8/lib/php/extensions/no-debug-non-zts-20200930/ Installing PHP CLI binary:        /usr/local/php8/bin/ Installing PHP CLI man page:      /usr/local/php8/php/man/man1/ Installing PHP FPM binary:        /usr/local/php8/sbin/ Installing PHP FPM defconfig:     /usr/local/php8/etc/ Installing PHP FPM man page:      /usr/local/php8/php/man/man8/ Installing PHP FPM status page:   /usr/local/php8/php/php/fpm/ Installing phpdbg binary:         /usr/local/php8/bin/ Installing phpdbg man page:       /usr/local/php8/php/man/man1/ Installing PHP CGI binary:        /usr/local/php8/bin/ Installing PHP CGI man page:      /usr/local/php8/php/man/man1/ Installing build environment:     /usr/local/php8/lib/php/build/ Installing header files:          /usr/local/php8/include/php/ Installing helper programs:       /usr/local/php8/bin/   program: phpize   program: php-config Installing man pages:             /usr/local/php8/php/man/man1/   page: phpize.1   page: php-config.1 /usr/local/src/php-8.0.0/build/shtool install -c ext/phar/phar.phar /usr/local/php8/bin/phar.phar ln -s -f phar.phar /usr/local/php8/bin/phar Installing PDO headers:           /usr/local/php8/include/php/ext/pdo/
        登錄后復(fù)制

        5、添加環(huán)境變量

        > vim /etc/profile # 在文件末尾加入 # PATH=$PATH:/usr/local/php8/bin/ # export PATH # :wq 保存并退出 > source /etc/profile # 立刻生效配置 > php -v # 獲得如下信息  php -v PHP 8.0.0 (cli) (built: Dec 15 2020 02:46:59) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
        登錄后復(fù)制

        6、獲取默認(rèn)配置

        // 復(fù)制php.ini到編譯配置參數(shù)指定的目錄。php.ini在解壓的源碼目錄里 > cp /usr/local/src/php-8.0.0/php.ini-production /usr/local/php8/etc/php.ini // 復(fù)制一份php-fpm的配置模版文件到同級(jí)目錄 方便備份和修改 > cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf // 復(fù)制一份php-fpm的擴(kuò)展配置模板文件到同級(jí)目錄 方便備份和修改 > cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf // 復(fù)制開(kāi)啟自起腳本到系統(tǒng)啟動(dòng)自動(dòng)加載腳本目錄。fpm/init.d.php-fpm在解壓的源碼目錄里 > cp /usr/local/src/php-8.0.0/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
        登錄后復(fù)制

        7、開(kāi)機(jī)自啟動(dòng)

        設(shè)置命令可被執(zhí)行

        > chmod +x /etc/init.d/php-fpm # 添加可執(zhí)行權(quán)限
        登錄后復(fù)制

        檢驗(yàn)自啟動(dòng)腳本

        > service php-fpm start # 檢驗(yàn)服務(wù)啟動(dòng) > service php-fpm stop # 檢驗(yàn)服務(wù)關(guān)閉 // 均正常提示 > chkconfig php-fpm on # 設(shè)置開(kāi)機(jī)自動(dòng)執(zhí)行php-fpm開(kāi)機(jī)自啟動(dòng)腳本 > reboot # 重啟,ssh重連 # 重啟后 [root@54skyer ~]# netstat -ntlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name     tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1097/nginx: master   tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1061/sshd            tcp        0      0 0.0.0.0:16379           0.0.0.0:*               LISTEN      1090/redis-server 0  tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      1083/php-fpm: maste
        登錄后復(fù)制

        7、額外說(shuō)明

        關(guān)于配置文件的一些說(shuō)明

        php-fpm.conf是PHP-FPM特有的配置文件

        php.ini是所有php模式中必須的配置文件

        兩者的區(qū)別是,php-fpm.conf是PHP-FPM進(jìn)程管理器的配置文件,php.ini是PHP解析器的配置文件

        有的PHP版本的配置文件路徑中還有/fpm.d/www.conf配置文件

        這是php-fpm.conf配置的文件的擴(kuò)展文件,可以打開(kāi)php-fpm.conf文件查看

        ; include=fpm.d/*.conf
        登錄后復(fù)制

        我們可以使用php-fpm.conf配置慢日志

        我們是可以開(kāi)啟慢日志功能的。

        slowlog = /usr/local/var/log/php-fpm.log.slow request_slowlog_timeout = 5s
        登錄后復(fù)制

        php入門(mén)到就業(yè)線上直播課:立即學(xué)習(xí)
        全程直播 + 實(shí)戰(zhàn)授課 + 邊學(xué) + 邊練 + 邊輔導(dǎo)

        贊(0)
        分享到: 更多 (0)
        網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)
        主站蜘蛛池模板: 欧美日韩精品一区二区视频| 亚洲日韩精品一区二区三区无码| 精品人妻少妇一区二区三区在线| 国产亚洲欧美精品久久久| 国产精品手机在线观看你懂的 | 国产精品一区在线观看你懂的| 国产精品无套内射迪丽热巴| 午夜福利麻豆国产精品| 99热都是精品久久久久久| 99re久久精品国产首页2020| 爽爽精品dvd蜜桃成熟时电影院| 人妻精品久久无码区| 西瓜精品国产自在现线| 国内精品久久久久久久coent| 夜色www国产精品资源站| 国产2021精品视频免费播放| 精品无码av一区二区三区 | 囯产精品一品二区三区| 四虎国产成人永久精品免费| 亚洲精品无码专区久久久 | 亚洲精品麻豆av| 日韩精品视频在线观看免费 | 国产亚洲精品自在线观看| 99精品国产福利在线观看| 亚洲国产精品婷婷久久| 精品亚洲欧美高清不卡高清| 国产福利在线观看精品| 国产午夜精品久久久久免费视| 久久九九精品99国产精品| 久久精品夜夜夜夜夜久久| 精品卡一卡二卡乱码高清| 凹凸国产熟女精品视频app| 国产精品视频二区不卡| 91精品最新国内在线播放| 国产精品免费网站| 久久r热这里有精品视频| 欧美黑人巨大精品| 国产精品玖玖美女张开腿让男人桶爽免费看 | 精品久久国产一区二区三区香蕉| 国产精品 日韩欧美| 精品人妻少妇一区二区|