Table of Contents
Introduction
There are currently several content management systems (CMSs) available, such as WordPress, which enable users to put up blogs in addition to whole websites with just a few clicks of the mouse. These CMSs are beneficial for those who do not have the financial means or time to construct websites from scratch.
WordPress is a robust content management system (CMS) used by millions of people around the world to power their blogs and fully functional websites. It is free, open-source, and extensible.
Installing it and learning how to use it is not difficult at all, and this is particularly true for those who have no previous experience with the creation and construction of websites. You can customize the functionality and appearance of your website or blog exactly as you want it to be thanks to the availability of millions of plugins and themes that were produced by an active and committed community of other users and developers. These plugins and themes may be downloaded from the WordPress plugin repository.
Requirements:
In this tutorial, we are going to walk you through the process of installing the most recent version of WordPress on Ubuntu 22.04 all the way down to Ubuntu 16.04 using the LAMP (Linux, Apache, MySQL, and PHP) stack.
I’m currently setting it up on an LXC container with Ubuntu 20.04 as a template.
You may install WordPress by following the instructions below.
Set up the LAMP stack on your Ubuntu server.
Before moving on to install WordPress, we kind of need to install the whole framework on which it will run, right?
Step 1: Set up Apache on Ubuntu
First, update and upgrade the software package list and then install the Apache webserver using the following commands.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apache2 apache2-utils
The Apache2 web server must be set up to automatically start with the OS at startup. Following these commands, we need to start the service and verify its status:
sudo systemctl enable apache2
sudo systemctl start apache2
sudo systemctl status apache2
After you have started Apache, you will need to make the necessary changes on your UFW firewall in order to enable traffic through HTTP as shown below.
sudo ufw allow in "Apache"
sudo ufw status
Launch your web browser, and with it open, type the following URL into the address bar to determine whether the Apache server is active:
http://server_address
or
http://your-domain.com
If the webserver is up and functioning properly, the default index page for Apache2 will be shown.
Note: The /var/www/html directory serves as the root directory for Apache by default; all of your website files will be placed in this location.
Step 2: Perform the installation of the MySQL Database Server.
In the next step, we will install the MySQL database server by executing the following command:
sudo apt-get install mysql-client mysql-server
In the event that you would want to install MariaDB, you may do so by using the following command.
sudo apt-get install mariadb-server mariadb-client
After the database server has been installed, it is highly recommended that you execute the security script to get rid of unsafe default settings and to safeguard your database system.
sudo mysql_secure_installation
you will be given the option to change the default password
Hit the Y key, and then immediately after that, press the ENTER key for each of the following questions.
Step 3: Install PHP on Ubuntu
Lastly, we will use the command below to install PHP and a few modules in order for it to function properly with the web and database servers:
sudo apt-get install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
You must restart Apache in order for the newly installed extensions to take effect once PHP and all essential extensions have been installed.
sudo systemctl restart apache2
In order to see whether PHP is functioning with the web server, a file named info.php must be created in /var/www/html.
sudo nano /var/www/html/info.php
And then just save the file when you’ve added the code below to it and close the window.
After you have completed that step, open your browser and go to the following URL using the address bar.
http://server_address/info.php
or
http://your-domain.com/info.php
As a confirmation, you should be able to see the php info page below.
Step 4: WordPress installation on Ubuntu
Download the most up-to-date version of the package for WordPress and extract it using the instructions below:
wget -c http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
next transfer the WordPress files to the Apache default root location, /var/www/html:
sudo mv wordpress/* /var/www/html/
Set the right permissions on the website’s directory, i.e., grant the webserver ownership of the WordPress files.
sudo chown -R www-data:www-data /var/www/html/
sudo chmod -R 755 /var/www/html/
Step 5: Create a Database for WordPress
Execute the following command and enter the root password, finally press Enter to access the mysql shell:
sudo mysql -u root -p
At the mysql prompt, enter the following commands, hitting Enter after each mysql command line. Remember to provide your own valid settings for database name, database user, and databaseuser password:
(DO NOT FORGET THE ; )
mysql> CREATE DATABASE wp_pcplanet;
mysql> CREATE USER pcplanet@localhost IDENTIFIED BY 'password';
mysql> GRANT ALL ON wp_pcplanet.* TO 'username'@'%';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
Rename the existing file to file in the /var/www/html/ directory. Additionally, delete the default Apache page.
cd /var/www/html/
sudo mv wp-config-sample.php wp-config.php
sudo rm -rf index.html
Then you should modify it so that it contains the information about your database in the MySQL options menu (refer to the boxes that are indicated in the figure below):
After that, be sure to restart the web server in addition to the mysql service by using the following commands:
sudo systemctl restart apache2.service
sudo systemctl restart mysql.service
First, launch your web browser, and then input your domain name or server address in the spaces provided.
http://server_address/info.php
or
http://your-domain.com/info.php
The following welcome page will appear for you to go through. After reading over the page, choose the “Let’s go!” button to continue, and then fill out all of the information that is needed on the screen.
Honestly, this was a lot of work for a simple task – check out this guide for our preferred way of setting apache up!