There are several ways to install and configure complete production server using Ubuntu I have figure out one of them which is easy to me. So I don’t want to talk more just want to jump to the steps of installation.
I need comments to improve this document if you think this is helpful to you.
Install MariaDB/MySQL database server
We can easily install mariadb by running the commands below:
sudo apt-get update
sudo apt-get install mariadb-server mariadb-client
Lets secure our server
sudo mysql_secure_installation

INSTALL APACHE2
sudo apt-get install apache2
CONFIGURE APACHE2
Next, run the commands below to configure Apache2 basic settings. These are the basics.. and more advanced configurations can be done later.
sudo nano /etc/apache2/conf-enabled/security.conf
Change your Apache2 server token to Prod
# Set to one of: Full | OS | Minimal | Minor | Major | Prod
# where Full conveys the most information, and Prod the least.
#ServerTokens Minimal
ServerTokens Prod
#ServerTokens Full
Change the highlighted line below and save the file.
Next, configure the default DirectoryIndex directives.
sudo nano /etc/apache2/mods-enabled/dir.conf
<IfModule mod_dir.c>
DirectoryIndex index.html index.php index.htm
</IfModule>
Then change the highlighted line below and save.
Virtual Hosting
Lets configure virtual host to accept multiple domain in a single server.
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.test.conf
Edit the configuration file you have just copied
sudo nano /etc/apache2/sites-available/example.test.conf
Change the highlighted lines and save the file.
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/example/public
ServerName example.test
ServerAlias www.example.test
#configuration for laravel
<Directory /var/www/html/example/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the newly created configuration
sudo a2ensite example.test.conf
Now restart Apache2
sudo service apache2 restart
INSTALL PHP 7.4

sudo apt-get install php7.4 php7.4-cgi libapache2-mod-php7.4 php7.4-common php-pear php7.4-mbstring php7.4-gd php-zip
CONFIGURE APACHE2 TO USE PHP
After install PHP and other related scripts, run the commands below to enable Apache2 to use PHP.
sudo a2enconf php7.4-cgi
Enable rewrite module for laravel url support
sudo a2enmod rewrite
Now restart Apache2
sudo service apache2 restart
Add domain to host file
sudo nano /etc/hosts
Add one line
127.0.0.1 example.test
Sir, please add the configuration of apache2 envvars file. it took me 2 days to find the problem.
Thanks for your comment.