Debian12编译安装php8.3.8、redis7.2.5

一、编译安装php

1、下载解压php

wget https://www.php.net/distributions/php-8.3.8.tar.gz ; \
tar -zxf php-8.3.8.tar.gz && cd ./php-8.3.8

2、安装依赖

apt install -y make gcc g++ libxml2 libxml2-dev libkrb5-dev openssl libssl-dev libsqlite3-dev zlib1g-dev libbz2-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libonig-dev libxslt1-dev libzip-dev libfreetype6-dev

3、创建专用用户

adduser --system --group --no-create-home php83

4、创建php目录

mkdir -pv /usr/local/php83/ ; \
mkdir -pv /usr/local/php83/etc/ ; \
mkdir -pv /usr/local/php83/etc/php.d/

5、开始配置安装,根据需求配置模块

./configure \
--prefix=/usr/local/php83/ \
--with-config-file-path=/usr/local/php83/etc/ \
--with-config-file-scan-dir=/usr/local/php83/etc/php.d/ \
--with-fpm-user=php83 \
--with-fpm-group=php83 \
--with-curl \
--with-freetype \
--with-gettext \
--with-jpeg \
--with-kerberos \
--with-libdir=lib64 \
--with-libxml \
--with-mysqli \
--with-ldap-sasl \
--with-openssl \
--with-pcre-jit \
--with-pdo-mysql \
--with-pdo-sqlite \
--with-pear \
--with-iconv \
--with-xsl \
--with-zlib \
--with-bz2 \
--with-mhash \
--with-zip \
--enable-cli \
--enable-calendar \
--enable-ftp \
--enable-gd \
--enable-fpm \
--enable-bcmath \
--enable-mbregex \
--enable-mbstring \
--enable-opcache \
--enable-pcntl \
--enable-pdo \
--enable-shmop \
--enable-soap \
--enable-static \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-intl \
--enable-mysqlnd \
--enable-xml \
--enable-fpm

没有错误的话会输出一句谢谢你使用php的内容。

6、开始编译安装

make && make install -j 2

7、配置php

echo 'export PATH=$PATH:/usr/local/php83/bin' | tee -a /etc/profile ; \
source  /etc/profile ; \
ln -s /usr/local/php83/sbin/php-fpm  /usr/local/php83/bin/php-fpm ; \
cp php.ini-production /usr/local/php83/etc/php.ini ; \
cp /usr/local/php83/etc/php-fpm.conf.default /usr/local/php83/etc/php-fpm.conf ; \
cp /usr/local/php83/etc/php-fpm.d/www.conf.default /usr/local/php83/etc/php-fpm.d/www.conf

上述php配置文件根据自身需求二次修改。

8、添加守护程序

cat > /etc/systemd/system/php83-fpm.service <<EOF
[Unit]
Description=The PHP FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/usr/local/php83/var/run/php-fpm.pid
ExecStart=/usr/local/php83/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php83/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID

PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF

重载并启动服务

systemctl daemon-reload
systemctl enable php83-fpm
systemctl start php83-fpm
systemctl status php83-fpm

至此php配置完成。

二、编译安装redis

1、安装依赖

apt install build-essential tcl -y

2、下载解压redis

wget http://download.redis.io/releases/redis-7.2.5.tar.gz ; \
tar xzf redis-7.2.5.tar.gz ; cd ./redis-7.2.5

3、编译安装

make && make install

4、创建redis目录

mkdir /etc/redis ; mkdir /var/redis ; mkdir /var/redis/6379

5、创建专用账号并授权目录权限

adduser --system --group --no-create-home redis && \
chown redis:redis /var/redis/6379

6、配置redis

cp redis.conf /etc/redis/6379.conf

复制过去的配置文件根据自身需求二次修改

7、添加守护程序

cat > /etc/systemd/system/redis.service <<EOF
[Unit]
Description=Redis In-Memory Data Store
After=network.target

[Service]
User=redis
Group=redis
Type=simple
ExecStart=/usr/local/bin/redis-server /etc/redis/6379.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always

[Install]
WantedBy=multi-user.target
EOF

重载并启动服务

systemctl daemon-reload
systemctl enable redis
systemctl start redis
systemctl status redis

8、验证redis是否启动成功

redis-cli ping # 返回PONG则成功

三、安装php-redis

apt install php-redis -y && \
echo "extension=redis.so" | tee /usr/local/php83/etc/php.d/redis.ini

至此,安装完毕。

 

 

版权声明:
作者:绛霄
链接:https://www.u8899.de/2024/07/15/139/
来源:JAXo's Blog
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码