
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Install WordPress with Apache on Ubuntu
WordPress is the leading content management system in the world. It's free, open source, and easy to use. It is based on the popular backend language PHP. According to statistics, WordPress powers almost 60% of web applications worldwide. This is because it offers many features and capabilities that every website owner needs.
Let's understand why WordPress is popular ?
- Usage ? WordPress is easy to set up and use. Even a person without an IT background can set up and use WordPress effectively. It comes with a simple interface to manage content, pages, and users.
- Free and Open Source ? Cost may be the most critical criterion when people choose between products. WordPress is free and can be used by anyone without paying anything. This allows many newly established websites to choose WordPress, as it provides all essential features at no cost.
- SEO-Friendly ? One of the most essential aspects of working on a website is making it SEO-friendly to gain traffic from Google, often referred to as organic traffic. Additionally, WordPress offers many plugins to help with SEO, keywords, and optimization all free of cost.
- Community ? WordPress has a large community that can assist with any errors or questions you may have.
In this article, we will go through the steps needed to set up WordPress on Ubuntu with PHP and the Apache server.
Update the System
Before we proceed with the installation, you need to make sure that your Ubuntu machine is updated and ready to install software.
To update and upgrade your system, use these commands ?
sudo apt update && sudo apt upgrade
This will ensure your system is updated to the latest state.
Install Apache Server
WordPress is a PHP web application. In order to work, it needs a server. There are many options, but the best and most popular one is the Apache server.
You can install it on Ubuntu by running this command ?
sudo apt install apache2
After the installation, you can check if it's running with the command ?
systemctl status apache2
You should get an output like this ?
You can navigate to your IP address if you installed it on a server or to localhost if it's installed locally. You should see this page from Apache ?
This means you have successfully set up the Apache server and it's ready to be used.
Install the Database
The next step is to install a database that WordPress will use to store website data such as articles, users, pages, and more. WordPress supports many databases; in this case, we will use MariaDB, which is a fork of MySQL and functions almost identically.
To install it on Ubuntu, use the following command ?
sudo apt install mariadb-server mariadb-client
You can verify the installation by checking the version with the command ?
mariadb --version
The next step is to make the database more secure, such as disabling remote access and other configurations. To do this, run the secure script provided by MySQL ?
sudo mysql_secure_installation
This will prompt you to make some changes ?
It will ask to set a password for root. You can skip it by pressing Enter.
It will then ask about changing the root password. You can skip it again by selecting [n].
For remote access, say [y] to disable it.
It will ask to delete the test database. Choose [y].
Finally, it will ask to reload the privileges. Choose [y].
Now, you have set up the MariaDB database securely and it's ready to store data.
Install PHP
WordPress is based on PHP, so we need to have PHP installed on Ubuntu to use WordPress. To install PHP and the PHP MySQL extension, use the following command ?
sudo apt install php php-mysql
After the installation is complete, verify it by creating a file in /var/www/html/. For example, let's add a file named hello.php. Using vim or any preferred editor, open the file ?
sudo vim /var/www/html/hello.php
Add this function to display PHP info:
<?php phpinfo(); ?>
Now, if you navigate to localhost/hello.php, you should see a PHP information page.
If this works, you have successfully installed PHP on Ubuntu.
Set Up the WordPress Database
The last step before installing WordPress is to prepare the database it will use to store data.
Open MariaDB as the root user using the command ?
sudo mysql -u root -p
You should see an output like this ?
Create a database using this SQL query ?
CREATE DATABASE word_db;
Choose any name for your database. In this example, we used word_db.
Next, create a user for this database with the following command ?
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'wp_pass';
Here, we created a user wp_user with the password wp_pass. You can replace these with your own values.
After creating the database and user, grant the user permissions to the database ?
GRANT ALL ON word_db.* TO 'wp_user'@'localhost';
Finally, reload the privileges and exit ?
FLUSH PRIVILEGES; EXIT;
Install WordPress
The last step is to install WordPress itself. You can download WordPress by visiting the official website or using wget ?
If you don't have wget installed, install it using the command ?
sudo apt install wget
Then run the command ?
wget https://wordpress.org/latest.tar.gz
This will download the wordpress latest version ?
After downloading, extract the file using ?
tar -xvf latest.tar.gz
This will create a folder called wordpress containing all the WordPress files. Copy this folder to /var/www/html/ ?
sudo cp -R wordpress /var/www/html/
Next, change ownership and permissions for the folder ?
sudo chown -R www-data:www-data /var/www/html/wordpress sudo chmod -R 755 /var/www/html/wordpress
At this point, you have installed WordPress. Navigate to localhost/wordpress to start the setup.
The first screen will prompt you to choose a language ?
Next, you will see a page to enter the database name, user, and password created earlier.
Fill in the details and submit. You will then be prompted to start the installation ?
The final step is to name your website and create an admin user.
Once completed, log in with your username and password.
You will be taken to the WordPress dashboard to start adding content, themes, and plugins.
Conclusion
WordPress is a simple and beginner-friendly CMS (Content Management System) that allows you to create powerful websites.
This guide provided a complete, step-by-step process to install and set up WordPress, from the initial installation to accessing the dashboard.