centos安装PHP7

新建php用户和php组

groupadd -r www && useradd -r -g www -s /bin/false -d /usr/local/php7 -M php

安装编译php7时需要的依赖包

yum -y install gcc libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel libzip-devel wget cmake libtool

升级libzip(version >= 0.11)具体最新版本可看官方:https://nih.at/libzip/index.html

yum remove libzip -y

#1.5.1版本
wget https://nih.at/libzip/libzip-1.5.1.tar.gz
tar -zxvf libzip-1.5.1.tar.gz
cd libzip-1.5.1
mkdir build && cd build && cmake … && make && make install

#1.2.0版本(不要使用)
wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make && make install

#cmake版本低的时候
yum remove cmake
cd /opt
wget https://cmake.org/files/v3.10/cmake-3.10.2-Linux-x86_64.tar.gz
tar -zxvf cmake-3.10.2-Linux-x86_64.tar.gz
export CMAKE_HOME=/opt/cmake-3.10.2-Linux-x86_64
export PATH= P A T H : PATH: CMAKE_HOME/bin
source /etc/profile
cmake -version

##configure: error: off_t undefined; check your library configuration

添加搜索路径到配置文件

echo ‘/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64’>>/etc/ld.so.conf

更新配置

ldconfig -v

PHP7编译参数的配置

tar -xzvf php-7.3.2.tar.gz
cd php-7.3.2

./configure
–prefix=/usr/local/php7
–exec-prefix=/usr/local/php7
–bindir=/usr/local/php7/bin
–sbindir=/usr/local/php7/sbin
–includedir=/usr/local/php7/include
–libdir=/usr/local/php7/lib/php
–mandir=/usr/local/php7/php/man
–with-config-file-path=/usr/local/php7/etc
–with-mysql-sock=/var/lib/mysql/mysql.sock
–with-mhash
–with-openssl
–with-mysqli=shared,mysqlnd
–with-pdo-mysql=shared,mysqlnd
–with-gd
–with-iconv
–with-zlib
–enable-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-dir
–with-freetype-dir
–enable-opcache
–enable-fpm
–with-fpm-user=www
–with-fpm-group=www
–without-gdbm
–disable-fileinfo

make
make test
make install

#问题:zipconf.h: No such file or directory
cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
#当配置PHP时出现 make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1 时,是因为服务器内存不足1G。只需要在配置命令中添加 --disable-fileinfo即可

猜你喜欢

转载自blog.csdn.net/i837314446/article/details/88841398