Skip to content
  • Homepage
  • HTML
  • CSS
  • Symfony
  • PHP
  • How to
  • Contact
  • Donate

Teach Developer

Articles, Guides & Tips

How To Install Nginx, PHP on Ubuntu 22.04

Home  »  HTML • PHP • Server   »   How To Install Nginx, PHP on Ubuntu 22.04
Posted on July 21, 2022July 21, 2022 4 Comments on How To Install Nginx, PHP on Ubuntu 22.04
631

Now, Open a terminal and start following the below steps.

Step 1 . Install Ngnix.

$ sudo apt update && sudo apt upgrade

our system is updated now we will install Nginx.

$ sudo apt install nginx

Ngnix is installed, Now we will configure the firewall, we will allow port 80 and port 443.

$ sudo ufw allow 80/tcp

$ sudo ufw allow 43/tcp

Now open your IP in the web browser you will see the output, If any problem occurred please comment below I will solve it soon.

Step 2 – Install PHP

As I before told you, we will install the latest version of PHP, This time when I am writing this post, the Current version is PHP8.1, So I will install PHP8.1.

The Ondrej/PHP PPA contains all PHP version’s for Ubuntu systems. So first we need to add this repository first.

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

Repository added now we are ready to install PHP.

sudo apt install php8.1

Note- You can also install any version of PHP like PHP 5.6, PHP 7.1, 7.2, 7.3, 7.4, and PHP 8.0, 8.1.

For PHP we need to Install and Configure PHP-FPM(FastCGI Process Manager).

$ sudo apt install php8.1-fpm

for a complete setup, we need some additional packages to install on our system.

$ sudo apt install php8.1-mysql php8.1-curl php8.1-xml

Note- If you want to use Laravel 9 to run on this system run the below command. This is an install extension pf PHP.

$ sudo apt install openssl php-common php-curl php-json php-mbstring php-mysql php-xml php-zip

Now configure the Ngnix to execute the PHP file.

$ sudo nano /etc/nginx/sites-enabled/default

and make changes which I am written below.

index index.php;

location / {
        try_files $uri $uri/ =404;
}

location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock;
}

Note- Please add index.php

HTML, PHP, Server

Post navigation

Previous Post: Difference between var, let, and const in JavaScript
Next Post: How to remove index.php from URL in CodeIgniter 4

Related Posts

  • HTML Tutorial
  • How to split a string into an array with Twig
  • HTML Basic Examples
  • How to check the PHP version
  • How to check PHP version using the command line
  • How to Send Email from Localhost in PHP

4 Comments on “How To Install Nginx, PHP on Ubuntu 22.04”

  1. Lucashmsilva says:
    July 24, 2022 at 6:40 am

    “Great content as always! Thanks a lot.”

    Reply
  2. Rakibul Haq says:
    July 24, 2022 at 6:46 am

    “This is what exactly I was looking for🙏
    Thanks a lot buddy for sharing.,its really easy to understand and implement.”

    Reply
  3. Alex Xu says:
    July 24, 2022 at 6:51 am

    Very detailed explanation. Thanks for sharing it.

    Reply
  4. Imanali Mamadiev says:
    July 24, 2022 at 6:57 am

    I love this articles. Thanks for sharing.

    Reply

Leave a Reply Cancel reply

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

Categories

  • Codeigniter (3)
  • CSS (11)
  • eCommerce (1)
  • Framework (1)
  • Git (3)
  • How to (43)
  • HTML (5)
  • JavaScript (15)
  • Jquery (7)
  • Laravel (1)
  • Linux (4)
  • Magento-2 (1)
  • Node js (4)
  • Others (2)
  • PHP (11)
  • React (13)
  • Server (1)
  • SSH (3)
  • Symfony (6)
  • Tips (16)
  • Top Tutorials (10)
  • Ubuntu (3)
  • Vue (1)
  • Wordpress (7)

Latest Posts

  • What is SSH in Linux?
  • How to Delete Files in Ubuntu Command Line
  • How to Deploy a React application on a cPanel
  • How to use events listeners and Event Subscriber in Symfony
  • How to Convert PHP CSV to JSON

WEEKLY TAGS

AJAX (1) Codeigniter (1) Javascript (11) JQuery (1) PHP (16) Programming (1) React (3) Symfony (1)

Random Post

Important most things you should know about JSX
How to Symfony parameters and environment variables use
How to Get Environment Variables in Laravel ReactJS
CSS
ReactJs Properties

Quick Navigation

  • About
  • Contact
  • Privacy Policy

© Teach Developer 2021. All rights reserved