php7.3安装教程

225 阅读4分钟

一.新增用户 用户组

groupadd www

useradd -g www www

二.下载php源码包

php.net/downloads.p…

我一般下载到/usr/local/下面
创建一个文件
mkdir php7.3
cd php7.3
mkdir php 安装php目录
wget https://downloads.php.net/~cmb/php-7.3.0.tar.gz
解压:
tar xzvf php-7.3.0.tar.gz
cd  php-7.3.0

三.解决依赖关系

yum install -y  libxml2-devel
yum install -y  bzip2-devel
yum install -y  curl-devel
yum install -y  libjpeg-devel
yum install -y libpng-devel
yum install -y freetype-devel
yum install -y libxslt-devel
yum install -y libzip-devel

四.编译

--with-fpm-user=www --with-fpm-group=www
这里使用www www 用户、用户组 编译出来的程序启动,就是归属这个用户、用户组


./configure 
--prefix=/usr/local/php7.3/php \ 安装目录
--with-config-file-path=/usr/local/php7.1/php/etc \ 指定php.ini位置
--with-fpm-user=www \
--with-fpm-group=www \
--with-curl \ 打开curl浏览工具的支持
--with-curlwrappers \ 运用curl工具打开url流 
--with-freetype-dir \ 打开对freetype字体库的支持 
--with-gd \ 打开gd库的支持
--enable-gd-native-ttf \ 支持TrueType字符串函数库
--with-gettext \ 打开gnu 的gettext 支持,编码库用到 
--with-iconv-dir \ 用于PHP编译时指定 iconv 在系统里的路径
--with-kerberos \ 
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \ openssl的支持,加密传输https时用到的
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \ 打开pear命令的支持,php扩展用的
--with-png-dir \ 打开对png图片的支持 
--with-jpeg-dir \ 打开对jpeg图片的支持 
--with-xmlrpc \ 打开xml-rpc的c语言 
--with-xsl \ 打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件
--with-zlib \ 打开zlib库的支持,用于http压缩传输
--with-bz2 \ 打开对bz2文件的支持
--with-mcrypt \ mcrypt算法扩展
--with-mhash \ mhash算法扩展
--enable-bcmath \  打开图片大小调整,用到zabbix监控的时候用到了这个模块
--enable-libxml \ 打开libxml2库的支持
--enable-inline-optimization \ 优化线程
--enable-mbregex \
--enable-mbstring \ 多字节,字符串的支持
--enable-opcache \
--enable-pcntl \ freeTDS需要用到的,可能是链接mssql 才用到
--enable-shmop \ 这样就使得你的PHP系统可以处理相关的IPC函数了
--enable-sysvsem \ 同上
--enable-soap \
--enable-sockets \ 打开 sockets 支持
--enable-sysvshm \
--enable-xml \
--enable-zip \ 打开对zip的支持
--enable-ftp \ 打开ftp的支持
--enable-fpm  打上php-fpm 补丁后才有这个参数,cgi方式安装的启动程序 



iconv出错
编辑 Makefile 大約 77 行左右的地方:
EXTRA_LIBS = ..... -lcrypt
在最後加上 -liconv,例如:
EXTRA_LIBS = ..... -lcrypt -liconv
再运行make就可以了。

php.ini

cp php.ini-production /usr/local/php7.3/php/ect/php.ini # 这个路径在php.info 里面看,人家指向到哪里cp 到哪里,源码包里面怎么找这个

cd /usr/local/php/etc/php-fpm.d
cp www.conf.default www.conf

启动

/usr/local/php7.3/php/sbin/php-fpm &

查看是否启动成功
ps aux | grep php-fpm

案例配置

./configure 
--prefix=/usr/local/opt/php@7.4 \
--with-config-file-path=/usr/local/opt/php@7.4/etc \
--with-fpm-user=www \
--with-fpm-group=www \
--with-curl \
--with-curlwrappers \ 
--with-freetype-dir \
--with-gd \
--enable-gd-native-ttf \
--with-gettext \
--with-iconv-dir \
--with-kerberos \ 
--with-libdir=lib64 \
--with-libxml-dir \
--with-mysqli \
--with-openssl \
--with-pcre-regex \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-png-dir \ 
--with-jpeg-dir \ 
--with-xmlrpc \
--with-xsl \
--with-zlib \
--with-bz2 \
--with-mcrypt \
--with-mhash \
--enable-bcmath \
--enable-libxml \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-shmop \
--enable-sysvsem \
--enable-soap \
--enable-sockets \
--enable-sysvshm \
--enable-xml \
--enable-zip \
--enable-ftp \
--enable-fpm

以下是经常出现的错误

configure: error: Unable to find libgd.(a|so)

tar zxvf gd-2.0.11.tar.gz
cd gd-2.0.11
sudo ./configure --prefix=/usr/local/gd2
sudo make
sudo make install

再php:~/:./configure …… --with-gd=/usr/local/gd2 ……

以下是经常出现的错误:

1) Configure: error: xml2-config not found. Please check your libxml2 installation.

Solutions :

Quote:#yum install libxml2 libxml2-devel (For Redhat & Fedora)

源码安装
地址:https://www.linuxfromscratch.org/blfs/view/cvs/general/libxml2.html
下载# wget http://xmlsoft.org/sources/libxml2-2.9.10.tar.gz
安装# ./configure --prefix=/usr/local/libxml2/ 
编辑安装# make & make install

php安装 指定libxml2安装目录
--with-libxml-dir=/usr/local/libxml2

 

2) Checking for pkg-config… /usr/bin/pkg-config
configure: error: Cannot find OpenSSL’s <evp.h>

Solutions :

Quote:#yum install openssl openssl-devel

 

3) Configure: error: Please reinstall the BZip2 distribution

Solutions :

Quote:# yum install bzip2 bzip2-devel

 

4) Configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/

Solutions :

Quote:# yum install curl curl-devel (For Redhat & Fedora)

 

5) Configure: error: libjpeg.(also) not found.

Solutions :

Quote:# yum install libjpeg libjpeg-devel

 

6) Configure: error: libpng.(also) not found.

Solutions :

Quote:# yum install libpng libpng-devel

 

7) Configure: error: freetype.h not found.
Solutions :

Quote:#yum install freetype-devel

 

8) Configure: error: Unable to locate gmp.h

Solutions :

Quote:# yum install gmp-devel

 

9) Configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!

Solutions :

Quote:# yum install mysql-devel (For Redhat & Fedora)

 

10) Configure: error: Please reinstall the ncurses distribution

Solutions :

Quote:# yum install ncurses ncurses-devel

 

11) Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

Solutions :

Quote:# yum install unixODBC-devel

 

12) Configure: error: Cannot find pspell

Solutions :

Quote:# yum install pspell-devel

 

13) configure: error: mcrypt.h not found. Please reinstall libmcrypt.

Solutions :

Quote:# yum install libmcrypt libmcrypt-devel (For Redhat & Fedora)

 

 

14) Configure: error: snmp.h not found. Check your SNMP installation.

Solutions :

Quote:# yum install net-snmp net-snmp-devel


15) configure: WARNING: unrecognized options: --with-curlwrappers, --enable-gd-native-ttf,--with-mcrypt

php7.2以后不支持–with-mcrypt, --enable-gd-native-ttf 这两个参数,需要去掉--with-mcrypt, --enable-gd-native-ttf


解决 configure: error: Package requirements (sqlite3 > 3.7.4) were not met: No package ‘sqlite3’ found 错误

yum install sqlite-devel