How to Install WordPress on a Linux VPS: A Step-by-Step Guide for 2024

What is WordPress - [Marketing Dictionary]Installing WordPress on a Linux VPS gives you full control over your website’s environment, enabling better performance and customization. Follow this step-by-step guide to install WordPress on your Linux VPS efficiently.

Prerequisites

Before starting, ensure you have:

  1. A VPS: Ensure your VPS meets the minimum requirements (1GB RAM, 1 CPU, 20GB storage).
  2. Operating System: Ubuntu 20.04 LTS or later.
  3. Root Access: Access to your VPS as a root user or a user with sudo privileges.
  4. Domain Name: A domain name pointing to your VPS IP address.

Step 1: Update Your Server

First, ensure your server’s package list and installed packages are up-to-date.

bash

sudo apt update
sudo apt upgrade -y

Step 2: Install Apache Web Server

Apache is a popular and powerful web server. Install Apache using the following command:

bash

sudo apt install apache2 -y

Start and enable Apache to run on boot:

bash

sudo systemctl start apache2
sudo systemctl enable apache2

Step 3: Install MySQL

WordPress requires a database to store its data. Install MySQL server with:

bash

sudo apt install mysql-server -y

Secure your MySQL installation:

bash

sudo mysql_secure_installation

Step 4: Create a MySQL Database and User for WordPress

Log into MySQL and create a database and user for WordPress:

bash

sudo mysql -u root -p

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

Step 5: Install PHP

WordPress is written in PHP. Install PHP and the necessary extensions:

bash

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

Step 6: Download and Configure WordPress

Download the latest version of WordPress:

bash

cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo mv wordpress /var/www/html/

Set the correct permissions for WordPress:

bash

sudo 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 an Apache configuration file for your WordPress site:

bash

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

Add the following configuration:

apache

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

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

ErrorLog ${APACHE_LOG_DIR}/wordpress_error.log
CustomLog ${APACHE_LOG_DIR}/wordpress_access.log combined

</VirtualHost>

Enable the WordPress site and the rewrite module:

bash

sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 8: Complete the WordPress Installation via Web Interface

Open your web browser and navigate to your WordPress site (e.g., http://example.com). You will be greeted by the WordPress setup page.

  1. Choose your language and click “Continue.”
  2. On the “Welcome” page, click “Let’s go!”
  3. Database Details: Enter the database name (wordpress), username (wordpressuser), and the password you created earlier. The database host is localhost, and you can leave the table prefix as wp_.
  4. Click “Submit” and then “Run the installation.”
  5. Site Information: Enter your site title, username, password, and your email. Be sure to choose a strong password.

Click “Install WordPress” to complete the installation. Once done, log in with your new credentials.

Conclusion

Congratulations! You have successfully installed WordPress on your Linux VPS. You now have a powerful platform to build and manage your website. Remember to keep your server and WordPress installation updated to ensure security and performance.

For more detailed guides and the latest updates on WordPress and web hosting, subscribe to our newsletter and follow our blog. Enjoy building your WordPress site!

administrator

Leave A Comment