Step-by-Step to install WordPress in Ubuntu Linux with LAMP

Photo of author
By Jay
— 4 min read
Photo of author
Written by
Photo of author
Verified by
Published On
— 4 min read

Install WordPress in Ubuntu

Introduction to Install WordPress in Ubuntu

WordPress is one of the most popular content management systems (CMS) in the world, powering millions of websites and blogs. Its user-friendly interface, extensive customization options, and robust community support make it an ideal choice for both beginners and experienced developers. If you’re looking to create a website or blog, installing WordPress on an Ubuntu server is a great way to get started.

In this article, we will guide you through the process to install WordPress in Ubuntu, step by step. Whether you’re setting up a personal blog, a business website, or an online portfolio, our comprehensive guide will cover everything you need to know, from preparing your server environment to configuring your WordPress installation. By the end of this tutorial, you’ll have a fully functional WordPress site up and running on your Ubuntu server, ready for you to customize and populate with content. Let’s get started!

To Install WordPress in ubuntu Linux server involves several steps. Below is a comprehensive guide covering the entire process from setting up your server to accessing your WordPress site.

Prerequisites

  • A Linux server (Ubuntu 20.04 LTS is used in this guide)
  • A non-root user with sudo privileges
  • Basic knowledge of terminal commands
  • Domain name (optional but recommended)

Step 1: Update Your Server

First, ensure your server is up-to-date:

sudo apt update
sudo apt upgrade

Step 2: Install Apache

WordPress requires a web server to run. Apache is a popular choice:

sudo apt install apache2

Enable Apache to start on boot and start it now:

sudo systemctl enable apache2
sudo systemctl start apache2

Read Also | Step-by-Step Guide to Install WordPress on Linux with LAMP

Step 3: Install MySQL

WordPress uses MySQL to store its data. Install MySQL server:

sudo apt install mysql-server

Secure the MySQL installation:

sudo mysql_secure_installation

During the secure installation, you’ll be prompted to set a root password and make several security choices. Follow the on-screen instructions.

Step 4: Install PHP

WordPress is built with PHP. Install PHP along with some common modules:

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

Step 5: Create a MySQL Database and User for WordPress

Log into MySQL:

sudo mysql -u root -p

Create a database for WordPress:

CREATE DATABASE wordpress;

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

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

Replace 'password' with a strong password of your choice.

Step 6: Download and Configure WordPress

Navigate to the /tmp directory and download the latest version of WordPress:

cd /tmp
wget https://wordpress.org/latest.tar.gz

Extract the downloaded file:

tar -xvzf latest.tar.gz

Move the WordPress files to the Apache root directory:

sudo mv wordpress /var/www/html/

Set the proper permissions:

chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress

Step 7: Configure Apache for WordPress

Create a new Apache configuration file for your WordPress site:

sudo vi /etc/apache2/sites-available/wordpress.conf

Add the following configuration to the file:

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/wordpress
ServerName example.com
ServerAlias www.example.com

<Directory /var/www/html/wordpress/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Replace example.com with your domain name.

Enable the WordPress site and the Apache rewrite module:

sudo a2ensite wordpress.conf
sudo a2enmod rewrite

Restart Apache to apply the changes:

sudo systemctl restart apache2

Step 8: Complete the WordPress Installation Through the Web Interface

Open your web browser and navigate to http://your_domain_or_IP. You should see the WordPress installation page.

Select your language and click “Continue.”

On the next page, enter the database details you created earlier:

  • Database Name: wordpress
  • Username: wordpressuser
  • Password: The password you set
  • Database Host: localhost
  • Table Prefix: wp_ (you can change this if you want to run multiple WordPress installations in one database)

Click “Submit” and then “Run the installation.”

Fill in the site information:

  • Site Title
  • Username
  • Password
  • Your Email

Click “Install WordPress.”

Step 9: Secure Your WordPress Installation

To enhance the security of your WordPress installation, consider the following steps:

Install an SSL Certificate: Encrypt traffic between your server and clients. You can use Let’s Encrypt:

sudo apt install certbot python3-certbot-apache sudo certbot --apache

Regularly Update WordPress, Themes, and Plugins: Ensure you always have the latest security patches.

Change the Default Login URL: Use a plugin to change the default /wp-admin login URL.

Limit Login Attempts: Protect against brute force attacks by limiting the number of login attempts.


Conclusion

Congratulations! You have successfully learned how to install WordPress in Ubuntu. With your new website now live, you can explore the countless themes and plugins available to customize your site according to your preferences. Whether you’re building a personal blog, an online store, or a professional portfolio, WordPress provides the flexibility and functionality to help you achieve your goals.

As you continue to develop your site, remember to keep your WordPress installation, themes, and plugins updated to ensure optimal performance and security. Regular backups are also crucial to protect your content and data. Don’t hesitate to engage with the vibrant WordPress community for support, resources, and inspiration as you grow your online presence.

Thank you for following this guide on how to install WordPress in Ubuntu! We hope you found it informative and helpful. If you have any questions or need further assistance, please leave a comment below. Happy blogging!

Related Posts


About Author

Photo of author

Jay

I specialize in web development, hosting solutions, and technical support, offering a unique blend of expertise in crafting websites, troubleshooting complex server issues, and optimizing web performance. With a passion for empowering businesses and individuals online, I provide in-depth reviews, tech tutorials, and practical guides to simplify the digital landscape. My goal is to deliver clear, reliable, and insightful content that helps readers make informed decisions and enhance their online presence.

Leave a Comment