安裝依賴
yum install -y gcc gcc-c++ autoconf
yum -y install libsodium-devel libwebp-devel freetype-devel glib2-devel cairo-devel libxml2-devel libjpeg-devel libpng libpng-devel libmcrypt-devel libicu-devel openldap openldap-devel bzip2-devel libcurl-devel gmp-devel libevent-devel readline-devel libxslt-devel net-snmp-devel aspell-devel unixODBC-devel libc-client-devel freetype-devel libXpm-devel libvpx-devel enchant-devel sqlite-devel libzip-devel epel-release oniguruma oniguruma-devel openssl openssl-devel curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel pcre pcre-devel libxslt libxslt-devel bzip2 bzip2-devel sqlite-devel
創(chuàng)建work用戶
groupadd work
useradd -g work work --no-create-home -s /bin/false
安裝
mkdir -p /opt/php
cd /opt/php
wget https://mirrors.sohu.com/php/php-8.0.11.tar.gz --no-check-certificate
編譯
tar xvf php-8.0.11.tar.gz
cd php-8.0.11
./configure --prefix=/opt/local/php8 --with-config-file-path=/opt/local/php8/etc --enable-fpm --with-fpm-user=work --with-fpm-group=work --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-xmlrpc --with-openssl --with-mcrypt --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 --enable-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --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 --with-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache --enable-bcmath --enable-pcntl
make && make install
報(bào)錯(cuò)
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:
解決
configure出現(xiàn)這個(gè)問(wèn)題狮荔,不要慌费什,我來(lái)告訴你怎么解決
根據(jù)字面意思缺菌,是libzip包有問(wèn)題粗井,且libzip應(yīng)該大于0.11版本且不等于1.3.1或者1.7.0
#卸載自帶的libzip
yum remove libzip -y
#獲取libzip包
wget https://libzip.org/download/libzip-1.3.2.tar.gz
#解壓安裝
tar zxf libzip-1.3.2.tar.gz
cd libzip-1.3.2/
./configure && make && make install
#查看libzip位置
[root@VM-8-9-centos php-7.4.28]# whereis libzip
libzip: /usr/local/lib/libzip.la /usr/local/lib/libzip.a /usr/local/lib/libzip.so
#配置libzip庫(kù)唧取,使configure可以找到它
vim /etc/profile
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"
source /etc/profile
#再次編譯
./configure --prefix=/opt/local/php8 --with-config-file-path=/opt/local/php8/etc --enable-fpm --with-fpm-user=work --with-fpm-group=work --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-xmlrpc --with-openssl --with-mcrypt --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 --enable-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --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 --with-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache --enable-bcmath --enable-pcntl
make && make install
復(fù)制配置文件
cp /opt/local/php8/etc/php-fpm.conf.default /opt/local/php8/etc/php-fpm.conf
cp /opt/local/php8/etc/php-fpm.d/www.conf.default /opt/local/php8/etc/php-fpm.d/www.conf
cp /opt/php/php-8.0.11/php.ini-development /opt/local/php8/etc/php.ini
cp /opt/php/php-8.0.11/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
sudo chmod 777 /etc/init.d/php-fpm
配置環(huán)境變量
vim /etc/profile
export PATH=$PATH:/opt/local/php8/bin:$PATH
source /etc/profile
服務(wù)啟停
#查看版本
php -v
#服務(wù)啟停
service php-fpm start|stop|restart|status
#開(kāi)機(jī)啟動(dòng)
chkconfig php-fpm on
安裝redis擴(kuò)展
cd /opt/php/
wget http://pecl.php.net/get/redis-5.3.4.tgz --no-check-certificate
tar xf redis-5.3.4.tgz
cd redis-5.3.4
phpize
./configure --with-php-config=/opt/local/php8/bin/php-config
sudo make && make install
echo "extension=redis.so" >> /opt/local/php8/etc/php.ini
service php-fpm restart
php -m