• Home
  • WordPress
  • web Hosting
  • linux
  • mysql
  • nginx
  • apache2
  • devops

Raju Ginni

wordpress tutorials seo hosting etc

You are here: Home / apache server tutorial (install,config, performance tuning, security, error handling) / Lamp stack install on Ubuntu 20.4 LTS apache, mysql, php 7.4(Debian 9 & Ubuntu 18.04 lts)

Lamp stack install on Ubuntu 20.4 LTS apache, mysql, php 7.4(Debian 9 & Ubuntu 18.04 lts)

Table of Contents

Toggle
    • #1. Update software packages
  • #2 install apache server
    • Domain mapping virtual hosts
    • Install MySQL server
    • Install phpmyadmin on Ubuntu 20.04
  • Configure domain to directory apache vhosts install wordpress on ubuntu 

#1. Update software packages

To update os 20.4
you may wanna upgrade ubuntu 18.04 to 20.04 lts ,#here
sudo apt update  && sudo apt upgrade

#2 install apache server

sudo apt install -y apache2 apache2-utils
check apache2 sever status by this command.
systemctl status apache2
or
service apache2 status
if not running start the server manually
by this command
sudo systemctl start apache2
If unable to starts
check config errors by this command sudo apache2ctl -t
fix restart the server. Remove reinstall server by above command.
It’s a good idea to run this command to enable apache on boot (by default it’s run on boot). But just try this
sudo systemctl enable apache2
check apache 2 version
apache2 -v
Server version: Apache/2.4.41 (Ubuntu)
Now type your server ip address
You will see default index page of apache server.
Incase of blocked
first add exception to firewall
sudo ufw allow http
If ufw not installed,
Just install by this command
sudo apt install ufw (frontend of iptables)
sudo ufw allow http
assign apache server gruop to web directory
to avoid write permissions (, unable install WordPress plugins)
sudo chown www-data:www-data -R /var/www/html/

Domain mapping virtual hosts

sudo nano /etc/apache2/conf-available/servername.conf
servername yourwebsite.com
sudo a2enconf servername.conf && sudo service apache2 reload
Incase any errors.
check detailed information by this command
apache2ctl -t

Install MySQL server

Mariadb or MySQL
(MySQL community version improving much more than mariadb)
MySQL bought by Oracle, but free MySQL version continuing its legacy by name of mariadb contributing open source devolopers.
while MySQL free version by Oracle, along with their premium Oracle software.
sudo apt install mysql-server
follow instructions install 8.2 5.7 based on availability of repository with latest ubuntu 20.04
otherwise you can manually add MySQL 8.24 version repository to improved performance.
set MySQL password.
after installation completes.
systemctl status mysql-server
or
systemctl status mysql
2nd step securing
sudo mysql_secure_installation
set strong password && remove otherusers except root.
 
install php 7.4 through mod php (7.4 latest)
sudo apt install php7.4 libapache2-mod-php7.4 php7.4-
by above command you have installed, php 7 and php module for apache
to enable php_mod use this command
sudo a2enmod php7.4
but other php extensions required to run apache webserver
mysql php extensions
installing php -fpm on apache server
php-mod or php-fpm
(Note: you can only use only one either php_mod or php-fpm mod)
php-fpm has some advantages when you are using apache core module
as mpm-prefork
(threads ready to handle save memory)
Disable apache 7.4 module
sudo a2dismod php7.4
Install php-fpm module
sudo apt install php7.4-fpm
enable php-fpm module
sudo a2enconf php7.4-fpm
or
sudo a2enmod php7.4-fpm
Enable proxy_fcgi and setenvif module.
sudo a2enmod proxy_fcgi setenvif
sudo service  apache2 restart

Install phpmyadmin on Ubuntu 20.04

sudo apt update && sudo apt install phpmyadmin
select webserver as
apache2
create database & user as phpmyadmin
NO.(yes means a database & phpmyadmin user will be created, later you have to grant root permissions to phpmyadmin user).
Accessing phpmyadmin page
example.com/phpmyadmin
Vhost file
/etc/apache2/conf-enabled/phpmyadmin.conf
automatically generated while installing,
Otherwise manually configure it.
accessing phpmyadmin from subdomain or new
just edit the conf file
Add domain
sudo a2ensite phpmyadmin.conf
sudo systemctl reload apache2
Note: same commands works for Debian 9 & ubuntu 18.04 even with ubuntu 16.04.
if you are here for reshat family like CentOS,fedora
just change repository name apt to yum all works fine.

 

migration server apache to nginx

 

navigate to the directory

cd /home/pubclubindia/epf/theonlineking.com

zip -r zipfilename.zip folder name

zip -r king.zip theonlineking.com

backup sql

know the database name by wp-config.php

export

mysql -u root -psqlpass king > /home/pubclubindia/epf/theonlineking.com/a.sql

import command
mysql -u root -psqlpass king < /var/www/html/king.sql

mysql login

mysql -u root -p

mysql -u root -psqlpass

create database king;

Next vhost nnginx

 

grant permissions to server user

chown www-data:www-data -R /var/www/html/

LAMP installation on ubuntu & debian  //Apache

sudo apt install apache2
sudo apt install mysql-server
sudo apt install php-pear php-fpm php-dev php-zip php-curl php-xmlrpc php-gd php-mysql php-mbstring php-xml libapache2-mod-php
sudo service apache2 restart

LAMP install on ubuntu

change apache.conf

apache htaccess allow rewrite

sudo nano /etc/apache2/sites-available/default

Once inside that file, find the following section, and change the line that says AllowOverride from None to All. The section should now look like this:

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

sudo chown -R pubclubindia:pubclubindia /home/user/
rm -rf /home/user/wp-content/cache/object

<Directory /home/user/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>

Configure domain to directory apache vhosts install wordpress on ubuntu 

sudo nano /etc/apache2/sites-available/epfouanloginportal.co.in.conf

sudo chown pubclubindia:pubclubindia /etc/apache2/sites-available/epfouanloginportal.co.in.conf

if root permission not there

past this
<VirtualHost *:80>
ServerAdmin pubclubindia@gmail.com
ServerName eaadharcarddownload.co.in
ServerAlias www.eaadharcarddownload.co.in
DocumentRoot /home/user/eaadharcarddownload.co.in
<Directory /home/user/eaadharcarddownload.co.in/>
Options Indexes FollowSymLinks MultiViews
Options All
AllowOverride All
Require all granted
</Directory>
ErrorLog /home/user/eaadharcarddownload.co.in/error.log
</VirtualHost>

sudo ln -s /etc/apache2/sites-available/aeaadharcarddownload.co.in.conf /etc/apache2/sites-enabled/aeaadharcarddownload.co.in.conf

or you can navbigate to cd /etc/apache2/sites-available/

and run this command sudo ln -s /etc/apache2/sites-available/burnbelly.in.conf

sudo here root level access i am not root user but own apachge directory

apachectl configtest

check for syntax error before restart becuase apache not able to start again.

sudo service apache2 reload

cheeck your website on browser.

apache server tutorial (install,config, performance tuning, security, error handling)

  • what is If-Modified-Since HTTP header how to add to Wordpress website
  • htaccess tutorial tips for wordpress #redirect #leverage browser cache #Gzip #KeepAlive
  • apache modules list (explained, enable disable)
  • connect to server by SSH client Putty SFTP client winscp LAMP, LEMP nginx apache etc linux
  • Lamp stack install on Ubuntu 20.4 LTS apache, mysql, php 7.4(Debian 9 & Ubuntu 18.04 lts)
  • apache performance tuning mpm-worker vs prefork vs event modules
  • enable caching in apache server (mod cache disk cache) vs fastcgi cache
  • how to enable KeepAlive connections in apache nginx wordpress
  • Cache control Header & expires headers How to set Properly
  • apache2 conf sample explained apache configuration file modules etc
  • restart apache in ubuntu (start | stop | reload | config test) centos debian mac linux windows 10 xampp
  • uninstall apache2 ubuntu in 3 steps Debian

hi i am raju ginni, primalry i manage wordpress websites on GCP cloud platform as a cloud engineer, and create content on passionate things.
you can follow me on youtbe

© 2025 - All Rights Reserved Disclaimer & Privacy Policy