How to Install WordPress on Ubuntu?

how to install wordpress on ubuntu

WordPress is one of the most popular content management systems (CMS) used by millions of websites around the world. If you’re running an Ubuntu server and want to install WordPress, you’re in the right place. In this step-by-step guide, we’ll show you how to install WordPress on Ubuntu, from setting up the necessary server software to configuring WordPress itself.

Prerequisites for Install WordPress on Ubuntu

Before you begin, you’ll need to ensure you have the following:

  • Ubuntu Server: Make sure you’re using a supported version of Ubuntu (Ubuntu 20.04 LTS or later).
  • A LAMP Stack: WordPress requires a web server (Apache), a database (MySQL or MariaDB), and PHP. We will install all these components.
  • Root or Sudo Access: You’ll need root or sudo privileges on the server to install the software.
how to install wordpress on ubuntu

Step 1: Update Your System

Before installing anything, it’s a good idea to update your system to ensure you’re working with the latest packages. Open your terminal and run the following commands:

sudo apt update
sudo apt upgrade

This will update your package list and upgrade the installed packages to the latest versions.

Step 2: Install Apache Web Server

Apache is the most popular web server used to host WordPress. To install Apache on your Ubuntu system, use the following command:

sudo apt install apache2

Once Apache is installed, you can verify the installation by visiting your server’s IP address or localhost in your web browser. You should see the default Apache page.

To ensure Apache starts automatically on boot, use:

sudo systemctl enable apache2

Step 3: Install MySQL Database Server

WordPress relies on a MySQL or MariaDB database to store its content. In this guide, we’ll install MySQL. To install it, run:

sudo apt install mysql-server

After installation, it’s important to secure your MySQL installation. Run the following command to set a root password and improve security:

sudo mysql_secure_installation

Follow the prompts to configure MySQL security settings.

Step 4: Install PHP and Required Extensions

WordPress is built using PHP, so you’ll need to install PHP and a few additional extensions. Install PHP along with the necessary extensions by running:

sudo apt install php libapache2-mod-php php-mysql php-curl php-xml php-mbstring php-zip

Once the installation is complete, restart Apache to apply the changes:

sudo systemctl restart apache2

You can check your PHP version by running:

php -v

Step 5: Create a MySQL Database for WordPress

WordPress needs a database to store its content. To create a MySQL database, first log into MySQL:

sudo mysql -u root -p

Create a new database for WordPress:

CREATE DATABASE wordpress;

Create a new MySQL user and grant them full privileges to the WordPress database:

CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'yourpassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Make sure to replace 'yourpassword' with a strong password.

Step 6: Download and Install WordPress

Now, we’ll download the latest version of WordPress and move it to the Apache web directory.

  1. First, change to the /tmp directory:
cd /tmp
  1. Download the latest WordPress package:
wget https://wordpress.org/latest.tar.gz
  1. Extract the tarball:
tar xzvf latest.tar.gz
  1. Move the extracted WordPress files to Apache’s root directory:
sudo mv wordpress /var/www/html/
  1. Set proper permissions for the WordPress files:
sudo chown -R www-data:www-data /var/www/html/wordpress

Step 7: Configure WordPress

  1. Create the WordPress configuration file by copying the sample file:
cd /var/www/html/wordpress
sudo cp wp-config-sample.php wp-config.php
  1. Open the wp-config.php file in a text editor:
sudo nano wp-config.php
  1. Update the following lines with your database details:
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wp_user' );
define( 'DB_PASSWORD', 'yourpassword' );
define( 'DB_HOST', 'localhost' );

Replace 'yourpassword' with the password you set earlier for the wp_user.

Save and exit the editor (Ctrl+X, then press Y, and Enter).

Step 8: Complete the WordPress Installation via the Web Browser

  1. Open your web browser and go to your server’s IP address or http://localhost/wordpress.
  2. You will see the WordPress installation page. Select your language and click Continue.
  3. Fill in the required details for your site (Site Name, Admin Username, Password, and Email), and click Install WordPress.

Once the installation is complete, you’ll see a success message. You can now log into your WordPress admin panel by visiting http://localhost/wordpress/wp-admin.

Step 9: Secure Your WordPress Installation

After installing WordPress, it’s important to take steps to secure your site. Some basic security tips include:

  • Change the default “admin” username: Avoid using “admin” as your WordPress username.
  • Install Security Plugins: Consider using plugins like Wordfence or Sucuri for extra protection.
  • Set File Permissions Properly: Ensure your files and directories have the correct permissions to avoid unauthorized access.

Conclusion

Congratulations! You’ve successfully install WordPress on Ubuntu server. Now you can start building your website, customize it with themes and plugins, and manage your content easily. WordPress provides a vast array of features, allowing you to create anything from a personal blog to a full-fledged e-commerce site.

As you continue to use WordPress, don’t forget to keep your server and WordPress installation up to date, and always backup your site regularly.

Happy building, and enjoy your new WordPress site on Ubuntu!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top