paint-brush
How to Install WordPress on Linux Server: A Step by Step Guideby@durojayeolusegun
15,362 reads
15,362 reads

How to Install WordPress on Linux Server: A Step by Step Guide

by OLUSEGUN DUROJAYEDecember 5th, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Whether you're a seasoned Linux user or a beginner navigating the server landscape, these comprehensive and well-structured instructions will ensure you have WordPress installed and ready for customization in no time.
featured image - How to Install WordPress on Linux Server: A Step by Step Guide
OLUSEGUN DUROJAYE HackerNoon profile picture

WordPress is the world’s most popular software that allows you to create a website. If you're looking to establish a robust and dynamic website, WordPress stands out as one of the most popular and user-friendly content management systems available.


Fortunately, installing WordPress on a Linux server is a straightforward process that doesn't require a computer science degree. In this guide, you’ll learn the essential steps to get WordPress up and running on your Linux environment, empowering you to take control of your online presence without unnecessary complications.


Whether you're a seasoned Linux user or a beginner navigating the server landscape, these comprehensive and well-structured instructions will ensure you have WordPress installed and ready for customization in no time.

Prerequisites

Before proceeding with the installation of WordPress, it is important to have the following in place:


  • Basic understanding of Linux command
  • A Linux system with admin privilege
  • Steady internet connection


By ensuring these prerequisites are met, you'll set the stage for a seamless WordPress installation on your Linux server. Now, proceed to the step-by-step guide to bring your WordPress site to life.

Steps Taken to Install and Set Up WordPress on Linux Server

Before you dive into the installation process of WordPress on your Linux server, it's crucial to follow a systematic approach. The following steps outline a streamlined procedure to ensure a successful setup.

1. Perform Linux Updates

It is important to ensure your Linux server is up to date. This not only provides the latest features and security patches but also ensures compatibility with the software components you’ll be installing.

sudo apt update && sudo apt upgrade -y 

This command ensures all the packages on our system are up to date.

2. Install Apache for WordPress

It is necessary to set up a web server that will host your WordPress site. Apache is a widely used and reliable choice.

sudo apt install apache2 


This command installs Apache on your Linux server. Apache will serve as the engine behind your WordPress site, handling incoming web requests.


Once Apache installation is complete, enable and start its service. Use the below command to do so.

sudo systemctl enable apache2


Output:

Start the Apache server with this command.

sudo systemctl start apache2


Afterward, you can check the status of the Apache server running on your system with the command.

Systemctl status apache2


Output:

This shows that the server is active and running successfully. To check further, visit your local IP address on your browser. That is:

http://server-ip-address

Note: server-IP-address is your actual local host IP address.

3. Install MariaDB for WordPress

You can use any database of your choice (MySQL or PostGRES). For this guide, we’ll be using MariaDB which helps to store data generated by the WordPress CMS(Content Management System).


sudo apt install mariadb-server mariadb-client


This command installs MariaDB on your Linux server, providing the backend storage for your WordPress site. MariaDB is known for its performance and reliability, making it an excellent choice for powering dynamic websites. With the database in place, your WordPress installation is poised for the next stages of setup.


Once the mariaDB database server is successfully installed, enable the mariaDB.

sudo systemctl enable --now mariadb


You can check if it is active by running this command.

systemctl status mariadDB


Output:

Note: If it is not Active, run sudo systemctl start mariaDB to start the MariaDB database server.

It is crucial to enable security within your installed database. Run this command to initiate the MySQL Secure Installation wizard.

sudo mysql_secure_installation


This command will prompt you to configure several security options, including setting a root password, removing anonymous users, and disabling remote root login. Follow the on-screen instructions to tighten the security of your MariaDB installation, ensuring a robust foundation for your WordPress database.


After completing this step, your server will be better protected against potential security threats.


Output:

4. Install PHP for WordPress

To empower your server to interpret and execute PHP code, essential for WordPress functionality, you’ll install PHP along with some necessary extensions.

sudo apt install -y php php-common php-mysql php-xml php-xmlrpc php-curl php-gd php-imagick php-cli php-dev php-imap php-mbstring php-soap php-zip php-intl


This command installs PHP along with essential extensions, ensuring your server is equipped to handle WordPress's dynamic content. PHP serves as the backbone of WordPress, enabling the execution of scripts and the seamless functioning of your website. With PHP successfully installed, your Linux server is now ready to support the WordPress platform.


You can check the version of PHP installed by running this command

php --version

5. Install WordPress for Linux

Installing WordPress on Linux is a seamless and straightforward process. Follow these commands accordingly to install, and set up WordPress without encountering errors.

sudo apt install wget unzip


This command installs the necessary tools needed to install WordPress successfully on your Linux server.


Download the latest version of WordPress with this command.

wget https://wordpress.org/latest.zip


This command fetches the latest version of WordPress from the official WordPress site. Extract the WordPress archive with the next command.

sudo unzip latest.zip


This unzips the downloaded file to access the WordPress files for installation.


Navigate to the WordPress directory to start the WordPress setup.

cd wordpress


Copy the WordPress files to the Web Server Directory.

sudo cp -r * /var/www/html


This transfers the extracted WordPress files to your web server's designated directory.


Next, navigate to the directory.

cd /var/www/html


Remove the default index file present.

sudo rm -rf index.html


Install additional PHP modules.

sudo apt install php-mysql php-cgi php-cli php-gd -y 


This installed additional PHP modules ensures your server has the necessary PHP module to support WordPress.


Now, restart the Apache to apply the changes.

sudo systemctl restart apache2


This activates the changes made to the server configuration by restarting the Apache service.


Set the appropriate ownership for the Apache server

sudo chown -R www-data:www-data /var/www/


This command adjusts the ownership of the WordPress files to ensure proper permissions for the web server.


Following these commands diligently ensures a seamless installation of WordPress on your Linux server. With the web server configured and the WordPress files in place, your site is ready for the next steps in the setup process.

6. Create a Database for WordPress

You need to seamlessly establish a database for your WordPress installation on your Linux server.

Login to your database server with this command.

sudo mysql -u root -p


Remember to use your root password created earlier in step 3 to gain access to the database management system.


Establish a dedicated database to store all the content and settings for your WordPress site.

create database new_DB;


Generate a user account linked to the 'new_DB' database, allowing WordPress to interact with it.

CREATE USER 'new_user'@'%' IDENTIFIED BY 'your_password';


Authorize the user to have complete control over the 'new_DB' database, ensuring seamless functionality.

GRANT ALL PRIVILEGES ON new_DB.* TO 'new_user'@'%';


Replace new_user with whatever you want to be the username of your database, also replace new_DB with what you want to name your database and your_password with the password you want to assign to your database.


Output:

Executing these commands ensures the creation of a dedicated database and user for your WordPress site. With the database configured, your Linux server is now ready for the next steps in the WordPress setup process.

7. WordPress CMS Web Interface Setup

After following the above steps successfully, you’re now set to set up the WordPress site. Open your browser to access the WordPress site. Visit the endpoint on your browser.

http://your-server-ip-address/wp-admin/setup-config.php


Replace your-server-ip-address with the IP address of your Linux server.

Select your language of choice and hit the Continue button to proceed.

8. Add Database Information to WordPress

This is where you will put your database information. Click on Let’s Go at the bottom which will create a wp-config file to store the database details.

This will redirect you to the WordPress setup wizard. Provide all the necessary credentials you have created earlier. Click on the submit button.

Finally, click on Run the Installation.

9. Create Admin User and Password

Add the site title of your choice and then add a username and password alongside to use the site efficiently.

Hit the Install WordPress button.


Finally, use the admin credentials you created to login to the backend.


Conclusion

Installing WordPress on your Linux server is a straightforward process that empowers you to establish a dynamic and robust website. This step-by-step guide provides a comprehensive and accessible approach, catering to both seasoned Linux users and beginners navigating the server landscape.


By adhering to the outlined prerequisites and following each command meticulously, you ensure a seamless WordPress installation.


With your web server configured, database in place, and WordPress files set up, you're now ready to embark on the journey of customization and content creation, taking full control of your online presence.