How To 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:
- Install Apache using the package manager:
sudo pacman -S apache
- Start the Apache service and enable it to run at boot:
sudo systemctl start httpd sudo systemctl enable httpd
- 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:
- Install MariaDB:
sudo pacman -S mariadb
- Initialize MariaDB data directory:
sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
- Start MariaDB service and enable it to run at boot:
sudo systemctl start mariadb sudo systemctl enable mariadb
- 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:
- Log in to MariaDB:
sudo mysql -u root -p
- Create a database for WordPress:
CREATE DATABASE wordpress_db;
- 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:
- Install PHP and required extensions:
sudo pacman -S php php-apache php-gd php-imagick php-intl php-mysqli
- Configure PHP for Apache. Edit the Apache configuration file:
sudo nano /etc/httpd/conf/httpd.conf
- Find the line that loads the PHP module and ensure it’s uncommented:
LoadModule php_module modules/libphp.so
- 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
- Save the file and exit the editor.
- 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:
- Navigate to the Apache document root:
cd /srv/http
- Download the latest WordPress package:
sudo wget https://wordpress.org/latest.tar.gz
- Extract the WordPress files:
sudo tar -xzvf latest.tar.gz
- Move WordPress files to the document root:
sudo mv wordpress/* . sudo rm -rf wordpress latest.tar.gz
- Set proper permissions:
sudo chown -R http:http /srv/http sudo chmod -R 755 /srv/http
- Create the WordPress configuration file:
sudo cp wp-config-sample.php wp-config.php
- Edit the configuration file:
sudo nano wp-config.php
- 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:
- Create a new virtual host configuration file:
sudo nano /etc/httpd/conf/extra/httpd-vhosts.conf
- 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>
- Save the file and exit the editor.
- Enable the virtual hosts configuration in the main Apache configuration file:
sudo nano /etc/httpd/conf/httpd.conf
- Uncomment or add the following line:
Include conf/extra/httpd-vhosts.conf
- 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:
- Open a web browser and navigate to
http://localhost
- You should see the WordPress installation page. Select your language and click “Continue”.
- On the next page, enter the site information:
- Site Title
- Username (for admin account)
- Password
- Your Email
- Click “Install WordPress” to complete the installation.
Congratulations! You have successfully installed WordPress on your Manjaro system.
Securing Your WordPress Installation
Security is crucial for any website. Here are some steps to enhance your WordPress security:
- Keep WordPress, themes, and plugins updated regularly.
- Use strong, unique passwords for all accounts.
- Install a security plugin like Wordfence or Sucuri.
- Enable two-factor authentication for admin accounts.
- Limit login attempts to prevent brute-force attacks.
- 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:
- Install a caching plugin like W3 Total Cache or WP Super Cache.
- Optimize your database regularly using a plugin like WP-Optimize.
- Use a Content Delivery Network (CDN) to serve static content.
- Optimize images before uploading them to your site.
- Minimize the use of plugins and choose lightweight themes.
- 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.