编译安装PHP7.4

Written by

in

, ,

1. 安装编译libzip新版需要的CMKAE3

wget https://cmake.org/files/v3.17/cmake-3.17.2.tar.gz
tar xvzf cmake-3.17.2.tar.gz
yum remove cmake*
yum install -y gcc gcc-c++ make automake openssl-deve
cd cmake*
./bootstrap
gmake
gmake install
/usr/local/bin/cmake --version
ln -s /usr/local/bin/cmake /usr/bin/
cmake --version

2. 安装最新版本libzip

yum -y remove libzip-devel
wget https://libzip.org/download/libzip-1.6.1.tar.gz
tar -zxvf libzip-1.6.1.tar.gz
cd libzip-1.6.1
mkdir build
cd build
cmake ..
make & make test & make install
cd ..
export PKG_CONFIG_PATH="/usr/local/lib64/pkgconfig/"
ldconfig /usr/local/lib
ldconfig /usr/local/lib64

3.下载php7.4

yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libsqlite3x-devel oniguruma-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
wget https://www.php.net/distributions/php-7.4.6.tar.gz
tar xvzf php-7.4.6.tar.gz
cd php-7.4.6
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-config-file-scan-dir=/usr/local/php/conf.d --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype --with-jpeg  --with-zlib --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --enable-ftp --enable-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --with-zip --with-zlib --enable-soap --with-gettext  --enable-opcache --with-xsl --with-pear
make & make test & make install

测试与配置

/usr/local/php/bin/php -v

增加系统变量,便于全局使用php命令

vim /etc/profile

在文件末尾加入:

PATH=$PATH:/usr/local/php/bin
export PATH

配置php基础设置

cp php.ini-production /usr/local/php/etc/php.ini
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
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
service php-fpm start
systemctl enable php-fpm

至此,你可以在你的网站或目录下编辑测试文件进行测试php文件了。

下一步我们再来介绍mysql数据库percona的源安装。

Comments

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注