准备安装gcc和make##安装make,已经安装,可以省略$yum-yinstallgccautomakeautoconflibtoolmake##安装gccg++glibc库$yum-yinstallgccgcc-c++glibc##Installrequiredpackages$yum-yinstalllibmcrypt-develmhash-devellibxslt-devellibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-develreadline-develgmp-devel以上安装可以分批进行也可以单独进行,比如yum-yinstalllibmcrypt-devel,一般情况下可以安装成功。如果失败了,可以多试几次。#添加搜索路径到配置文件echo'/usr/local/lib64/usr/local/lib/usr/lib/usr/lib64'>>/etc/ld.so.conf#更新配置ldconfig-vPHP下载$wgethttps://www.php.net/distributions/php-7.4.5.tar.gz$tar-xzvfphp-7.4.5.tar.gz#解压$cdphp-7.4.5#cd$./configure#phpconfigureConfigure参数config参数根据个人需要而确定--prefix=/usr/local/php--with-config-file-path=/etc--enable-fpm--with-fpm-user=nginx--with-fpm-group=nginx--enable-inline-optimization--disable-debug--disable-rpath--enable-shared--enable-soap--with-xmlrpc--with-openssl--with-pcre-regex--with-sqlite3--with-zlib--enable-bcmath--with-iconv--with-bz2--enable-calendar--with-curl--with-cdb--enable-dom--enable-exif--enable-fileinfo--enable-filter--with-pcre-dir--enable-ftp--with-gd--with-openssl-dir--with-jpeg-dir--with-png-dir--with-freetype-dir--enable-gd-jis-conv--with-gettext--with-gmp--with-mhash--enable-json--enable-mbstring--enable-mbregex--enable-mbregex-backtrack--with-onig--enable-pdo--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--with-zlib-dir--with-pdo-sqlite--with-readline--启用会话--enable-shmop--enable-simplexml--enable-sockets--enable-sysvmsg--enable-sysvsem--enable-sysvshm--enable-wddx--with-libxml-dir--with-xsl--enable-zip--enable-mysqlnd-compression-support--with-pear--enable-opcache7.3./configure--prefix=/usr/local/php--with-config-file-path=/etc--enable-fpm--with-fpm-user=nginx--with-fpm-group=nginx--enable-inline-optimization--disable-debug--disable-rpath--enable-shared--enable-soap--with-xmlrpc--with-openssl--with-pcre-regex--with-sqlite3--with-zlib--enable-bcmath--with-iconv--with-bz2--enable-calendar--with-curl--with-cdb--enable-dom--enable-exif--enable-fileinfo--enable-filter--with-pcre-dir--enable-ftp--with-gd--with-openssl-dir--with-jpeg-dir--with-png-dir--with-freetype-dir--enable-gd-jis-conv--with-gettext--with-gmp--with-mhash--enable-json--enable-mbstring--enable-mbregex--enable-mbregex-backtrack--with-onig--enable-pdo--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd--with-zlib-dir--with-pdo-sqlite--with-readline--enable-session--enable-shmop--enable-simplexml--enable-sockets--enable-sysvmsg--enable-sysvsem--enable-sysvshm--enable-wddx--with-libxml-dir--with-xsl--enable-zip--enable-mysqlnd-compression-support--with-pear--enable-opcache安装$make&&makeinstall#make安装位置--prefix=/usr/local/php配置文件存放路径:--with-config-file-path=/etc也是php.ini的位置,默认为/etcfpmuser&Usergroupconfiguration--enable-fpm--with-fpm-user=www--with-fpm-group=www不要忘记maketest虽然经常报很多警告,但是如果有严重的errorsor编译安装后,可以发现配置文件复制到了with-config-file-path指定的目录下,可以使用phpinfo或者php-i查看对应位置。##php.ini,编译配置在php7/etc目录下$cpphp-7.2.2/php.ini-development../etc/php.ini##php-fpm.conf$cp../etc/php-fpm.conf.default../etc/php-fpm.conf##www.conf$cp../etc/php-fpm.d/www.conf.default../etc/php-fpm.d/www.conf修改配置php.ini原来的cgi.force_redirect=1有注释,需要放行改成cgi.force_redirect=0使用composer时,还需要打开proc_open和proc_get_statusphp-fpm.confwithdisable_functions=修改错误日志路径error_log=log/php-fpm.logwww.conf修改用户和用户组选项user=nginx,group=nginxsetphp全局环境变量/etc/profile全局环境变量$vim/etc/profile##添加以下语句exportPATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH$source/etc/profile$php-vPHP7.3.14(cli)(built:Feb15202000:22:13)(NTS)版权所有(c)1997-2018ThePHPGroupZendEnginev3.3.14,版权所有(c)1998-2018ZendTechnologiesStartphpnginx80001.70.423697632380?SApr274:14php-f:poolwww0root8001.1400166884?SsMar212:24php-fpm:主进程(/usr/local/php/etc/php-fpm.conf)nginx126061.50.423926833656?SApr272:45php-fpm:池wnginx142991.50.416096832368?SApr272:18php-fpm:poolwww安装composer访问composer官网获取最新版本cd/usr/local/php#首先进入php目录php-r"copy('https://getcomposer.org/installer','composer-setup.php');"php-r"if(hash_file('sha384','composer-setup.php')==='e0012edf3e80b6978849f5eff0d4b4e4c79ff1609dd1e613307e16318854d24ae64f26d17af3ef0bf7cfb710ca74755a'){echo'Installerverified';}else{echo'Installercorrupt';unlink('composer-setup.php');}echoPHP_EOL;"phpcomposer-setup.phpphp-r"unlink('composer-setup.php');"目录下会生成composer.phar,移动到/usr/local/bin或/usr/bin或/usr/sbin使其全局生效注意:指定with-fpm-user用户必须有读写权限网站目录的权限;最好设置chown,保持权限统一
