php編譯的常見報錯和製作php.tar.gz解壓可直接用的包
技術標籤:nginx
首先下載一個php原始碼包
wget https://www.php.net/distributions/php-7.4.13.tar.gz
安裝依賴
yum -y install gcc gcc-c++ libxml2-devel openssl-devel sqlite-devel libcurl libcurl-devel gmp-devel oniguruma-devel gdbm-devel net-snmp-devel
建立一個要安裝到的目錄
mkdir /srv/php
進入編譯
[[email protected] ~]# tar xf php-7.4.13.tar.gz
[[email protected] ~]# cd php-7.4.13/
開始編譯指定路徑
[[email protected] php-7.4.13]# ./configure --prefix=/srv/php --with-config-file-path=/srv/php/etc --with-mysql=mysqlnd --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-snmp --with-zlib --with-curl --with-pear --with-gettext --with-gmp --enable-inline-optimization --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mhash
常見的一些編譯報錯
-
configure: error: Please reinstall the BZip2 distribution
解決:yum -y install bzip2 bzip2-devel -
configure: error: Package requirements (libcurl >= 7.15.5) were not met:No package ‘libcurl’ found
解決:yum -y install libcurl libcurl-devel
3.you may set the environment variables SQLITE_CFLAGS and SQLITE_LIBS to avoid the need to call pkg-config.
4.configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
解決:yum -y install sqlite-devel
5.configure: error: GNU MP Library version 4.2 or greater required.
解決:yum -y install gmp-devel
6.configure: error: Package requirements (oniguruma) were not met: No package ‘oniguruma’ found
解決:yum -y install oniguruma-devel
7.configure: error: Please reinstall readline - I cannot find readline.h
解決:yum -y install readline-devel
8.configure: error: Package requirements (libpcre2-8 >= 10.30) were not met: No package ‘libpcre2-8’ found
解決:https://www.jianshu.com/p/89646111a1ce
9.configure: error: DBA: Could not find necessary header file(s).
解決:yum -y install gdbm-devel
10.configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:No package ‘libzip’ found
解決:https://www.jianshu.com/p/6cbd25addc29
11 configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
解決
yum -y install net-snmp-devel
沒有報錯後編譯
make && make install
生成標準配置
cp php.ini-development /srv/php/etc/php.ini
mv /srv/php/etc/php-fpm.conf.default /srv/php/etc/php-fpm.conf
改名配置檔案
[[email protected] ~]# cd /srv/php/etc/php-fpm.d/
[[email protected] php-fpm.d]# ls
www.conf.default
[[email protected] php-fpm.d]# mv www.conf.default www.conf
建立一個nginx使用者因為我們安裝時規定的使用者是nginx
useradd -s /sbin/nologin nginx
啟動即可
/srv/php/sbin/php-fpm
然後打包
上傳到一個沒安裝php的機子上測試
scp php1.tar.gz [email protected]:/srv
這臺機子沒有nginx使用者新增一個
useradd -s /sbin/nologin nginx
然後解壓啟動
報錯是少些依賴外掛解決方法
yum -y install epel-release
yum -y install oniguruma
接著報錯
安裝
yum -y install net-snmp
完事之後啟動即可