准備工作
創建空文件夾
> mkdir /opt/php //創建目錄 > cd /opt/php //進入目錄
安裝php運行依賴庫
> yum install openssl-devel gcc gcc-c++ wget make libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel
bison autoconf sqlite-devel bzip2-devel libcurl-devel libicu-devel libxslt-devel libzip-devel libtidy-devel libtidy
> yum --enablerepo=PowerTools install oniguruma-devel
下載源碼
> wget https://www.php.net/distributions/php-8.0.6.tar.gz //下載php8 > tar vxf php-8.0.6.tar.gz //解壓php壓縮 > mv php-8.0.6 php8 //改名
配置准備
> mkdir /opt/php/php //建立php安裝目錄 > mkdir /opt/php/etc //建立php配置目錄
配置php
> ./configure --prefix=/opt/php/php/ --with-config-file-path=/opt/php/etc --enable-fpm --enable-mysqlnd --enable-opcache --enable-pcntl --enable-mbstring --enable-soap --enable-zip --enable-calendar --enable-bcmath
--enable-exif --enable-ftp --enable-intl --with-mysqli --with-pdo-mysql --with-openssl --with-curl --with-gd --with-gettext --with-mhash --with-openssl --with-mcrypt --with-tidy --enable-wddx --with-xmlrpc --with-zlib
配置成功會出現以下信息
+--------------------------------------------------------------------+ | 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.
編譯&安裝
> make
> make install
判斷是否安轉成功
> cd /opt/php/php/bin //進入php的安裝目錄下的bin > ./php --version //查看版本號
出現版本號,則安裝成功
可能出現的問題
在配置過程中,出現的問題基本上都是某個依賴包沒有安裝好,這幾篇文章能給你一些幫助。
error: C++ preprocessor "/lib/cpp" fails sanity check錯誤解決方法