ubuntu 20.04 安装php8.0
apt-get安装
# 追加一个PHP相关的存储库 sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt update # 安装php8系列版本 sudo apt install php8.* sudo apt install libapache2-mod-php8.* #与apache2交互的模块 sudo a2enmod proxy_fcgi setenvif sudo a2enconf php8.*-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 # 追加镜像库 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 autoconf ./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-openssl --with-mhash --with-zlib --with-xmlrpc --with-iconv --with-curl --enable-intl --enable-pdo --enable-ftp --enable-mbstring --enable-gd --enable-sockets --enable-fpm --enable-cli --enable-xml --enable-soap --enable-pcntl --enable-calendar --enable-opcache 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
编译安装是没有pecl跟pear的需要手动安装
wget http://pear.php.net/go-pear.phar -O go-pear.php php go-pear.php
本文来自博客园,作者:编程混子,转载请注明原文链接:https://www.cnblogs.com/Qyehui/p/15159546.html