编译安装Linux源码和安装PHP环境下载源码。为了保险起见,还是去官网下载吧:https://www.php.net/downloads,选择适合自己项目的稳定版,这里我使用官网最新的稳定版wgethttps://www.php.net/distributions/php-7.4.1.tar.gz解压tar-zxvfphp-7.4.1.tar.gzcdphp-7.4.1配置根据自己的需要选择扩展安装,下面是我的配置,--prefix指定PHP安装目录./configure--prefix=/usr/local/php7--with-curl--with-mysqli--with-openssl--with-pdo-mysql--with-gd--enable-fpm--enable-bcmath--enable-xml--enable-zip--enable-mbstring--enable-sockets配置可选--with-curl--with-freetype-dir--with-gd--with-gettext--with-iconv-dir--with-kerberos--with-libdir=lib64--with-libxml-dir--with-mysqli--with-openssl--with-pcre-正则表达式--with-pdo-mysql--with-pdo-sqlite--with-pear--with-png-dir--with-xmlrpc--with-xsl--with-zlib--enable-fpm--enable-bcmath--enable-libxml--enable-inline-optimization--enable-gd-native-ttf--enable-mbregex--enable-mbstring--enable-opcache--enable-pcntl--enable-shmop--enable-soap--enable-sockets--enable-sysvsem--enable-xml--enable-zip配置是Error:Thelibcurlpackagedoesnotexistconfigure:error:Packagerequirements(libcurl>=7.15.5)werenotmet:Nopackage'libcurl'found我们使用yum安装包,注意版本要求,类似的时候其他包不存在,将libcurl换成其他包名,执行安装命令yuminstalllibcurl-devel安装一些依赖库包libxml2和一些php7需要的其他依赖扩展库yum-yinstalllibxml2yum-yinstalllibxml2-develyum-y安装opensslyum-y安装openssl-develyum-y安装curl-develyum-y安装libjpeg-develyum-y安装libpng-develyum-y安装freetype-develyum-y安装bzip2-develyum-y安装libmcryptdevelyum-y安装postgresql-develyum-y安装aspell-develyum-y安装readline-develyum-y安装libxslt-develyum-y安装net-snmp-develyum-y安装unixODBC-develyum-y安装libicu-develyum-c-yinstclient-develyum-y安装libXpm-develyum-y安装libvpx-develyum-y安装enchant-develyum-y安装openldapyum-y安装openldap-develyum-y安装db4-develyum-y安装gmp-develyum-y-installysqlite-yinstallmysql-devel编译安装make&&makeinstall配置环境变量添加:/usr/local/php7/bin:/usr/local/php7/bsin路径与其他路径分隔:vim~/.bash_profilesource~/.bash_profile
