Ubuntu安装多版本PHP+Nginx共存环境
相关文档
https://www.cnblogs.com/ishenghuo/p/16062779.html
https://www.cnblogs.com/68xi/p/15340087.html
https://www.cnblogs.com/Hi-blog/p/How-To-Install-Node-And-Npm-On-Ubuntu.html
https://www.jianshu.com/p/198cc60910d0
https://blog.z6z8.cn/2019/09/09/%e9%83%a8%e7%bd%b2ubuntu-nginx-php-fpm-phalcon/#lwptoc
添加php软件库
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
卸载自带apache服务
$ sudo systemctl stop apache2 && sudo apt remove apache2
卸载自带php-apache服务
$ sudo apt-get remove libapache2-mod-php7.2 && sudo apt-get remove libapache2-mod-php
安装软件
$ sudo apt install -y git lrzsz nginx php7.4 php7.4-fpm libapache2-mod-php7.4 php8.0 php8.0-fpm libapache2-mod-php8.0 php8.1 php8.1-fpm libapache2-mod-php8.1
安装php拓展
$ sudo apt-get install -y php7.4-mbstring php7.4-gd php7.4-dom php7.4-mysql php7.4-curl php7.4-intl php7.4-swoole php7.4-redis php7.4-memcache php7.4-mongodb php7.4-pgsql php7.4-geoip php7.4-bcmath php7.4-phalcon php7.4-psr php7.4-apcu php7.4-imagick php7.4-msgpack php7.4-sqlite3
$ sudo apt-get install -y php8.0-mbstring php8.0-gd php8.0-dom php8.0-mysql php8.0-curl php8.0-intl php8.0-swoole php8.0-redis php8.0-memcache php8.0-mongodb php8.0-pgsql php8.0-geoip php8.0-bcmath php8.0-phalcon php8.0-psr php8.0-apcu php8.0-imagick php8.0-msgpack php8.0-sqlite3
$ sudo apt-get install -y php8.0-mbstring php8.1-gd php8.1-dom php8.1-mysql php8.1-curl php8.1-intl php8.1-swoole php8.1-redis php8.1-memcache php8.1-mongodb php8.1-pgsql php8.1-geoip php8.1-bcmath php8.1-phalcon php8.1-psr php8.1-apcu php8.1-imagick php8.1-msgpack php8.1-sqlite3
安装composer2
$ cd /usr/bin/ && wget https://getcomposer.org/composer.phar && mv composer.phar composer && chmod +x composer
安装nodejs
$ curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash - && sudo apt-get update && sudo apt-get install yarn && sudo apt-get install -y nodejs
安装npm
$ sudo apt install npm -y && sudo npm config set registry https://registry.npm.taobao.org && sudo npm install npm@latest -g && sudo npm config list
使用aliyun镜像
$ composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
取消aliyun镜像
$ composer config -g --unset repos.packagist
查看composer配置
$ composer config -l -g
更新composer
$ composer selfupdate
$ composer self-update
查看安装的php版本
$ update-alternatives --display php
切换php服务版本
$ sudo a2dismod php8.1 && sudo a2enmod php8.0
切换php-cli版本
$ sudo update-alternatives --set php /usr/bin/php7.4
$ sudo update-alternatives --set php /usr/bin/php8.0
$ sudo update-alternatives --set php /usr/bin/php8.1
安装pecl
$ sudo apt install php-pear
启动软件
$ sudo systemctl start nginx.service && sudo systemctl start php8.1-fpm.service && sudo systemctl start php8.0-fpm.service
swoole.use_shortname = off