一键安装PHP8.0.md

Centos8一键安装PHP8.0

yum update -y \
&& yum install -y \ 
gcc \
autoconf automake libtool \ 
pcre pcre-devel \
zlib zlib-devel \
libxml2 libxml2-devel \
openssl openssl-devel \
libcurl libcurl-devel \
libjpeg libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libmcrypt libmcrypt-devel \
sqlite-devel

curl -SL "https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz"  -o oniguruma694.tar.gz \
&& mkdir -p oniguruma694 \
&& tar -xf /root/oniguruma694.tar.gz -C oniguruma694 --strip-components=1 \
&& ( \
    cd oniguruma694 \ 
    && ./autogen.sh \ 
    && ./configure --prefix=/usr \ 
    && make -s -j$(nproc) \
    && make install \
)

cd /root \
&& curl -SL "http://mirrors.sohu.com/php/php-8.0.1.tar.gz"  -o php80.tar.gz \
&& mkdir -p php80 \
&& tar -xf /root/php80.tar.gz -C php80 --strip-components=1 \
&& ( \  cd php80 \ 
    && mkdir -p "/etc/php/conf.d" \ 
    && ./configure \
    --prefix=/usr/local/php80 \
    --with-config-file-path="/etc/php" \
    --with-config-file-scan-dir="/etc/php/conf.d" \
    --with-pdo-mysql \
    --with-zlib \
    --with-openssl \
    --with-mhash \
    --with-curl \
    --with-fpm-user=nobody \
    --with-fpm-group=nobody \
    --enable-bcmath \
    --enable-soap \
    --enable-fpm \
    --enable-mbstring \
    --enable-sockets \
    --enable-opcache \
    --enable-pcntl \
    --enable-simplexml \
    --enable-xml \
    --disable-fileinfo \
    --disable-rpath \
&& make -s -j$(nproc) \
&& make install \
&& /bin/cp -rf php.ini-production /etc/php/php.ini)

# 设置php-fpm.conf
cd "/usr/local/php80/etc" \
&& /bin/cp -rf  php-fpm.conf.default php-fpm.conf \
&& /bin/cp -rf  php-fpm.d/www.conf.default php-fpm.d/www.conf

# 把PHP加入环境变量
echo "PATH=\$PATH:/usr/local/php80/bin:/usr/local/php80/sbin" > /etc/profile.d/php.shecho "export PATH" >> /etc/profile.d/php.shsource /etc/profile

cd /root \
&& curl -SL https://github.com/phpredis/phpredis/archive/5.3.2.tar.gz -o redis.tar.gz \
&& mkdir -p redis \
&& tar -xf redis.tar.gz -C redis --strip-components=1 \
&& ( \
    cd redis \
    && phpize \
    && ./configure \
    && make -s -j$(nproc) \
    && make install \
) \
&& echo "extension=redis.so" > /etc/php/conf.d/50_redis.ini \
&& php --ri redis

echo -e "\033[32m😂 mission completed.\033[0m"
本作品采用《CC 协议》,转载必须注明作者和本文链接
讨论数量: 1

按您的脚本部署的时候,发现oniguruma还是需要yum去安装,否则安装php8时会提示“No package 'oniguruma' found”

2天前 评论
soonio (楼主) 2天前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!