How To Install WordPress with LAMP on Ubuntu 22.04 - TechvBlogs

How To Install WordPress with LAMP on Ubuntu 22.04

In this article, we will guide you through installing a WordPress site with the LAMP stack on Ubuntu 22.04.


Smit Pipaliya - Author - TechvBlogs
Smit Pipaliya
 

1 year ago

TechvBlogs - Google News

For those who cannot afford the hustles of developing websites from scratch, there are now several content management systems (CMSs) such as WordPress that you can take advantage of to set up blogs and complete websites with a few clicks.

WordPress is one of the world’s most popular, if not the world’s most popular content management system (CMS). It is a free and open-source platform built entirely in PHP – it’s used by millions of people for running blogs, business websites, e-commerce stores, and much more. With features such as in-depth theming, thousands of plug-ins, and a huge community, WordPress is probably the most user-friendly CMS you can choose for building your website.

It is easy to install and learn, especially for persons who do not have prior website design and development knowledge. With millions of plugins and themes available, developed by an active and dedicated community of fellow users and developers, you can utilize them to tailor your blog or website to work and look just the way you want.

This blog will show you how to get your site hosted with WordPress on Ubuntu Linux. We’ll use Apache as our HTTP server and install PHP and MySQL since WordPress requires them to function. This assortment of packages is commonly referred to as a LAMP stack (Linux, Apache, MySQL, PHP). Once those packages are installed, we’ll go over the configuration of Apache and MySQL, including the initial setup of a database and user, before installing WordPress itself.

Prerequisites

  • The operating system running Ubuntu 22.04 LTS
  • A root or non-root user with Sudo privileges
  • Has stable internet connection
  • Terminal window / Command line

1. Install Apache On Ubuntu

If you have installed Apache, you can skip this. If you have not installed Apache, then just follow this article How to Install Apache on Ubuntu 22.04 LTS

2. Install And Configure MySQL On Ubuntu

If you have installed MySQL, you can skip this. If you have not installed MySQL, then just follow this article How to Install MySQL on Ubuntu 22.04

3. Install PHP 8 On Ubuntu

If you have installed PHP 8.1, you can skip this. If you have not installed PHP 8.1, then just follow this article How To Install PHP 8.1 on Ubuntu 22.04

4. Install WordPress On Ubuntu

Download the latest version of the WordPress package and extract it by issuing the commands below on the terminal:

#! /bin/bash
sudo wget -c http://wordpress.org/latest.tar.gz
sudo tar -xzvf latest.tar.gz

Then move the WordPress files from the extracted folder to the Apache default root directory, /var/www/html/:

#! /bin/bash
sudo mv wordpress/* /var/www/html

Now set appropriate permissions on the website (/var/www/html) directory. It should be owned by the Apache2 user and group called www-data.

#! /bin/bash
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 775 /var/www/html

Checkout This Tool: Open Port Check Tool

5. Create WordPress Database On MySQL

Execute the command below and provide the root user password, then hit Enter to move to the MySQL shell:

#! /bin/bash
sudo mysql -u root -p

At the MySQL shell, type the following commands, pressing Enter after each MySQL command line. Remember to use your own, valid values for database namedatabase user, and also use a secure and robust password as database user password:

#! /bin/bash
mysql> CREATE DATABASE wp_dbname;
mysql> CREATE USER 'db_username'@'%' IDENTIFIED WITH mysql_native_password BY 'db_password';
mysql> GRANT ALL ON wp_dbname.* TO 'db_username'@'%';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;

How To Install WordPress with LAMP on Ubuntu 22.04 - Techvblogs

Next, move into your website’s document root and create a wp-config.php file from the sample configuration file provided as shown.

#! /bin/bash
cd /var/www/html
sudo mv wp-config-sample.php wp-config.php

Then open the wp-config.php configuration file for editing.

#! /bin/bash
sudo nano wp-config.php

How To Install WordPress with LAMP on Ubuntu 22.04 - Techvblogs 

After updating your wp-config.php file, press CTRL+XY, and Enter key to save the wp-config.php file.

Afterward, restart the webserver and MySQL service, Run the following command:

#! /bin/bash
sudo systemctl restart apache2.service
sudo systemctl restart mysql.service 

6. Completing the WordPress Installation Via Web

Open your web browser, then enter your domain name or server address as shown.

http://server_address
OR
http://your-domain.com

Once the WordPress web installer loads, pick the language you wish to use for installation and click Continue.

How To Install WordPress with LAMP on Ubuntu 22.04 - Techvblogs

Next, set your site’s title, administrative username, password, and email to manage your site content. Then click Install WordPress.

How To Install WordPress with LAMP on Ubuntu 22.04 - Techvblogs

Once the WordPress installation is complete, click on Log in to access your site’s administrative login page.

How To Install WordPress with LAMP on Ubuntu 22.04 - Techvblogs

Now log into your new WordPress website using your administrative credentials (username and password created above) and start to customize your site from Dashboard.

How To Install WordPress with LAMP on Ubuntu 22.04 - Techvblogs

Note that to get back to the WordPress admin panel in the future, you can always use the URL http://yoursite.com/wp-admin.

How To Install WordPress with LAMP on Ubuntu 22.04 - Techvblogs

Your WordPress site should now be accessible from http://yoursite.com.

How To Install WordPress with LAMP on Ubuntu 22.04 - Techvblogs

Thank you for reading this blog.

Read Also: How to Implement Multiple Authentication Guards in Laravel 9

If you want to manage your VPS / VM Server without touching the command line go and  Checkout this linkServerAvatar allows you to quickly set up WordPress or Custom PHP websites on VPS / VM in a  matter of minutes.  You can host multiple websites on a single VPS / VM, configure SSL certificates, and monitor the health of your server without ever touching the command line interface.

Comments (1)

OliveBand OliveBand 11 months ago

Hi, Thank you for the detailed steps. However, after I install WP, my localhost still shows the Apache landing page. Any tips on what I might be missing?

Thanks in advance, AA

Comment


Note: All Input Fields are required.