Sitemap
Janushanth Sivaratnam

Janushanth Sivaratnam

Expertise in DevOps and IT Support

๐Ÿš€๐”๐ฅ๐ญ๐ข๐ฆ๐š๐ญ๐ž ๐†๐ฎ๐ข๐๐ž: ๐ˆ๐ง๐ฌ๐ญ๐š๐ฅ๐ฅ๐ข๐ง๐  ๐–๐จ๐ซ๐๐๐ซ๐ž๐ฌ๐ฌ ๐จ๐ง ๐”๐›๐ฎ๐ง๐ญ๐ฎ ๐Ÿ๐จ๐ซ ๐๐ž๐ ๐ข๐ง๐ง๐ž๐ซ๐ฌ ๐Ÿ“Œ

5 min readMar 8, 2023

--

Step-by-Step Guide: How to Install WordPress on Ubuntu

WordPress is a popular content management system that powers millions of websites worldwide. If youโ€™re looking to create a website or blog with WordPress, you'll need to install it on a web server first. In this article, we'll show you how to install WordPress on Ubuntu, a popular Linux distribution.

Press enter or click to view image in full size

Before we get started, ensure you have access to a server running Ubuntu and root privileges or sudo access.

Press enter or click to view image in full size
Photo by Gabriel Heinzer on Unsplash

Step 1: Install Apache Web Server

The first step in installing WordPress on Ubuntu is to install the Apache web server. Apache is the most popular web server in the world and can be easily installed using the apt package manager. Open up your terminal and run the following command:

sudo apt update
sudo apt install apache2
Press enter or click to view image in full size

Step 2: Install MySQL Database Server

Press enter or click to view image in full size

WordPress uses a MySQL database to store and manage its content. You can install the MySQL server by running the following command:

sudo apt install mysql-server

During the installation, you will be prompted to set a password for the MySQL root user. Make sure to remember this password as you will need it later.

Get Janushanth Sivaratnamโ€™s stories inย yourย inbox

Join Medium for free to get updates fromย thisย writer.

Letโ€™s now secure our MySQL database engine and disallow remote root login.

$ mysql_secure_installation

The first step will prompt you to change the root password to log in to the database. You can opt to change it or skip it 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.

Step 3: Install PHP

PHP is the scripting language that WordPress is built on. You can install PHP and some of its commonly used extensions by running the following command:

sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-imagick php-intl php-json php-mbstring php-xml php-xmlrpc php-zip

To confirm that PHP is installed, created a info.php file at /var/www/html/ path

nano /var/www/html/info.php

Append the following lines:

<?php
phpinfo();
?>

Save and Exit. Open your browser and append /info.php to the serverโ€™s URL.

https://ip-address/info.php
Press enter or click to view image in full size

Step 4: Create a MySQL Database and User for WordPress

Before we can install WordPress, we need to create a MySQL database and use it. Log in to the MySQL server as the root user:

sudo mysql -u root -p

Enter the password you set for the MySQL root user during installation. Once youโ€™re logged in, create a new database for WordPress:

CREATE DATABASE wordpress;

Next, create a new MySQL user and grant it privileges to access the WordPress database:

CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'your_password_here';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;

Make sure to replace your_password_here with a strong password of your choice.

Press enter or click to view image in full size

Step 5: Download and Install WordPress

Now that we have all the necessary components installed and configured, we can download and install WordPress. Start by navigating to the /var/www/html directory:

cd /var/www/html

Then, download the latest version of WordPress using the wget command:

sudo apt-get install wget
sudo wget https://wordpress.org/latest.tar.gz

Extract the downloaded archive using the tar command:

sudo tar -xzvf latest.tar.gz

Step 6: Configure WordPress

The final step is to configure WordPress. Rename the sample configuration file:

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

Edit the wp-config.php file:

sudo nano wp-config.php

Enter the MySQL database and user details we created earlier:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpressuser');
define('DB_PASSWORD', 'your_password_here');
define('DB_HOST', 'localhost');

Save and close the file.

Step 7: Set file permissions

To ensure WordPress can write files to the server, weโ€™ll set the correct permissions for the Apache web server to write to certain directories:

sudo chown -R www-data: /var/www/html/wordpress/
sudo find /var/www/html/wordpress/ -type d -exec chmod 755 {} \;
sudo find /var/www/html/wordpress/ -type f -exec chmod 644 {} \;
Press enter or click to view image in full size

Step 8: Verity the installed services

Press enter or click to view image in full size
php -v
sudo service mysql status
sudo service apache2 status

Step 9: Finish the Installation

Weโ€™re almost done! Open up your web browser and navigate to your serverโ€™s IP address or domain name. You should see the WordPress installation

https://ip-address/wordpress

Open your browser and append /wordpress to the serverโ€™s URL.

Press enter or click to view image in full size

Choose the language of your choice.

Press enter or click to view image in full size

Enter the installation detailsโ€ฆ

Press enter or click to view image in full size

When you complete the installation, it will request your WordPress login and password.

Press enter or click to view image in full size

Conclusion

The WordPress dashboard is now gone, ready for you to start your own blog or website! Thank you for making it this far. You can now move on to learning more about the many features, plugins, and themes and start creating your first blog or website! ๐Ÿ‘ˆ

--

--

Written by Janushanth Sivaratnam

Expertise in DevOps and IT Support