How to Install Wordpress on Ubuntu using CCE
Installing WordPress on Ubuntu 22.04 LTS Linux involves several steps. You’ll need to set up a LAMP (Linux, Apache, MySQL, PHP) stack, configure your server, and then install WordPress.
First of all, You need to create an Ubuntu VM using the information on Create a Virtual Machine page.
Create a Virtual Machine
1- On the Virtual Machines page, click the "Create A Virtual Machine" button.
2- Write "wordpress-test" input in name field.
3- Choose, "Choose an Image" deployment option.
4- Click the "Choose an Image" button and select "Ubuntu 22.04-Cloudimage".
5- On the Volume section click the edit icon in the boot volume pane and increase volume to 30gb.
6- Click "Choose a Virtual Machine Type" button and select "m.small" type.
7- Click "Choose a Network" button. On the "Add network interface" page, select "VM_PUBLIC_2" option and then click the "Add Network" button.
8- Select the "SSH Key" authentication method and click "Select existing SSH Key" button. And then select the existing SSH key.
9- Click "Create A Virtual Machine"
Install WordPress on Ubuntu
After creating a virtual machine, we followed these steps to install WordPress on the Ubuntu;
Update Your Server:
Firstly access the Ubuntu system.
- Open the PowerShell and connect to the machine by entering the command below
ssh ubuntu@ip-adress
- The IP address appears on the "Virtual Machines" page after your virtual machine is created.
After accessing the system, run the system update command to ensure all the packages on our system are up to date and also the APT package index cache is in its latest state.
sudo apt update && sudo apt upgrade
Install the LAMP
Next, we are going to install the LAMP stack for WordPress to function. LAMP is short for Linux Apache MySQL and PHP.
Install Apache
Let’s jump right in and install Apache first. To do this, execute the following command.
sudo apt install apache2
To confirm that Apache is installed on your system, execute the following command.
systemctl status apache2
If the apache service status is active, running, open your browser and go to your server’s IP address.
https://ip-address
Install MySQL
Next, we are going to install the MariaDB database engine to hold our Wordpress files. MariaDB is an open-source fork of MySQL and most of the hosting companies use it instead of MySQL.
sudo apt install mariadb-server mariadb-client
Let’s now secure our MariaDB database engine and disallow remote root login.
sudo mysql_secure_installation
-
The first step will prompt you to change the root password to login to the database. You can opt to change it or skip if you are convinced that you have a strong password. To skip changing type n.
-
For safety’s sake, you will be prompted to remove anonymous users. Type Y.
-
Next, disallow remote root login to prevent hackers from accessing your database. However, for testing purposes, you may want to allow log in remotely if you are configuring a virtual server
-
Next, remove the test database.
-
Finally, reload the database to effect the changes.
Install PHP
Lastly, we will install PHP as the last component of the LAMP stack.
sudo apt install php php-mysql
To confirm that PHP is installed , created a info.php
file at /var/www/html/
path
cd /var/www/html/
Then,
sudo touch info.php
Then,
sudo nano info.php
Then, append the following lines in info.php
:
<?php
phpinfo();
?>
Save and Exit. Open your browser and append /info.php
to the server’s URL.
https://ip-address/info.php
Can see the PHP page.
Create WordPress Database
Now it’s time to log in to our MariaDB database as root and create a database for accommodating our WordPress data.
sudo mysql -u root -p
Create a database for our WordPress installation.
CREATE DATABASE wordpress_db;
Next, create a database user for our WordPress setup.
CREATE USER 'dtcloud_user'@'localhost' IDENTIFIED BY 'password';
Grant privileges to the user Next, grant the user permissions to access the database
GRANT ALL ON wordpress_db.* TO 'dtcloud_user'@'localhost' IDENTIFIED BY 'password';
Great, now you can exit the database.
FLUSH PRIVILEGES;
Exit;
Install WordPress CMS
Go to your temp directory and download the latest WordPress File
cd /tmp && wget https://wordpress.org/latest.tar.gz
Next, Uncompress the tarball which will generate a folder called “wordpress”.
tar -xvf latest.tar.gz
Copy the wordpress folder to /var/www/html/
path.
sudo cp -R wordpress /var/www/html/
Run the command below to change ownership of ‘wordpress’ directory.
sudo chown -R www-data:www-data /var/www/html/wordpress/
Change File permissions of the WordPress folder.
sudo chmod -R 755 /var/www/html/wordpress/
Create ‘uploads’ directory.
sudo mkdir /var/www/html/wordpress/wp-content/uploads
Finally, change permissions of ‘uploads’ directory.
sudo chown -R www-data:www-data /var/www/html/wordpress/wp-content/uploads/
Open your browser and go to the server’s URL. In my case it’s
https://server-ip/wordpress
WordPress Configuration
You’ll be presented with a WordPress wizard and a list of credentials required to successfully set it up.
- Fill out the form as shown with the credentials specified when creating the WordPress database in the MariaDB database. Leave out the database host and table prefix and Hit ‘Submit’ button.
Database Name: wordpress_db
Username: dtcloud_user
Password: password
Database Host: localhost
Table Prefix: wp_
If all the details are correct, you will be given the green light to proceed. Run the installation.
- Fill out the additional details required such as site title, Username, and Password and save them somewhere safe lest you forget. Ensure to use a strong password.
Site Title: DTCloudX-WordPress
Username: dtcloudx
Password: Password1.
Your Email: wordpress@dtcloudx.com
Scroll down and Hit ‘Install WordPress’. If all went well, then you will get a ‘Success’ notification as shown.
Click on the ‘Login’ button to get to access the Login page of your fresh WordPress installation.
And, there goes the WordPress dashboard that you can use to create your first blog or website! Congratulations for having come this far. You can now proceed to discover the various features, plugins, and themes and proceed setting up your first blog/website!