
How To Install WordPress on Arch Linux
In the world of content management systems, WordPress stands out as one of the most popular and flexible platforms for building websites and blogs. As an Arch Linux user, installing WordPress may seem daunting at first, but it’s quite manageable with the right steps. In this guide, we’ll walk you through the process of installing WordPress on your Arch Linux system, ensuring you can set up your own site in no time.
Prerequisites
Before diving into the installation, make sure you have the following prerequisites:
- Arch Linux Installation: You should have a running Arch Linux installation.
- Web Server: We will use Apache in this example, but Nginx is also a great option.
- PHP: WordPress requires PHP, and we will install necessary PHP extensions.
- Database: We’ll use MariaDB, a fork of MySQL, to store our data.
- Basic Terminal Knowledge: Familiarity with the terminal will help in executing the commands.
Step 1: Update Your System
It’s always a good practice to update your system before installing new software. Open your terminal and run:
sudo pacman -SyuThis command syncs the package databases and updates your system packages.
Step 2: Install Apache
To install Apache, use the following command:
sudo pacman -S apacheAfter the installation, enable and start the Apache service:
sudo systemctl enable httpd
sudo systemctl start httpdYou can check if Apache is running by accessing http://localhost in your web browser.
Step 3: Install PHP and Required Extensions
Next, install PHP and some important extensions required by WordPress:
sudo pacman -S php php-apache php-mysql php-gd php-curl php-xml php-mbstring php-zipAfter installing PHP, you need to modify the Apache configuration to work with PHP. Open the Apache config file in your preferred text editor:
sudo nano /etc/httpd/conf/httpd.confAdd the following lines to the end of the configuration file:
# Load PHP module
LoadModule php_module modules/libphp.so
# Set handler for PHP files
AddType application/x-httpd-php .phpSave and close the file, and restart Apache to apply the changes:
sudo systemctl restart httpdStep 4: Install MariaDB
Now, let’s install MariaDB:
sudo pacman -S mariadbAfter installation, initialize the MariaDB data directory:
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysqlNext, start and enable MariaDB:
sudo systemctl start mariadb
sudo systemctl enable mariadbTo secure your MariaDB installation, run:
sudo mysql_secure_installationFollow the prompts to set a root password and secure your database instance.
Step 5: Create a Database for WordPress
We now need to create a database and a user for WordPress. Log into the MariaDB shell:
sudo mysql -u root -pInside the MariaDB shell, run the following commands to create a new database and user:
CREATE DATABASE wordpress;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;Substitute your_password with a strong password of your choice.
Step 6: Download and Set Up WordPress
Now it’s time to download WordPress. Navigate to your web root directory (e.g., /srv/http for Apache) and download the latest WordPress package:
cd /srv/http
sudo wget https://wordpress.org/latest.tar.gzExtract the downloaded file:
sudo tar -xvzf latest.tar.gzMove the extracted files to the correct directory:
sudo mv wordpress/* ./Remove the downloaded archive and the empty directory:
sudo rm -rf wordpress latest.tar.gzNext, change ownership of the files so that the web server can access them:
sudo chown -R http:http /srv/http/*Step 7: Configure WordPress
Copy the sample configuration file:
sudo cp wp-config-sample.php wp-config.phpOpen the configuration file in a text editor:
sudo nano wp-config.phpFind the following lines and enter your database details:
define('DB_NAME', 'database_name_here');
define('DB_USER', 'username_here');
define('DB_PASSWORD', 'password_here');Replace database_name_here with wordpress, username_here with wp_user, and password_here with the password you set earlier.
Step 8: Complete the Installation via the Web Interface
Open your web browser and navigate to http://localhost. You should see the WordPress installation wizard. Follow the on-screen instructions to complete the installation, including setting up your site title, username, and password.
Conclusion
Congratulations! You have successfully installed WordPress on your Arch Linux system. You can now start customizing your site, adding themes, plugins, and creating content.
We at Greenhost.Cloud strive to empower users with knowledge and resources to create a sustainable, online presence. If you enjoyed this guide, check out our other articles and tutorials!