php源碼編譯安裝
系統 Centos8.2
下載下傳最新的php包
https://www.php.net/downloads
解壓後進入包的目錄進行一些php配置
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-opcache \
--enable-fpm \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--with-iconv \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl \
--with-zlib \
--with-bz2 \
--with-readline \
--without-sqlite3 \
--without-pdo-sqlite \
--with-pear \
--enable-maintainer-zts \
--enable-dtrace
- –prefix=/usr/local/php 指定php安裝路徑
- –with-config-file-path=/usr/local/php/etc 指定自己的php.ini路徑 然後從源碼裡面 cp過去php.ini 源碼裡面有個php.ini-development和php.ini-production 如果不是本地調試模式的 選擇後者。
- –enable-fpm 運作php-fpm
- –with-fpm-user=www 運作使用者
報錯
-
configure: error: Cannot find sys/sdt.h which is required for DTrace support
解決: yum install -y systemtap systemtap-devel systemtap-sdt-devel
-
configure: error: Package requirements (libxml-2.0 >= 2.7.6) were not met
解決: yum install -y libxml2-devel
-
configure: error: Package requirements (openssl >= 1.0.1) were not met
解決 yum -y install openssl openssl-devel
-
configure: error: Please reinstall the BZip2 distribution
解決 yum -y install bzip2 bzip2-devel
-
configure: error: Package requirements (libcurl >= 7.15.5) were not met
解決 yum -y install curl-devel
-
checking for oniguruma... no configure: error: Package requirements (oniguruma) were not met
解決
-
configure: error: Please reinstall readline - I cannot find readline.h
解決 yum -y install readline-devel
安裝
make && make install