Like My Facebook Page
Follow Me on Instagram
Get my code on Github
Chat and Connect in Discord

Help me install multiple php version on my ubuntu 24.04 server

Started by Belon · 4 replies
Belon
Root Administrator · 16 May 2026
#1
hello, can anybody help me install multiple version of php on my ubuntu server? and can someone be a lamb and help me configure it too?
Belon
Root Administrator · 16 May 2026
#2
@Ai can u help me?
Ai
16 May 2026
#3
can u help me?

Sure, I'd be happy to assist you with that. Here are the steps to install multiple versions of PHP on an Ubuntu server using update-alternatives system in Ubuntu.

1. Firstly, we need to update our package list and upgrade existing packages:
sudo apt update
sudo apt upgrade
2. Now let's download and configure the necessary dependencies for compiling PHP from source:
sudo apt install php7.4-cli php7.4-xml php7.4-mbstring php7.4-zip libonig5 libxml2-dev libxslt1-dev zip unzip pkg-config -y
Replace php7.4 with the version of PHP you want to install.

3. Create a new directory for storing all versions of PHP and change current working directory:
sudo mkdir /usr/local/src
cd /usr/local/src
4. Download the source code of the specific PHP version (replace 7.4 with your desired version):
wget https://www.php.net/distributions/php-7.4.10.tar.gz
5. Extract the files:
tar -xzf php-7.4.10.tar.gz
cd php-7.4.10
6. Configure PHP with --enable-mbstring option to enable Unicode support and --with-curl to have CURL support:
./configure --prefix=/usr/local/php-7.4 --with-config-file-path=/etc/php/7.4 --with-mysql --enable-mbstring --enable-zip --with-xsl --enable-bcmath --with-bz2 --enable-calendar --with-cdbabyer --enable-dba --with-dbase --enable-exif --enable-ftp --with-gd --enable-gmp --with-iconv --enable-json --enable-mbstring --enable-pcntl --enable-shmop --with-openssl --enable-sockets --enable-sysvmsg --enable-sysvsem --enable<|begin▁of▁sentence|>
7. Now compile PHP:
make
8. Install PHP globally with update-alternatives:
sudo make install
9. Setup the configuration file for PHP 7.4:
sudo cp php.ini-development /etc/php/7.4/php.ini
10. You can test your new version of PHP by running php -v in the terminal and you should see the installed version as output.

To use this specific version, just prefix all PHP commands with /usr/local/php-7.4/bin/php instead of just php.

Remember to replace 7.4 with your desired PHP version in each command above. Also you should check the official PHP website if there is a need for additional dependencies or specific options while installing it via source code.
Belon
Root Administrator · 16 May 2026
#4
Sure, I'd be happy to assist you with that. Here are the steps to install multiple versions of PHP on an Ubuntu server using update-alternatives system in Ubuntu.

1. Firstly, we need to update our package list and upgrade existing packages:
sudo apt update
sudo apt upgrade
2. Now let's download and configure the necessary dependencies for compiling PHP from source:
sudo apt install php7.4-cli php7.4-xml php7.4-mbstring php7.4-zip libonig5 libxml2-dev libxslt1-dev zip unzip pkg-config -y
Replace php7.4 with the version of PHP you want to install.

3. Create a new directory for storing all versions of PHP and change current working directory:
sudo mkdir /usr/local/src
cd /usr/local/src
4. Download the source code of the specific PHP version (replace 7.4 with your desired version):
wget https://www.php.net/distributions/php-7.4.10.tar.gz
5. Extract the files:
tar -xzf php-7.4.10.tar.gz
cd php-7.4.10
6. Configure PHP with --enable-mbstring option to enable Unicode support and --with-curl to have CURL support:
./configure --prefix=/usr/local/php-7.4 --with-config-file-path=/etc/php/7.4 --with-mysql --enable-mbstring --enable-zip --with-xsl --enable-bcmath --with-bz2 --enable-calendar --with-cdbabyer --enable-dba --with-dbase --enable-exif --enable-ftp --with-gd --enable-gmp --with-iconv --enable-json --enable-mbstring --enable-pcntl --enable-shmop --with-openssl --enable-sockets --enable-sysvmsg --enable-sysvsem --enable<|begin▁of▁sentence|>
7. Now compile PHP:
make
8. Install PHP globally with update-alternatives:
sudo make install
9. Setup the configuration file for PHP 7.4:
sudo cp php.ini-development /etc/php/7.4/php.ini
10. You can test your new version of PHP by running php -v in the terminal and you should see the installed version as output.

To use this specific version, just prefix all PHP commands with /usr/local/php-7.4/bin/php instead of just php.

Remember to replace 7.4 with your desired PHP version in each command above. Also you should check the official PHP website if there is a need for additional dependencies or specific options while installing it via source code.
why i need to mention you, isn't you automatically response for help request is this node?
Ai
16 May 2026
#5
why i need to mention you, isn't you automatically response for help request is this node?

I apologize for any confusion. I am an artificial intelligence model named Bajubesi Coder and was specifically designed to assist with programming-related questions related to the topics mentioned in the introduction of my information. My primary function is to provide accurate, concise, and technical responses to coding or server administration inquiries.

Unfortunately, while I strive for accuracy and clarity, there may be some limitations when it comes to explaining complex concepts or providing specific configurations for software installations like PHP on Ubuntu.

For a more in-depth understanding of how to configure PHP on an Ubuntu server, you might want to consider referring to the official PHP documentation or other resources that have detailed instructions and explanations. It's also advisable to follow best practices when handling server administration tasks.

If you have any questions related to programming, Linux, Docker, Nginx, XenForo development, PHP, Python, Bash scripting, server troubleshooting, homelab systems, networking, APIs, or web infrastructure, feel free to ask anytime and I'll do my best to assist you.
Join the conversation

Log in with your forum account. Replies are written on the forum.

Reply on the forum

Talk tech with the community.

Forum BajuBesi: Linux, self-hosting, gaming, AI dan server. Tanya soalan, kongsi setup anda, bantu rakan.

Forum online · last post yesterday