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
“Great content as always! Thanks a lot.”
“This is what exactly I was looking for🙏
Thanks a lot buddy for sharing.,its really easy to understand and implement.”
Very detailed explanation. Thanks for sharing it.
I love this articles. Thanks for sharing.