centos7 编译安装php8 以及redis、mongo扩展

centos7 编译安装php8 以及redis、mongo扩展

安装依赖

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

创建www用户

groupadd www
useradd -g www www  –no-create-home -s /bin/false

 安装

因为原来电脑有默认的php版本7.4,所以这里兼安装php8.0,使用软连接上稍微做了区分

具体用法稍微不同,跟进个人实际情况修改

php -v => php8 -v

php-config => php8-config

phpize => phpize-8

service php-fpm start => service php8-fpm start

mkdir -p /opt/download/php;
cd /opt/download/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=www --with-fpm-group=www --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;
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;
# vim /opt/local/php8/etc/php-fpm.d/www.conf #修改php8端口->9001,9000给了其它版本php
cp /opt/download/php/php-8.0.11/php.ini-development /opt/local/php8/etc/php.ini;
cp /opt/download/php/php-8.0.11/sapi/fpm/init.d.php-fpm /etc/init.d/php8-fpm;
sudo chmod 777 /etc/init.d/php8-fpm;
#软连接
ln -s /opt/local/php8/bin/php /usr/local/bin/php8;
ln -s /opt/local/php8/bin/php-config /usr/local/bin/php8-config;
ln -s /opt/local/php8/bin/phpize /usr/local/bin/phpize-8;
ln -s /opt/local/php8/etc/php.ini /etc/php8.ini;
#查看版本
#php8 -v;
#服务启停
#service php8-fpm start|stop|restart|status
#开机启动
#chkconfig php8-fpm  on

安装redis扩展

cd /opt/download/php;
wget http://pecl.php.net/get/redis-5.3.4.tgz –no-check-certificate
tar xvf redis-5.3.4.tgz;
cd redis-5.3.4;
phpize-8;
./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 php8-fpm restart;

安装mongodb扩展

mkdir -p /opt/download/php;
cd /opt/download/php;
wget http://pecl.php.net/get/mongodb-1.14.0.tgz –no-check-certificate
tar xvf mongodb-1.14.0.tgz;
cd mongodb-1.14.0;

phpize-8;
./configure –with-php-config=/opt/local/php8/bin/php-config
sudo make && make install;

echo "extension=mongodb.so" >> /opt/local/php8/etc/php.ini;
service php-fpm restart;

                       

点击阅读全文

上一篇 2023年 6月 5日 am11:09
下一篇 2023年 6月 5日 am11:11