Skip to content

Instantly share code, notes, and snippets.

@zdienos
Last active May 21, 2024 05:40
Show Gist options
  • Save zdienos/b06ee3e6d766b765f11f4ea73b84613d to your computer and use it in GitHub Desktop.
Save zdienos/b06ee3e6d766b765f11f4ea73b84613d to your computer and use it in GitHub Desktop.
Instalasi banyak versi php (multi php)

Instalasi Multiple PHP!

Hi! ini catatan saja, biar ndak lupa, bagaimana cara menginstall banyak versi php dalam satu mesin linux (ubuntu) menggunakan fpm.

Tambah Repository ondrej

sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y

Instalasi versi php yang diinginkan

Usahakan menginstall versi php yang paling rendah dulu, lalu ke yang tinggi.

sudo apt install php7.2 php7.2-fpm libapache2-mod-php7.2 php7.2-curl php7.2-intl php7.2-zip php7.2-soap php7.2-xml php7.2-gd php7.2-mbstring php7.2-bcmath php7.2-common php7.2-xml php7.2-mysqli php7.2-tidy -y
sudo apt install php7.4 php7.4-fpm libapache2-mod-php7.4 php7.4-curl php7.4-intl php7.4-zip php7.4-soap php7.4-xml php7.4-gd php7.4-mbstring php7.4-bcmath php7.4-common php7.4-xml php7.4-mysqli php7.4-tidy -y
sudo apt install php8.1 php8.1-fpm libapache2-mod-php8.1 php8.1-curl php8.1-intl php8.1-zip php8.1-soap php8.1-xml php8.1-gd php8.1-mbstring php8.1-bcmath php8.1-common php8.1-xml php8.1-mysqli php8.1-tidy -y
sudo apt install php8.2 php8.2-fpm libapache2-mod-php8.2 php8.2-curl php8.2-intl php8.2-zip php8.2-soap php8.2-xml php8.2-gd php8.2-mbstring php8.2-bcmath php8.2-common php8.2-xml php8.2-mysqli php8.2-tidy -y

Jalankan dan cek status service FPM yang diinginkan

sudo systemctl start php7.4-fpm
sudo systemctl status php7.4-fpm

Install Modul Apache

sudo a2enmod php7.4
sudo a2enmod rewrite
sudo apt-get install libapache2-mod-fcgid -y
sudo a2enmod actions fcgid alias proxy_fcgi
sudo systemctl restart apache2

File .htaccess

Di setiap folder source code yang dijalankan, tentukan file .htaccess dengan memilih versi php yang diinginkan

<FilesMatch \.php$>
        # 2.4.10+ can proxy to unix socket
        SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
</FilesMatch>

You can export the current file by clicking Export to disk in the menu. You can choose to export the file as plain Markdown, as HTML using a Handlebars template or as a PDF.

Enable Disable Mod PHP

Hanya bisa jalan satu versi php di Apache service, jadi pastikan sudah didisable dulu baru enable versi php yang lain

sudo a2dismod phpY.y
sudo a2enmod phpX.x 
sudo service apache2 restart 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment