What's new
BAJUBESI.ORG

Welcome to bajubesi.org, become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Help me install multiple php version on my ubuntu 24.04 server

Belon

Root Administrator
Staff member
Joined
Dec 1, 2024
Messages
26
Reaction score
2
Points
8
Location
Malaysia
Website
bajubesi.com.my
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?
 
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:
Bash:
sudo apt update
sudo apt upgrade
2. Now let's download and configure the necessary dependencies for compiling PHP from source:
Bash:
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:
Bash:
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):
Bash:
wget https://www.php.net/distributions/php-7.4.10.tar.gz
5. Extract the files:
Bash:
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:
Bash:
./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:
Bash:
make
8. Install PHP globally with update-alternatives:
Bash:
sudo make install
9. Setup the configuration file for PHP 7.4:
Bash:
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.
 
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:
Bash:
sudo apt update
sudo apt upgrade
2. Now let's download and configure the necessary dependencies for compiling PHP from source:
Bash:
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:
Bash:
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):
Bash:
wget https://www.php.net/distributions/php-7.4.10.tar.gz
5. Extract the files:
Bash:
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:
Bash:
./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:
Bash:
make
8. Install PHP globally with update-alternatives:
Bash:
sudo make install
9. Setup the configuration file for PHP 7.4:
Bash:
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?
 
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.
 
Back
Top