• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Source Digit

Source Digit

Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • How To
  • Ubuntu
  • Instagram
  • Blogging
  • Android
  • WordPress
  • +More
    • Cloud Computing
    • Gadgets
    • Social Media
    • Technology
  • Write for Us
Home / How To / How To Install Php on Ubuntu Linux Using Terminal Commandline

How To Install Php on Ubuntu Linux Using Terminal Commandline

By Sourabh / July 19, 2020 Category: How To, Ubuntu

How to install PHP on Ubuntu Linux using terminal commandline. PHP stands for Hypertext Preprocessor (no, the acronym doesn’t follow the name). It’s an open source, server-side, scripting language used for the development of web applications. PHP is script-based (lines of code) program written for the automation of tasks.

Note that HTML is that HTML is a front-end language that runs on the browser, while PHP is back-end and runs on the server.

Installing PHP 7.4 with Apache

sudo apt upgrade
sudo apt update
sudo apt install php libapache2-mod-php
apt-get install php5-common libapache2-mod-php5 php5-cli
sudo systemctl restart apache2

You can also run the following commands for stopping and starting Apache once PHP is installed:

# /etc/init.d/apache2 stop
# /etc/init.d/apache2 start

Installing PHP 7.4 with Nginx

sudo apt upgrade
sudo apt update
sudo apt install php-fpm
systemctl status php7.4-fpm
sudo systemctl restart nginx

You can also install PHP with MySQL, cURL using the following command:

sudo apt upgrade
sudo apt update
sudo apt-get install php5-mysql php5-curl

APT will automatically add the appropriate lines to the different php.ini related files like /etc/php5/apache2/php.ini, /etc/php5/conf.d/pdo.ini, etc. and depending on the extension will add entries similar to extension=foo.so. However, restarting the web server (like Apache) is required before these changes take affect.

Installing PHP extensions

Once PHP is installed, users can also install PHP extensions compiled libraries such as MySQL and GD extensions and many more:

sudo apt install php-[extname]
sudo apt install php-mysql php-gd

After installing a new PHP extension, you miust restart Apache or PHP service.

NOTE:

  1. If the PHP scripts are not parsing via the web server, then it’s likely that PHP was not added to the web server’s configuration file, which on Debian may be /etc/apache2/apache2.conf or similar. See the Debian manual for further details.
  2. If an extension was seemingly installed yet the functions are undefined, be sure that the appropriate ini file is being loaded and/or the web server was restarted after installation.
  3. There are two basic commands for installing packages on Debian (and other linux variants): apt-get and aptitude. However, explaining the subtle differences between these commands goes beyond the scope of this manual.

Primary Sidebar

Latest Posts

Ubuntu 25.04 ‘Plucky Puffin’ Is Available To Download

How to Login as Root User in Linux Terminal

Install Firefox In Ubuntu Terminal Command Line

How To Check Kernel Installed Date In Linux Ubuntu

How To List All Kernel Modules That Are Loaded In Ubuntu

Enable Ubuntu Auto Login Without Password

Download Ubuntu 25.04 Official Default Wallpapers

How To Fix Initramfs Error In Ubuntu Command Line

How To Check All Available Kernel Version In Linux Ubuntu

3 Best Artificial Intelligence Domain Name Generators

© 2025 Source Digit • Linux, Ubuntu Tutorials & News, Technology, Gadgets & Gizmos

  • Home
  • About
  • Privacy Policy
  • Terms & Conditions
  • Contact Us
  • Sitemap