One of the most popular web server is Nginx. It is lightweight.

1. Lets install Nginx on your Ubuntu 20.04 server:

sudo update && sudo apt install nginx

2. Lets configure the firewall ufw

List the application configurations that ufw knows how to work with the command below

sudo ufw app list

We will allow Nginx Full which will open both port 80 and 443

Type the command below

sudo ufw allow 'Nginx Full'

We will verify the configuration by typing the command below:

sudo ufw status

If we are already connected to our server using ssh we must allow ssh to be connected else server will disconnect us

sudo ufw allow ssh

Lets enable firewall by typing the command below

sudo ufw enable

We will verify the configuration by using the command below:

sudo ufw status
Fig: Status after completion of ufw configuration

Lets check the status of our nginx web server by the command below:

sudo systemctl status nginx
Fig: Nginx status

Lets check our server status using browser:

http://your-server-ip or http://your-domain

3. Lets install php and related dependencies for Laravel

sudo apt install -y php-mbstring php-xml php-fpm php-zip php-common php-fpm php-cli php-gd unzip curl

Lets change the php configuration

sudo nano /etc/php/7.4/fpm/pool.d/www.conf
user = www-data
group = www-data
...
listen.owner = www-data
listen.group = www-data
;listen.mode = 0660

To

user = da
group = da
...
listen.owner = da
listen.group = da
listen.mode = 0660

Restart the php-fpm service

sudo service php7.4-fpm restart

Leave a Reply