Installing and configuring PHP on a server

2 min readUpdated December 6, 2025

PHP is a popular open-source general-purpose scripting language. It is specifically designed for web development, and its code can be embedded directly into HTML.

#Adding required libraries

Use the following command:

bash
sudo apt-get -y install ca-certificates apt-transport-https

#PHP installation

You need to use the following two commands:

bash
wget -q https://packages.sury.org/php/apt.gpg -O- | apt-key add - echo "deb https://packages.sury.org/php/ stretch main" | tee /etc/apt/sources.list.d/php.list

Next, install PHP and its core modules:

bash
sudo apt-get -y install php7.4 php7.4-{mcrypt,mysql,fpm}

Did not find the answer? We are online 24/7.Contact support