ubuntu 20.04 安裝php8.0


apt-get安裝

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php #追加一個存儲庫
sudo apt update
sudo apt install php8.0
sudo apt install libapache2-mod-php8.0 #與apache2交互的模塊 sudo a2enmod proxy_fcgi setenvif sudo a2enconf php8.0-fpm

編譯安裝

#! /bin/bash

read -p "請輸入安裝路徑:" installdir

if [ ! $installdir ]
then
echo "安裝路徑不得為空!";
exit -1
fi

#rm -rf $installdir
source=/etc/apt/sources.list


if [ `grep -c "deb http://mirrors.aliyun.com/ubuntu/" $source` -eq '0' ]
then
    mv $source /etc/apt/sources.list.bak
    touch $source
elif [ ! -e "$source" ]
then
    touch $source
fi

chmod 777 $source

if [ `grep -c "deb http://mirrors.aliyun.com/ubuntu/" $source` -eq '0' ]
then
cat > "$source" << EOF
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
EOF
fi

#無法關閉文件
# echo "deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" >> $source
# echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse" >> $source
# echo "\n" >> $source
# echo "deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> $source
# echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse" >> $source
# echo "\n" >> $source
# echo "deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >> $source
# echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse" >> $source
# echo "\n" >> $source
# echo "deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse" >> $source
# echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse" >> $source
# echo "\n" >> $source
# echo "deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >> $source
# echo "deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse" >> $source

add-apt-repository ppa:ondrej/php
sudo apt-get update && sudo apt-get upgrade

sudo apt-get install gcc pkg-config libxml2-dev libsqlite3-dev \
libssl-dev libonig-dev libpng-dev libcurl4-openssl-dev zlib1g-dev libzip-dev \
software-properties-common build-essential autoconf bison re2c

./configure \
--prefix=${installdir} \
--bindir=${installdir}bin \
--sbindir=${installdir}sbin \
--libdir=${installdir}lib \
--libexecdir=${installdir}libexec \
--includedir=${installdir}include \
--mandir=${installdir}man \
--infodir=${installdir}info \
--oldincludedir=${installdir}oldinclude \
--datadir=${installdir}data \
--localedir=${installdir}localedir \
--with-config-file-path=${installdir}etc \
--with-config-file-scan-dir=${installdir}etc/conf.d \
--with-pear=${installdir}pear \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--with-mhash \
--with-zlib \
--with-xmlrpc \
--with-iconv \
--with-curl \
--enable-intl
--enable-pdo \
--enable-mysqlnd \
--enable-ftp \
--enable-mbstring \
--enable-gd \
--enable-gd-jis-conv \
--enable-sockets \
--enable-fpm \
--enable-cli \
--enable-xml \
--enable-soap \
--enable-pcntl \
--enable-debug \
--enable-calendar \
--enable-opcache \
--enable-maintainer-zts

make clean && make && make install

cp ./php.ini-development ${installdir}etc/php.ini

export PATH="echo $PATH:${installdir}bin:${installdir}sbin"

php_path=/etc/profile.d/php_path.sh
if [ ! -e "$php_path" ]
then
cat > "$php_path" <<EOF
export PATH="echo $PATH:${installdir}bin:${installdir}sbin"
EOF
chmod 744 $php_path
`source $php_path`
fi
 
 
 
//單獨安裝pear方法
wget http://pear.php.net/go-pear.phar -O go-pear.php
php go-pear.php
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM