• About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap
Linux Tutorials for Beginners
Advertisement
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
  • Ubuntu
    Install and Secure phpMyAdmin on Ubuntu 22.04

    How To Install and Secure phpMyAdmin on Ubuntu 22.04

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Ubuntu 22.04

    Install Uptime Kuma on Ubuntu 22.04

    How To Install Uptime Kuma on Ubuntu 22.04

    Install Ubuntu Server 22.04

    How To Install Ubuntu Server 22.04 LTS with Screenshots

    Set Up Firewall on Ubuntu 22.04

    How To Set Up a Firewall with UFW on Ubuntu 22.04

    Install Nginx on Ubuntu

    How To Install Nginx on Ubuntu 22.04: A Comprehensive Guide

    Install MySQL 8.0 on Ubuntu 22.04

    How To Install MySQL 8.0 on Ubuntu Server 22.04

    install-php74-ubuntu2204

    How To Install PHP 7.4 on Ubuntu 22.04

    Install Snipe-IT on Ubuntu 22.04

    How To Install Snipe-IT Asset Management on Ubuntu 22.04

  • Debian
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Debian 11

    Install Debian 11 Server

    How To Install Debian 11 (Bullseye) Server with Pictures

    Install and Setup Node.js on Debian 11

    How To Install and Setup Node.js on Debian 11

    Install PHP 8.2 on Debian 11

    How To Install PHP 8.2 on Debian 11

    Install Nginx on Debian 11

    How To Install Nginx on Debian 11: A Comprehensive Guide

    Set Up Firewall with UFW on Debian

    How To Set Up a Firewall with UFW on Debian 11

    install php74 on debian 11

    How To Install PHP 7.4 on Debian 11

    Install MariaDB 10.9 on Debian 11

    How To Install MariaDB 10.9 on Debian 11 Server

    Initial Setup Debian Server

    Initial Setup Debian 11 Server: Secure and Efficient

  • Rocky Linux
    Install phpMyAdmin on Rocky Linux 9

    How To Install phpMyAdmin on Rocky Linux 9

    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on Rocky Linux 9

    Install Rocky Linux 9.2 Server

    How To Install Rocky Linux 9.2 Server with Screenshots

    setup Firewall Using Firewalld Rocky Linux 9

    How To Set Up a Firewall Using FirewallD on Rocky Linux 9

    Install Nginx on Rocky Linux 9

    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide

    Install Apache on Rocky Linux

    How To Install and Configure Apache on Rocky Linux 9

    Install MongoDB on Rocky Linux 9

    How To Install MongoDB 6.0 on Rocky Linux 9

    Install Docker on Rocky Linux

    How To Install Docker CE on Rocky Linux 9

  • CentOS
    Secure SSH with Fail2Ban

    How To Secure SSH with Fail2Ban on CentOS 7

    Install PHP8.2 on CentOS 7

    How To Install PHP 8.2 on CentOS 7 / RHEL 7

    Install Apache on CentOS 7

    How To Install Apache Web Server on CentOS 7

    Set Up FirewallD on CentOS 7

    How To Set Up a Firewall Using FirewallD on CentOS 7

    Initial Setup CentOS 7 Server

    Initial Setup CentOS 7 Server: Secure and Efficient

    Install Nginx on CentOS 7

    How To Install Nginx on CentOS 7: A Comprehensive Guide

    Build NGINX from Source on Centos 7

    How To Build NGINX from Source (Compile) on Centos7

    Install Docker Swarm on CentOS 7

    Install and Configure Docker Swarm Mode on Centos 7

    Install Docker Compose on Centos 7

    How To Install and Use Docker Compose on Centos 7

  • Linux
    Manage Groups on Linux

    A Simple Guide: How To Manage Groups on Linux

    Logrotate In Linux

    How To Manage Log Files Using Logrotate In Linux

    Check File Size in Linux

    The Easy Ways to Check File Size in Linux

    Linux server security system administrators

    Best Practices Linux Server Security for System Administrator

    Backup Files From Remote Linux VPS Using Rsync Script

    How To Backup Files From Remote Linux VPS Using Rsync Script

    SSH Key-based Authentication

    How To Configure SSH Key-based Authentication In Linux

    Linux File Permissions

    Understanding Linux File Permissions for Beginners

    Create Multiboot USB with Ventoy

    How To Create Multiboot USB with Ventoy in Linux

    Find Hard Disk Drive Information in Linux

    How To Find Hard Disk Drive Information in Linux

No Result
View All Result
Linux Tutorials for Beginners
No Result
View All Result

Home » Ubuntu » How To Install PHP 7.4 on Ubuntu 22.04

How To Install PHP 7.4 on Ubuntu 22.04

sammbysamm
October 17, 2023
install-php74-ubuntu2204

How To Install PHP 7.4 on Ubuntu Server 22.04

Share on FacebookShare on LinkedinShare on Whatsapp

This article provides an in-depth, step-by-step guide on how to install and config PHP7.4 on Ubuntu 22.04, you to take full advantage of its capabilities and streamline your development workflows “How To Install PHP 7.4 on Ubuntu Server 22.04”.

Ubuntu Server 22.04 is a popular choice for hosting web applications and services due to its stability, security, and ease of use.

OTHER POSTS

How To Install and Secure phpMyAdmin on Ubuntu 22.04

How To Secure SSH with Fail2Ban on Ubuntu 22.04

How To Install Uptime Kuma on Ubuntu 22.04

PHP is a crucial component for many web applications, providing the server-side scripting needed to generate dynamic content. In this step-by-step guide, we’ll walk you through the process of how to install PHP 7.4 on Ubuntu Server 22.04, ensuring that your server is equipped to handle a wide range of web-based tasks. Let’s get started.

PHP 7.4, often referred to as PHP 7.4.x, is a version of the PHP programming language. PHP is a widely-used open-source scripting language that is particularly suited for web development. Each new version of PHP brings improvements in terms of performance, security, features, and bug fixes.

Table of Contents

  • Key Features PHP 7.4
  • Prerequisites to Install PHP 7.4 on Ubuntu
  • Install PHP 7.4 on Ubuntu Server 22.04
    • Step 1: Update System Packages
    • Step 2: Add PPA Repository
    • Step 3: Update Package List
    • Step 4: Install PHP 7.4 on Ubuntu
    • Step 5: Verify PHP 7.4 Installation
    • Step 6: Install Additional PHP 7.4 Extensions
    • Step 7: Configure PHP 7.4
    • Step 8: Restart PHP-FPM Service
    • Step 9: Test PHP
    • Step 10: Clean Up
  • Conclusion

Key Features PHP 7.4

PHP 7.4 is one of the intermediate versions in the PHP 7 series, which was a major milestone for the language. It introduced significant performance enhancements compared to PHP 5.x, along with a number of new features and improvements. Some of the key features and improvements introduced in PHP 7.4 include:

  1. Typed Properties: PHP 7.4 introduced the ability to declare type hints for class properties. This improves code clarity and helps catch type-related errors during development.
  2. Arrow Functions: Arrow functions provide a shorter syntax for defining anonymous functions, making code more concise and readable.
  3. Covariant Returns and Contravariant Parameters: PHP 7.4 introduced better support for covariance and contravariance in method signatures, which helps with improving type flexibility and safety.
  4. Preloading: This feature allows certain files to be preloaded into memory, resulting in improved performance by reducing the need to load and parse files on each request.
  5. Shorter Syntax for Exceptions: PHP 7.4 introduced a shorter syntax for throwing exceptions, making error handling more streamlined.
  6. Improved Error Messages: Error messages and warnings in PHP 7.4 are more descriptive and helpful, aiding developers in identifying and resolving issues more effectively.
  7. Numeric Literal Separator: Developers can now use underscores to separate groups of digits in numeric literals, enhancing code readability for large numbers.
  8. Weak References: PHP 7.4 introduced support for weak references, which allows developers to maintain references to objects without preventing them from being garbage-collected when they’re no longer needed.

These are just a few highlights of the improvements and features introduced in PHP 7.4. As with any programming language, using the latest version ensures that you have access to the most up-to-date tools, performance enhancements, and security improvements, along with access to a larger ecosystem of packages and libraries developed by the community.

Prerequisites to Install PHP 7.4 on Ubuntu

Before we dive into the installation process, there is prerequisite you need to ensure are in place:

  • Ubuntu Server: Make sure you have a clean installation of Ubuntu Server. You can deploy this on a physical machine or a virtual environment like VMware or VirtualBox.  To set this up, follow our guide :
    • Initial Setup Ubuntu Server 22.04: Secure and Efficient

Install PHP 7.4 on Ubuntu Server 22.04

Step 1: Update System Packages

Before you begin, it’s essential to update your server’s package list to ensure you’re working with the latest software versions. Open a terminal window and enter the following commands:

$ sudo apt update
$ sudo apt upgrade

This command fetches the latest package information from the Ubuntu repositories, ensuring that you install the most recent version of PHP.

Step 2: Add PPA Repository

Ubuntu 22.04 doesn’t include PHP 7.4 in its default repositories, so you’ll need to add the repository that contains it. We will use the Ondrej PPA for installing PHP on Ubuntu 22.04 LTS system. Enter the following command:

$ sudo add-apt-repository ppa:ondrej/php

Step 3: Update Package List

After adding the repository, update the package list again to include the new repository’s contents:

$ sudo apt update

Step 4: Install PHP 7.4 on Ubuntu

To install PHP 7.4, you can use the following command:

$ sudo apt install php7.4

This command will install the core PHP 7.4 packages, along with the most commonly used extensions. Once the installation is complete, you’ll have PHP 7.4 ready to go on your server.

Step 5: Verify PHP 7.4 Installation

After the installation is finished, you should verify that PHP 7.4 is installed correctly. You can do this by running:

$ php -v

This command will display the installed PHP version. You should see output indicating that PHP 7.4 is installed along with the version number.

PHP 7.4.33 (cli) (built: Jun  8 2023 15:23:32) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.33, Copyright (c), by Zend Technologies

Step 6: Install Additional PHP 7.4 Extensions

Depending on the requirements of your web applications, you may need to install additional PHP extensions. Common extensions for various web applications include mysql, gd, curl, json, and more. To install an extension, use the following syntax:

sudo apt install php7.4-<extension-name>

For example, to install the extension, you would run:

$ sudo apt install php7.4-{cli,fpm,common,zip,gd,mcrypt,mbstring,curl,xml,bcmath,json,ldap,fileinfo,tokenizer,opcache,apcu,pdo,mysql,mysqlnd,mysqli,pgsql,mongodb,redis,memcache,memcached,sockets,imagick,iconv,exif,simplexml,dom}

Repeat this step for each extension you need.

Step 7: Configure PHP 7.4

Optimize PHP’s configuration to enhance performance for your website. Open the php.ini file using your preferred text editor. For example:

$ sudo vi /etc/php/7.4/cli/php.ini

Adjust the following settings to optimize PHP:

  • Increase the memory limit:
memory_limit = 256M
  • Enable OPCache for opcode caching:
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=60
opcache.fast_shutdown=1

Step 8: Restart PHP-FPM Service

After making configuration changes, restart the PHP-FPM service for the changes to take effect:

$ sudo systemctl restart php7.4-fpm.service

Step 9: Test PHP

To ensure that PHP is working correctly, you can create a simple test PHP file and access it through your web browser. Create a file named info.php in your web server’s document root (usually /var/www/html/):

$ sudo vi /var/www/html/info.php

Add the following content to the info.php file:

<?php
 
phpinfo();
 
?>

Save the file and exit the text editor. Now, open your web browser and navigate to http://your-server-ip/info.php.

Install PHP 7.4 on Ubuntu 22.04
Info-php74 on Ubuntu

You should see a page displaying detailed information about your PHP installation.

Step 10: Clean Up

Once you’ve verified that PHP 7.4 is working as expected, you can remove the info.php file, as it contains sensitive information about your PHP installation:

$ sudo rm /var/www/html/info.php

Conclusion

By following this step-by-step guide, you’ve successfully install PHP 7.4 on Ubuntu Server 22.04. PHP is a powerful tool for developing dynamic web applications, and with the right extensions, you can handle a wide range of tasks.

Also Read Our Other Guides :

  • How To Install PHP 7.4 on Debian 11
  • How To Install PHP8.2 on Ubuntu Server 22.04
  • How To Install PHP 8.2 on Debian 11
  • How To Install PHP8.2 on Rocky Linux 9
  • How To Install PHP 8.2 on CentOS 7 / RHEL 7

Keep in mind that security updates are essential, so regularly update your server to stay protected. Now that you have PHP up and running, you’re ready to start building and deploying your web applications. Hopefully, now you have learned how to install PHP 7.4 on Ubuntu Server 22.04.

Tags: LampPHPPHP 7.4PHP-FPMProgramming LanguageUbuntu

If you got help by our tutorials, please buy me a coffee..!

Buy Me a Coffee

Thank you so much for your support!!

Previous Post

How To Install Snipe-IT Asset Management on Ubuntu 22.04

Next Post

Initial Setup Debian 11 Server: Secure and Efficient

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

RECENT POST

Install and Secure phpMyAdmin on Ubuntu 22.04

How To Install and Secure phpMyAdmin on Ubuntu 22.04

by samm
July 22, 2024
0

Are you ready to take control of your MySQL databases on Ubuntu 22.04? In this step-by-step guide, we'll walk you...

Manage Groups on Linux

A Simple Guide: How To Manage Groups on Linux

by samm
November 12, 2023
0

Are you a Linux enthusiast looking to enhance your system administration skills? One fundamental aspect you should master is how...

Install phpMyAdmin on Rocky Linux 9

How To Install phpMyAdmin on Rocky Linux 9

by samm
November 11, 2023
0

If you're navigating the world of Rocky Linux 9 and looking to streamline your MariaDB or MySQL database management, installing...

Logrotate In Linux

How To Manage Log Files Using Logrotate In Linux

by samm
November 10, 2023
0

Log files are an essential part of any Linux system. They provide valuable insights into the system's activities, helping administrators...

Load More

RECOMMENDED.

Install Redis on Debian

How To Install Redis on Debian 11 Server

October 16, 2023
Secure SSH with Fail2Ban

How To Secure SSH with Fail2Ban on Rocky Linux 9

October 29, 2023
sammlinux sammlinux sammlinux

Related Posts

Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu

How To Install and Secure phpMyAdmin on Ubuntu 22.04

July 22, 2024
Secure SSH with Fail2Ban
Ubuntu

How To Secure SSH with Fail2Ban on Ubuntu 22.04

October 29, 2023
Install Uptime Kuma on Ubuntu 22.04
Ubuntu

How To Install Uptime Kuma on Ubuntu 22.04

November 12, 2023
Install Ubuntu Server 22.04
Ubuntu

How To Install Ubuntu Server 22.04 LTS with Screenshots

October 21, 2023
Load More
Next Post
Initial Setup Debian Server

Initial Setup Debian 11 Server: Secure and Efficient

  • About Us
  • Disclaimers
  • Privacy Policy
  • Sitemap

© 2023 sammlinux - Learn Today for Lead Tomorrow.

No Result
View All Result
  • Ubuntu
  • Debian
  • Rocky Linux
  • CentOS
  • Linux

© 2023 sammlinux - Learn Today for Lead Tomorrow.