Skip to content

Instantly share code, notes, and snippets.

@anwas
Last active December 14, 2023 11:03
Show Gist options
  • Save anwas/4873797fd515c69e6f05d9e6d2880e01 to your computer and use it in GitHub Desktop.
Save anwas/4873797fd515c69e6f05d9e6d2880e01 to your computer and use it in GitHub Desktop.
[Multiple PHP versions on Ubuntu] #php #dev #ispconfig
## Add repository
### https://launchpad.net/%7Eondrej/+archive/ubuntu/php
### https://launchpad.net/~ondrej/+archive/ubuntu/apache2
sudo add-apt-repository ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/apache2
sudo apt-get update
sudo apt-get dist-upgrade
## Use the following command to search available PHP 7 modules in the package repository.
sudo apt-cache search php7*
## Install PHP 5.6
sudo apt install php5.6 php5.6-common php5.6-gd php5.6-mysql php5.6-imap phpmyadmin php5.6-cli php5.6-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear mcrypt imagemagick libruby libapache2-mod-python php5.6-curl php5.6-intl php5.6-pspell php5.6-recode php5.6-sqlite3 php5.6-tidy php5.6-xmlrpc php5.6-xsl memcached php-memcache php-imagick php-gettext php5.6-zip php5.6-mbstring php5.6-opcache php5.6-json php5.6-ldap php5.6-soap php5.6-bz2 php5.6-bcmath php5.6-xml php5.6-dev php5.6-fpm php5.6-phpdbg php-apcu dh-php php5.6-readline pkg-php-tools shtool xml2
## Install PHP 7.0
sudo apt install php7.0 php7.0-common php7.0-gd php7.0-mysql php7.0-imap phpmyadmin php7.0-cli php7.0-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear mcrypt imagemagick libruby libapache2-mod-python php7.0-curl php7.0-intl php7.0-pspell php7.0-recode php7.0-sqlite3 php7.0-tidy php7.0-xmlrpc php7.0-xsl memcached php-memcache php-imagick php-gettext php7.0-zip php7.0-mbstring php7.0-opcache php7.0-json php7.0-ldap php7.0-soap php7.0-bz2 php7.0-bcmath php7.0-xml php7.0-dev php7.0-fpm php7.0-phpdbg php-apcu php7.0-readline pkg-php-tools shtool xml2 dh-php dh-make
## Install PHP 7.1
sudo apt install php7.1 php7.1-common php7.1-gd php7.1-mysql php7.1-imap phpmyadmin php7.1-cli php7.1-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear mcrypt imagemagick libruby libapache2-mod-python php7.1-curl php7.1-intl php7.1-pspell php7.1-recode php7.1-sqlite3 php7.1-tidy php7.1-xmlrpc php7.1-xsl memcached php-memcache php-imagick php-gettext php7.1-zip php7.1-mbstring php7.1-opcache php7.1-json php7.1-ldap php7.1-soap php7.1-bz2 php7.1-bcmath php7.1-xml php7.1-dev php7.1-fpm php7.1-phpdbg php-apcu php7.1-readline pkg-php-tools shtool xml2 dh-php dh-make
## Install PHP 7.2
sudo apt install php7.2 php7.2-common php7.2-gd php7.2-mysql php7.2-imap phpmyadmin php7.2-cli php7.2-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear mcrypt imagemagick libruby libapache2-mod-python php7.2-curl php7.2-intl php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl memcached php-memcache php-imagick php-gettext php7.2-zip php7.2-mbstring php7.2-opcache php7.2-json php7.2-ldap php7.2-soap php7.2-bz2 php7.2-bcmath php7.2-xml php7.2-dev php7.2-fpm php7.2-phpdbg php-apcu php7.2-readline pkg-php-tools shtool xml2 dh-php dh-make
## Install PHP 7.3
sudo apt install php7.3 php7.3-common php7.3-gd php7.3-mysql php7.3-imap phpmyadmin php7.3-cli php7.3-cgi libapache2-mod-fcgid apache2-suexec-pristine php-pear mcrypt imagemagick libruby libapache2-mod-python php7.3-curl php7.3-intl php7.3-pspell php7.3-recode php7.3-sqlite3 php7.3-tidy php7.3-xmlrpc php7.3-xsl memcached php-memcache php-imagick php-gettext php7.3-zip php7.3-mbstring php7.3-opcache php7.3-json php7.3-ldap php7.3-soap php7.3-bz2 php7.3-bcmath php7.3-xml php7.3-dev php7.3-fpm php7.3-phpdbg php-apcu php7.3-readline libapache2-mod-php7.3 pkg-php-tools shtool xml2 dh-php dh-make
## Install PHP 7.4
sudo apt install php7.4 php7.4-cli php7.4-common php7.4-dev php7.4-fpm php7.4-cgi libphp7.4-embed php7.4-phpdbg php7.4-readline php7.4-curl php7.4-mysql php7.4-sqlite3 php7.4-pgsql php7.4-imap imagemagick php7.4-imagick php7.4-gd memcached php7.4-memcached php7.4-memcache php7.4-opcache php-apcu php-apcu-bc php7.4-apcu php7.4-apcu-bc php7.4-igbinary php7.4-mcrypt php7.4-bcmath php7.4-zip php7.4-bz2 xml2 php7.4-xml php7.4-tidy php7.4-xsl php7.4-json php7.4-intl php7.4-mbstring php7.4-pspell php7.4-ldap php7.4-soap php7.4-xmlrpc php-pear pkg-php-tools shtool dh-php dh-make php-geoip php7.4-geoip libruby
### Papildomai, jei naudojamas apache apache
sudo apt install libapache2-mod-php7.4 libapache2-mod-fcgid apache2-suexec-pristine libapache2-mod-python
## Install PHP 8.0
sudo apt install php8.0 php8.0-cli php8.0-common php8.0-dev php8.0-fpm php8.0-cgi libphp8.0-embed php8.0-phpdbg php8.0-readline php8.0-curl php8.0-mysql php8.0-sqlite3 php8.0-pgsql php8.0-imap imagemagick php8.0-imagick php8.0-gd memcached php8.0-memcached php8.0-memcache php8.0-opcache php-apcu php-apcu-bc php8.0-apcu php8.0-igbinary php8.0-mcrypt php8.0-bcmath php8.0-zip php8.0-bz2 xml2 php8.0-xml php8.0-tidy php8.0-xsl php8.0-intl php8.0-mbstring php8.0-pspell php8.0-ldap php8.0-soap php8.0-xmlrpc php-pear pkg-php-tools shtool dh-php dh-make php-geoip libruby
### Papildomai, jei naudojamas apache apache
sudo apt install libapache2-mod-php8.0 libapache2-mod-fcgid apache2-suexec-pristine libapache2-mod-python
## Install PHP 8.1
sudo apt install php8.1 php8.1-cli php8.1-common php8.1-dev php8.1-fpm php8.1-cgi libphp8.1-embed php8.1-phpdbg php8.1-readline php8.1-curl php8.1-mysql php8.1-sqlite3 php8.1-pgsql php8.1-imap imagemagick php8.1-imagick php8.1-gd memcached php8.1-memcached php8.1-memcache php8.1-opcache php-apcu php-apcu-bc php8.1-apcu php8.1-igbinary php8.1-mcrypt php8.1-bcmath php8.1-zip php8.1-bz2 xml2 php8.1-xml php8.1-tidy php8.1-xsl php8.1-intl php8.1-mbstring php8.1-pspell php8.1-ldap php8.1-soap php8.1-xmlrpc php-pear pkg-php-tools shtool dh-php dh-make php-geoip libruby
### Papildomai, jei naudojamas apache apache
sudo apt install libapache2-mod-php8.1 libapache2-mod-fcgid apache2-suexec-pristine libapache2-mod-python
## Install PHP 8.2
sudo apt install php8.2 php8.2-cli php8.2-common php8.2-dev php8.2-fpm php8.2-cgi libphp8.2-embed php8.2-phpdbg php8.2-readline php8.2-curl php8.2-mysql php8.2-sqlite3 php8.2-pgsql php8.2-imap imagemagick php8.2-imagick php8.2-gd memcached php8.2-memcached php8.2-memcache php8.2-opcache php-apcu php-apcu-bc php8.2-apcu php8.2-igbinary php8.2-mcrypt php8.2-bcmath php8.2-zip php8.2-bz2 xml2 php8.2-xml php8.2-tidy php8.2-xsl php8.2-intl php8.2-mbstring php8.2-pspell php8.2-ldap php8.2-soap php8.2-xmlrpc php-pear pkg-php-tools shtool dh-php dh-make php-geoip libruby
### Papildomai, jei naudojamas apache apache
sudo apt install libapache2-mod-php8.2 libapache2-mod-fcgid apache2-suexec-pristine libapache2-mod-python
## Install PHP 8.3
sudo apt install php8.3 php8.3-cli php8.3-common php8.3-dev php8.3-fpm php8.3-cgi libphp8.3-embed php8.3-phpdbg php8.3-readline php8.3-curl php8.3-mysql php8.3-sqlite3 php8.3-pgsql php8.3-imap imagemagick php8.3-imagick php8.3-gd memcached php8.3-memcached php8.3-memcache php8.3-opcache php-apcu php-apcu-bc php8.3-apcu php8.3-igbinary php8.3-bcmath php8.3-zip php8.3-bz2 xml2 php8.3-xml php8.3-tidy php8.3-xsl php8.3-intl php8.3-mbstring php8.3-pspell php8.3-ldap php8.3-soap php8.3-xmlrpc php-pear pkg-php-tools shtool dh-php dh-make php-geoip libruby
### Papildomai, jei naudojamas apache apache
sudo apt install libapache2-mod-php8.3 libapache2-mod-fcgid apache2-suexec-pristine libapache2-mod-python
# For command line
## Managing Multiple Versions
### https://github.com/oerdnj/deb.sury.org/wiki/Managing-Multiple-Versions
update-alternatives --query php
sudo update-alternatives --config php
# For command line
## It's important to note that there are four important PHP commands you should update if changing the default versions.
## These include php, php-config, phpdbg and phpize. So, to fully migrate to PHP 8.1, execute the following:
sudo update-alternatives --set php /usr/bin/php8.1
sudo update-alternatives --set php-config /usr/bin/php-config8.1
sudo update-alternatives --set phpdbg /usr/bin/phpdbg8.1
sudo update-alternatives --set phpize /usr/bin/phpize8.1
sudo update-alternatives --set phar /usr/bin/phar8.1
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.1
# For command line
## It's important to note that there are four important PHP commands you should update if changing the default versions.
## These include php, php-config, phpdbg and phpize. So, to fully migrate to PHP 8.0, execute the following:
sudo update-alternatives --set php /usr/bin/php8.0
sudo update-alternatives --set php-config /usr/bin/php-config8.0
sudo update-alternatives --set phpdbg /usr/bin/phpdbg8.0
sudo update-alternatives --set phpize /usr/bin/phpize8.0
sudo update-alternatives --set phar /usr/bin/phar8.0
sudo update-alternatives --set phar.phar /usr/bin/phar.phar8.0
# For command line
## It's important to note that there are four important PHP commands you should update if changing the default versions.
## These include php, php-config, phpdbg and phpize. So, to fully migrate to PHP 7.4, execute the following:
sudo update-alternatives --set php /usr/bin/php7.4
sudo update-alternatives --set php-config /usr/bin/php-config7.4
sudo update-alternatives --set phpdbg /usr/bin/phpdbg7.4
sudo update-alternatives --set phpize /usr/bin/phpize7.4
sudo update-alternatives --set phar /usr/bin/phar7.4
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4
# Ubuntu ISPConfig kol kas neveikia su php8.0, todėl reikia default php7.4
sudo update-alternatives --config php
sudo update-alternatives --config php-cgi
# For apache
## https://tecadmin.net/switch-between-multiple-php-version-on-ubuntu/
### Switch From PHP 7.4 => PHP 8.0
sudo a2dismod php7.4
sudo a2enmod php8.0
sudo service apache2 restart
### Switch From PHP 8.0 => PHP 7.4
sudo a2dismod php8.0
sudo a2enmod php7.4
sudo service apache2 restart
# ISPConfig setup
## Add other PHP versions
### https://www.howtoforge.com/tutorial/how-to-install-php-7-for-ispconfig-3-from-debian-packages-on-debian-8-and-9/
### PHP 5.6
Path to the PHP FastCGI binary: php-cgi5.6
Path to the php.ini directory: /etc/php/5.6/cgi/php.ini
Path to the PHP-FPM init script: php5.6-fpm
Path to the php.ini directory: /etc/php/5.6/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/5.6/fpm/pool.d
### The cli version for e.g. cron jobs has the name php5.6.
### PHP 7.0
Path to the PHP FastCGI binary: php-cgi7.0
Path to the php.ini directory: /etc/php/7.0/cgi/php.ini
Path to the PHP-FPM init script: php7.0-fpm
Path to the php.ini directory: /etc/php/7.0/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/7.0/fpm/pool.d
### The cli version for e.g. cron jobs has the name php7.0.
### PHP 7.1
Path to the PHP FastCGI binary: php-cgi7.1
Path to the php.ini directory: /etc/php/7.1/cgi/php.ini
Path to the PHP-FPM init script: php7.1-fpm
Path to the php.ini directory: /etc/php/7.1/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/7.1/fpm/pool.d
### The cli version for e.g. cron jobs has the name php7.1.
### PHP 7.2
Path to the PHP FastCGI binary: php-cgi7.2
Path to the php.ini directory: /etc/php/7.2/cgi/php.ini
Path to the PHP-FPM init script: php7.2-fpm
Path to the php.ini directory: /etc/php/7.2/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/7.2/fpm/pool.d
### The cli version for e.g. cron jobs has the name php7.2.
### PHP 7.3
Path to the PHP FastCGI binary: php-cgi7.3
Path to the php.ini directory: /etc/php/7.3/cgi/php.ini
Path to the PHP-FPM init script: php7.3-fpm
Path to the php.ini directory: /etc/php/7.3/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/7.3/fpm/pool.d
### The cli version for e.g. cron jobs has the name php7.3.
### PHP 7.4
Path to the PHP FastCGI binary: php-cgi7.4
Path to the php.ini directory: /etc/php/7.4/cgi/php.ini
Path to the PHP-FPM init script: php7.4-fpm
Path to the php.ini directory: /etc/php/7.4/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/7.4/fpm/pool.d
PHP-FPM socket directory: /var/lib/php7.4-fpm
### The cli version for e.g. cron jobs has the name php7.4.
### PHP 8.0
Path to the PHP FastCGI binary: php-cgi8.0
Path to the php.ini directory: /etc/php/8.0/cgi/php.ini
Path to the PHP-FPM init script: php8.0-fpm
Path to the php.ini directory: /etc/php/8.0/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/8.0/fpm/pool.d
PHP-FPM socket directory: /var/lib/php8.0-fpm
### The cli version for e.g. cron jobs has the name php8.0.
### PHP 8.1
Path to the PHP FastCGI binary: php-cgi8.1
Path to the php.ini directory: /etc/php/8.1/cgi/php.ini
Path to the PHP-FPM init script: php8.1-fpm
Path to the php.ini directory: /etc/php/8.1/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/8.1/fpm/pool.d
PHP-FPM socket directory: /var/lib/php8.1-fpm
### The cli version for e.g. cron jobs has the name php8.1.
### PHP 8.2
Path to the PHP FastCGI binary: php-cgi8.2
Path to the php.ini directory: /etc/php/8.2/cgi/php.ini
Path to the PHP-FPM init script: php8.2-fpm
Path to the php.ini directory: /etc/php/8.2/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/8.2/fpm/pool.d
PHP-FPM socket directory: /var/lib/php8.2-fpm
### The cli version for e.g. cron jobs has the name php8.2.
### PHP 8.3
Path to the PHP FastCGI binary: php-cgi8.3
Path to the php.ini directory: /etc/php/8.3/cgi/php.ini
Path to the PHP-FPM init script: php8.3-fpm
Path to the php.ini directory: /etc/php/8.3/fpm/php.ini
Path to the PHP-FPM pool directory: /etc/php/8.3/fpm/pool.d
PHP-FPM socket directory: /var/lib/php8.3-fpm
### The cli version for e.g. cron jobs has the name php8.3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment