How to Install WordPress on Ubuntu 22.04 using LAMP

How to Install WordPress on Ubuntu 22.04 using LAMP. In this guide, we introduce WordPress, its advantages then explain how to install WordPress using LAMP on Ubuntu 22.04.

What is WordPress?

Well, WordPress is a free, open source content management system (CMS) that is used for managing and publishing digital content. Easy to use and install as well as customizable to suit different types of websites.

To be accurate, more than one third of the world’s websites are designed on the platform because it is easy to use and install. Also, the site builder and content management system offer various features that allow users to work at any level without any expertise in code or programming.

The software was originally written in PHP, but it has since been rewritten in JavaScript so it can be included in browsers outside of a web server environment.

Accordingly, WordPress is no more just a blogging platform but has now become a fully featured, open source content management system (CMS) that’s easy to use and available for free.

Advantages of WordPress

After all, WordPress is a popular CMS that is used for a variety of websites. WordPress provides a user friendly interface, which makes it easier for users to create and manage their sites without any coding knowledge.

Below, we have listed some of its main benefits that explains benefits of WordPress.

1. Easy to Use and Install

Altogether, WordPress is 100% free, quick to download, and easy to install. The installation process is fast and the best part is you do not require any technical expertise to run the process. You must have a domain name as well as a web hosting account. Basically, WordPress is downloaded directly from or installed for free with the help of your WordPress hosting provider.

Once installed, you access all the features and customize the site from the admin dashboard. Add a theme and start creating dynamic pages and informative posts with a few clicks.

2. No HTML Editing or FTP Software is Necessary

Besides, WordPress is an independent CMS, i.e., you do not require HTML editing software like Dreamweaver or Adobe Contribute to create blog sections or manage image galleries. Users easily upload images/documents, format text, upload video files, create blog posts, etc., without adding any HTML or FTP software.

3. Fast, Simple, and Customizable

Most people believe designing or building a website involves a lot of coding work. But, there are many platforms like WordPress in which the majority of that design work has already been completed. Users easily create blogs with a single click or choose from different theme options available on the platform.

Further, it is fully customizable, i.e., you can change the look and feel of your website as per your requirement and deliver a unique experience to your audience.

4. Offers Built in Blog Feature

There are several features that make posting or publishing content a simple process. The supported features also allow customers to add a blog to their website without having to start one from scratch. It is then accessed from any device, at any time. Even if you do not have regular content for your website, you can use the built in feature for posting updates or making announcements.

It’s also quite easy to set up RSS/email subscriptions, and commenting features, and automatically show up the latest blog entries on other pages of the site. All these help to increase the audience for your business and make your website more dynamic and interactive.

5. Easy to Install Plugins

In WordPress, developers find all elements necessary to build a basic website. But sometimes developers require special functionalities to design a site as per the user’s requirement. The WordPress plugin directory offers various plugins to improve the look and appearance of the website as well as SEO. The plugins are tiny pieces of code created to carry out certain functions.

Using these plugins, developers add various features shopping carts, galleries, contact forms, etc., to a website and perform specific tasks. You can find both free and paid plugins in WordPress.

Up next with how to Install WordPress on Ubuntu 22.04 using LAMP we move onto installation phase. 

How to Install WordPress on Ubuntu 22.04 using LAMP

In this section, we aim to show you how to install WordPress on Ubuntu 22.04 using LAMP. We will also show you how to secure WordPress with Let’s Encrypt SSL.


  • An Ubuntu 22.04 server installed on your server.
  • Valid domain name is pointed to your server IP.
  • A root user or a user with sudo privileges.

Step 1 - Update the System

First, it is always a good idea to update and upgrade all system packages to the latest version. You run following commands to update all packages.

					apt update -y
apt upgrade -y

After updating all system packages, you can proceed to install the LAMP server.

Step 2 - Install LAMP Server

LAMP stands for Linux, Apache, MariaDB and PHP. You can install all these components using the following command.

					apt install apache2 mariadb-server php php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap libapache2-mod-php php-mysql -y

After installing the LAMP server, start and enable the Apache service using the following command.

					systemctl start apache2
systemctl enable apache2


At this point, the LAMP server is installed on your server. You can now proceed to create a database for WordPress.

Step 3 - Create WordPress Database

WordPress uses a MariaDB as a database backend to store their content. First, secure the MariaDB installation and set a root password using the following command.


Answer all the questions as shown below to secure the MariaDB installation.

					Enter current password for root (enter for none): Press ENTER
Set root password? [Y/n]: Y
New password: Set-your-new-password
Re-enter new password: Set-your-new-password
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Next, log in to the MariaDB shell using the following command:

					mysql -u root -p

After log in, create a wordpress database and user with the following command.

					CREATE DATABASE wordpress;
CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'yourpassword';

Next, grant all the privileges to the wordpress database with the following command.

					GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost';

Then, flush the privileges and exit from the MariaDB shell with the following command.



Step 4 - Downlaod WordPress

Now, change your directory to the Apache website directory and download the latest version of WordPress with the following command.

					cd /var/www/html

Once the WordPress is downloaded, extract the downloaded file with the following command.

					tar -xvzf latest.tar.gz

Next, change the directory to the WordPress directory and rename the default configuration file.

					cd wordpress
mv wp-config-sample.php wp-config.php


Then, edit the WordPress configuration file and define your database settings.

					nano wp-config.php

Change the following lines:

					define( 'DB_NAME', 'wordpress' );

/** Database username */
define( 'DB_USER', 'wordpress' );

/** Database password */
define( 'DB_PASSWORD', 'yourpassword' );

/** Database hostname */
define( 'DB_HOST', 'localhost' );


Save and close the file then change the ownership and permission of the WordPress directory.

					chown -R www-data:www-data /var/www/html/wordpress
chmod -R 775 /var/www/html/wordpress

Step 5 - Create Apache Virtual Host for WordPress

Next, you need to create an Apache virtual host configuration file for WordPress. You can create it with the following command.

					nano /etc/apache2/sites-available/wordpress.conf

Add the following lines:

					<VirtualHost *:80>

DocumentRoot /var/www/html/wordpress
<Directory /var/www/html/wordpress/>
Options FollowSymLinks
AllowOverride All
Require all granted

ErrorLog ${APACHE_LOG_DIR}/yourdomain_error.log
CustomLog ${APACHE_LOG_DIR}/yourdomain_access.log combined


Save the file then activate the Apache virtual host and rewrite module using the following command.

					a2ensite wordpress.conf
a2enmod rewrite

Next, restart the Apache service to apply the configuration changes.

					systemctl restart apache2

To check the Apache service status, run the following command.

					systemctl status apache2

You will get the following output.

					● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-12-24 14:35:38 UTC; 2s ago
    Process: 53484 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 53488 (apache2)
      Tasks: 6 (limit: 1030)
     Memory: 15.1M
        CPU: 37ms
     CGroup: /system.slice/apache2.service
             ├─53488 /usr/sbin/apache2 -k start
             ├─53489 /usr/sbin/apache2 -k start
             ├─53490 /usr/sbin/apache2 -k start
             ├─53491 /usr/sbin/apache2 -k start
             ├─53492 /usr/sbin/apache2 -k start
             └─53493 /usr/sbin/apache2 -k start

Dec 24 14:35:38 ubuntu2204 systemd[1]: apache2.service: Deactivated successfully.
Dec 24 14:35:38 ubuntu2204 systemd[1]: Stopped The Apache HTTP Server.
Dec 24 14:35:38 ubuntu2204 systemd[1]: Starting The Apache HTTP Server...


Step 6 - Install Let's Encrypt SSL on WordPress

To install the Let’s Encrypt SSL, you will need to install the Certbot client on your server. You install it with the following command.

					apt install python3-certbot-apache -y

Once the Certbot is installed, run the following command to secure your website with Let’s Encrypt SSL:

					certbot --apache -d

You will be asked to provide your email and accept the term of service as shown below:

					Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at You must
agree in order to register with the ACME server at
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/wordpress-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/wordpress-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/wordpress-le-ssl.conf
Next, select whether or not to redirect HTTP traffic to HTTPS as shown below:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2


Type 2 and hit Enter to install the Let’s Encrypt SSL for your website:

					Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/wordpress.conf to ssl vhost in /etc/apache2/sites-available/wordpress-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled

You should test your configuration at:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

 - Congratulations! Your certificate and chain have been saved at:
   Your key file has been saved at:
   Your cert will expire on 2023-02-29. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:
   Donating to EFF:          


Step 7 - Perform WordPress Web based Installation

Now, open your web browser and perform the WordPress web installation using the URL You should see the WordPress language selection screen.

Select your language and click on the Continue. You should see the site configuration screen.

Define your website name, admin username, password and click on the Install WordPress. You should see the following screen.

Click on the Log in button. You should see the WordPress login screen.

Provide your admin username, password and click on the Log in button. You should see the WordPress dashboard on the following screen.

Thank you for reading How to Install WordPress on Ubuntu 22.04 using LAMP. We shall conclude the article. 

Install WordPress SAML SSO( Single Sign On) Security Plugin

Use WP Cloud SSO, a WordPress hardening tool, that limits login attempts to your WordPress site.

How to Install WordPress on Ubuntu 22.04 using LAMP Conclusion

In this post, we showed you how to install WordPress using LAMP server and secure it with Let’s Encrypt SSL on Ubuntu 22.04. WordPress can do more than just publish content. Today, organizations run complex sites via WordPress. You can run podcasts, and eCommerce stores as well as display portfolios via WordPress sites.

Additionally, they have an active online community that answers all your technical queries and helps resolve issues in real time with proper discussion and explanation. Follow the above listed benefits to learn more about WordPress.

Navigate to this section of the blog to read more WordPress content. 

Avatar for Hitesh Jethva
Hitesh Jethva

I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.

3.5 8 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x