以前购买的是镜像产品直接安装的。现在已多次收到后台提示需要升级php版本,请各位专家给予帮助。谢谢!
1.首先更新依赖包。
yum -y update 2.安装依赖包
yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel libzip gcc-c++
3.转到 /usr/local/src 目录,下载php7.3.5
cd /usr/local/src wget https://www.php.net/distributions/php-7.3.5.tar.gz
4.解压安装包,并进入目录
tar -zxvf php-7.3.5.tar.gz cd php-7.3.5
5.添加用户和组
groupadd www useradd -g www www
6.开始编译
./configure --prefix=/usr/local/php --with-fpm-user=www --with-fpm-group=www --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-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc --with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip --enable-fpm
这里会提示 configure: error: Please reinstall the libzip distribution,我们需要移除libzip,手动安装最新版本
7.安装libzip
(1)先安装cmake
cd /usr/local/src wget https://github.com/Kitware/CMake/releases/download/v3.14.3/cmake-3.14.3.tar.gz tar -zxvf cmake-3.14.3.tar.gz cd cmake-3.14.3 ./bootstrap make && make install
(2)再编译安装libzip
yum remove libzip -y cd /usr/local/src wget https://libzip.org/download/libzip-1.5.2.tar.gz tar -zxvf libzip-1.5.2.tar.gz cd libzip-1.5.2 mkdir build cd build cmake .. make && make install
(3)执行以下命令
vi /etc/ld.so.conf #添加如下几行 /usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64 #保存退出 ldconfig -v # 使之生效
make && make install
9.编译完成后,添加环境变量
vi /etc/profile #添加以下内容到最后 PATH=$PATH:/usr/local/php/bin export PATH #刷新环境变量 source /etc/profile
10.配置文件
cp /usr/local/src/php-7.3.5/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm73
chmod +x /etc/init.d/php-fpm73
cp /usr/local/php/etc/php-fpm.conf.default ${PHP73_DIR}/etc/php-fpm.conf
cat << EOF > /usr/local/php/etc/php-fpm.d/www.conf [www] listen = /home/www/logs/php73-fpm.sock listen.mode = 0666 user = www group = www pm = dynamic pm.max_children = 128 pm.start_servers = 5 pm.min_spare_servers = 5 pm.max_spare_servers = 15 pm.max_requests = 300 rlimit_files = 1024 slowlog = /home/www/logs/php73-fpm-slow.log EOF 11.修改apache
镜像中默认是用的php-fpm,使用的是socket方式的监听,Apache对应配置文件/usr/local/apache/conf/httpd.conf
修改指定位置为:
12.重启服务
/etc/init.d/php-fpm stop
/etc/init.d/php-fpm73 start #启动报错请修改文件名 修改/usr/local/php/etc/php-fpm.conf.default为php-fpm.conf
/etc/init.d/apachectl restart
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。