Arch Linux BasedManjaro

How To Install WordPress on Manjaro

Install WordPress on Manjaro

WordPress, the world’s most popular content management system, powers over 40% of all websites on the internet. Its versatility and user-friendly interface make it an excellent choice for bloggers, businesses, and developers alike. Manjaro, a user-friendly and powerful Linux distribution based on Arch Linux, provides a stable and customizable platform for hosting WordPress. In this comprehensive guide, we’ll walk you through the process of installing WordPress on Manjaro using the LAMP stack, ensuring you have a robust and efficient web hosting environment.

Prerequisites

Before we begin, make sure you have the following:

  • A Manjaro Linux system (updated to the latest version)
  • Root or sudo access to your Manjaro system
  • Basic familiarity with command-line operations
  • A stable internet connection

This guide assumes you’re comfortable using the terminal and have a basic understanding of web servers and databases. Don’t worry if you’re new to these concepts; we’ll explain each step in detail.

Understanding the LAMP Stack

LAMP is an acronym that stands for Linux, Apache, MySQL (or MariaDB), and PHP. This popular stack of technologies works together to create a robust web hosting environment:

  • Linux: The operating system (in this case, Manjaro)
  • Apache: The web server that handles HTTP requests
  • MySQL/MariaDB: The database management system
  • PHP: The server-side scripting language

WordPress is built to run optimally on the LAMP stack, making it an ideal choice for our installation. Each component plays a crucial role in serving dynamic web content efficiently and securely.

Updating Manjaro System

Before we start installing the LAMP stack components, it’s essential to ensure your Manjaro system is up to date. This helps prevent compatibility issues and ensures you have the latest security patches.

Open a terminal and run the following commands:

sudo pacman -Syu

This command updates the package database and upgrades all installed packages to their latest versions. If prompted, confirm the updates and allow the process to complete.

Installing Apache Web Server

Apache is one of the most popular web servers, known for its reliability and flexibility. Let’s install and configure Apache on your Manjaro system:

  1. Install Apache using the package manager:
    sudo pacman -S apache
  2. Start the Apache service and enable it to run at boot:
    sudo systemctl start httpd
    sudo systemctl enable httpd
  3. Check if Apache is running:
    sudo systemctl status httpd

You should see output indicating that Apache is active and running. To test your Apache installation, open a web browser and navigate to http://localhost. You should see the default Apache welcome page.

Setting Up MariaDB (MySQL) Database

MariaDB is a fork of MySQL and is fully compatible with WordPress. Let’s install and secure MariaDB:

  1. Install MariaDB:
    sudo pacman -S mariadb
  2. Initialize MariaDB data directory:
    sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
  3. Start MariaDB service and enable it to run at boot:
    sudo systemctl start mariadb
    sudo systemctl enable mariadb
  4. Secure your MariaDB installation:
    sudo mysql_secure_installation

Follow the prompts to set a root password, remove anonymous users, disallow root login remotely, and remove the test database.

Now, let’s create a database and user for WordPress:

  1. Log in to MariaDB:
    sudo mysql -u root -p
  2. Create a database for WordPress:
    CREATE DATABASE wordpress_db;
  3. Create a user and grant privileges:
    CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'your_strong_password';
    GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;

Replace ‘your_strong_password’ with a secure password of your choice.

Installing PHP and Required Extensions

PHP is the scripting language that WordPress is built on. We’ll install PHP 8.3 and the necessary extensions:

  1. Install PHP and required extensions:
    sudo pacman -S php php-apache php-gd php-imagick php-intl php-mysqli
  2. Configure PHP for Apache. Edit the Apache configuration file:
    sudo nano /etc/httpd/conf/httpd.conf
  3. Find the line that loads the PHP module and ensure it’s uncommented:
    LoadModule php_module modules/libphp.so
  4. Add the following lines at the end of the file:
    Include conf/extra/php_module.conf
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
  5. Save the file and exit the editor.
  6. Restart Apache to apply the changes:
    sudo systemctl restart httpd

Downloading and Configuring WordPress

Now that we have our LAMP stack set up, let’s download and configure WordPress:

  1. Navigate to the Apache document root:
    cd /srv/http
  2. Download the latest WordPress package:
    sudo wget https://wordpress.org/latest.tar.gz
  3. Extract the WordPress files:
    sudo tar -xzvf latest.tar.gz
  4. Move WordPress files to the document root:
    sudo mv wordpress/* .
    sudo rm -rf wordpress latest.tar.gz
  5. Set proper permissions:
    sudo chown -R http:http /srv/http
    sudo chmod -R 755 /srv/http
  6. Create the WordPress configuration file:
    sudo cp wp-config-sample.php wp-config.php
  7. Edit the configuration file:
    sudo nano wp-config.php
  8. Update the database details:
    define('DB_NAME', 'wordpress_db');
    define('DB_USER', 'wordpress_user');
    define('DB_PASSWORD', 'your_strong_password');
    define('DB_HOST', 'localhost');

Replace ‘your_strong_password’ with the password you set earlier for the WordPress database user.

Configuring Apache Virtual Hosts

Virtual hosts allow you to host multiple websites on a single server. Let’s set up a virtual host for WordPress:

  1. Create a new virtual host configuration file:
    sudo nano /etc/httpd/conf/extra/httpd-vhosts.conf
  2. Add the following configuration:
    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot "/srv/http"
        ServerName localhost
        ErrorLog "/var/log/httpd/wordpress-error_log"
        CustomLog "/var/log/httpd/wordpress-access_log" common
        <Directory "/srv/http">
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
  3. Save the file and exit the editor.
  4. Enable the virtual hosts configuration in the main Apache configuration file:
    sudo nano /etc/httpd/conf/httpd.conf
  5. Uncomment or add the following line:
    Include conf/extra/httpd-vhosts.conf
  6. Restart Apache to apply the changes:
    sudo systemctl restart httpd

Completing WordPress Installation

With all the components in place, we can now complete the WordPress installation:

  1. Open a web browser and navigate to http://localhost
  2. You should see the WordPress installation page. Select your language and click “Continue”.
  3. On the next page, enter the site information:
    • Site Title
    • Username (for admin account)
    • Password
    • Your Email
  4. Click “Install WordPress” to complete the installation.

Congratulations! You have successfully installed WordPress on your Manjaro system.

Install WordPress on Manjaro

Securing Your WordPress Installation

Security is crucial for any website. Here are some steps to enhance your WordPress security:

  1. Keep WordPress, themes, and plugins updated regularly.
  2. Use strong, unique passwords for all accounts.
  3. Install a security plugin like Wordfence or Sucuri.
  4. Enable two-factor authentication for admin accounts.
  5. Limit login attempts to prevent brute-force attacks.
  6. Use SSL/TLS encryption (HTTPS) for your site.

Optimizing WordPress Performance on Manjaro

To ensure your WordPress site runs smoothly on Manjaro, consider these optimization techniques:

  1. Install a caching plugin like W3 Total Cache or WP Super Cache.
  2. Optimize your database regularly using a plugin like WP-Optimize.
  3. Use a Content Delivery Network (CDN) to serve static content.
  4. Optimize images before uploading them to your site.
  5. Minimize the use of plugins and choose lightweight themes.
  6. Enable PHP OPcache for improved PHP performance.

Troubleshooting Common Issues

If you encounter problems during or after the installation, here are some common issues and their solutions:

  • Permission errors: Ensure that the web server has the correct permissions to access WordPress files and directories.
  • Database connection errors: Double-check your database credentials in the wp-config.php file.
  • PHP configuration issues: Verify that all required PHP extensions are installed and enabled.
  • White screen of death: Enable WordPress debug mode in wp-config.php to identify the cause.

Congratulations! You have successfully installed WordPress. Thanks for using this tutorial to install the latest version of WordPress on Manjaro Linux. For additional help or useful information, we recommend you check the official WordPress website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button