PHP 8 在Centos7下的编译安装与使用
前言
PHP官方已经停止维护php7,更新一下PHP8手动安装的教程
一、安装步骤
1.下载最新版本的PHP
https://www.php.net/downloads.php
2.服务器安装相关依赖
这一步可以根据自己需求下载安装依赖
yum install -y --setopt=protected_multilib=false gcGc gcc-c++ make cmake automake autoconf gd file bison patch mlocate flex diffutils zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel kernel-devel libtool-libs readline-devel gettext-devel libcap-devel php-mcrypt libmcrypt libmcrypt-devel recode-devel sqlite-devel oniguruma oniguruma-devel libzip libzip-devel openssl-devel sqlite-devel
3、下载php软件包并解压
官网地址:https://www.php.net/downloads.php
wget https://www.php.net/distributions/php-8.2.5.tar.gz
4、编译
#解压tar zxvf php-8.2.5.tar.gz#检查环境cd php-8.2.5./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysqli=shared,mysqlnd --with-pdo-mysql --enable-opcache --enable-gd --with-iconv --with-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg --with-freetype --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-fast-install --disable-fileinfo
编译可能会遇到的问题总结
错误提示:1、No package ‘oniguruma’ found
解决方法:
yum install -y epel-releaseyum install -y oniguruma oniguruma-devel
Requested ‘libzip >= 0.11’ but version of libzip is 0.10.1
解决方法:
yum remove libzip libzip-develwget https://libzip.org/download/libzip-1.2.0.tar.gztar -zxvf libzip-1.2.0.tar.gzcd libzip-1.2.0./configuremake && make installexport PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
5、编译安装
make && make install
6、配置文件
创建用户及用户组
groupadd nginx useradd -g nginx -s /sbin/nologin -M nginx
复制 php 配置文件
cp php.ini-production /usr/local/php/etc/php.ini
复制 php-fpm 配置文件
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
复制 php-fpm 的启动脚本(在php安装文件中)
cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
增加执行权限
chmod 744 /etc/rc.d/init.d/php-fpm
启动 php-fpm
/etc/init.d/php-fpm start 或者 service php-fpm start
开启服务
chkconfig --add php-fpm chkconfig php-fpm on
7、配置环境
echo "PATH=/usr/local/php/bin:/usr/local/php/lib:\$PATH" >>/etc/profileecho "export PATH" >>/etc/profile
总结
按照这个教程就可以安装php,安装完成后需要修改php子进程数,防止访问过多导致无法访问
来源地址:https://blog.csdn.net/zzz1502/article/details/120157436