Note: Please don’t follow below guide, because I actually ran into permissions issue and other things at that moment I didn’t had time to further look into it so dropped that idea. Follow this blog instead: https://www.atlantic.net/dedicated-server-hosting/how-to-install-wordpress-on-arch-linux/

I have kept this blog for my own personal understanding and there are some pointers that can help as well in the above as mentioned.

There are three major dependencies for the wordpress

  1. Apache HTTP Server
  2. PHP
  3. MariaDB / MySql

Installation for the dependencies

# Install Apache HTTP Server
pacman -S apache
 
# Configure the /etc/httpd/conf/httpd.conf
# Since there is a bydefault directory called /srv/http where apache would serve the content but I want to change it
# Refer the file below called /etc/http/conf/httpd.conf
# also run below command
chmod o+x /home/visrut   # so apache can traverse through this directory and can access /home/visrut/dev/wordpress-play where I will put wordpress
 
# Instal PHP
pacman -S php
 
# Install MariaDB
pacman -S mariadb
mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
systemctl start mariadb
 
# download the wordpress zip file from: https://wordpress.org/download/
mv ~/Downloads/wordpress-6.6.2.zip ~/dev/wordpress-play
unzip wordpress-6.6.2.zip
 
# Configure Apache HTTP Server to run with PHP and MariaDB
pacman -S php-apache
 
# after installing above package confirm that this file does exist
ls /etc/httpd/modules/libphp.so
 
# uncomment out extension=mysqli and extension=pdo_mysql from /etc/php/php.ini file
sudo nvim /etc/php/php.ini
 
# Start the Apache server
sudo systemctl restart httpd.service
 
# create a database for wordpress in mariadb, press enter for below command if it asks for password
sudo mysql -u root -p
# MariaDB [(none)]> CREATE DATABASE wordpress;
# MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO "test"@"localhost" IDENTIFIED BY "test";
# MariaDB [(none)]> FLUSH PRIVILEGES;
# MariaDB [(none)]> EXIT;
 
# You also will require to give write permission, I was lazy to figure out how to do properly but this below hack I have used for myself
# If you see the process running for wordpress it will either have root user or http user
# so it won't be able to write files to wordpress-play folder I have created so that's why
chmod o+w /home/visrut
chmod o+w /home/visrut/dev
chmod -R o+w /home/visrut/dev/wordpress-play
 
# After playing with the wordpress if you want to see the information in the raw database
sudo mysql -u root -p
# MariaDB [(none)]> SHOW DATABASES;
# MariaDB [(none)]> USE wordpress;      # I had given this name above when creating the wordpress database
# MariaDB [(none)]> SHOW TABLES;
# MariaDB [(none)]> SELECT comment_ID, comment_author FROM wp_comments;
/etc/http/conf/httpd.conf
# I have commented out mod_mpm_event and uncommented mod_mpm_prefork because it would not work with libphp.so
# due to thread safety error
# The mpm_event and mpm_worker modules use threads to handle requests, which conflicts with mod_php because it is not thread-safe.
# The mpm_prefork module, on the other hand, uses separate processes rather than threads, which is compatible with mod_php.
 
#LoadModule mpm_event_module modules/mod_mpm_event.so
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
 
LoadModule userdir_module modules/mod_userdir.so
 
# Since WordPress heavily relies on URL rewriting for permalinks, ensure mod_rewrite is enabled.
LoadModule rewrite_module modules/mod_rewrite.so
 
<IfModule userdir_module>
UserDir enabled visrut
UserDir dev/wordpress-play
</IfModule>
 
DocumentRoot "/home/visrut/dev/wordpress-play"
<Directory "/home/visrut/dev/wordpress-play">
    # Other things as it is
</Directory>
 
# PHP
Include conf/extra/httpd-php.conf
 
# Wordpress
Include conf/extra/httpd-wordpress.conf
 
<IfModule dir_module>
    DirectoryIndex index.php
</IfModule>
/etc/http/conf/extra/httpd-wordpress.conf
Alias /wordpress-play "/home/visrut/dev/wordpress-play/wordpress"
<Directory "/home/visrut/dev/wordpress-play/wordpress">
    AllowOverride All
    Options FollowSymlinks
    Require all granted
</Directory>
/etc/http/conf/extra/httpd-php.conf
<FilesMatch \.php$>
    SetHandler application/x-httpd-php
</FilesMatch>

One more thing If you are not able to install the plugin or get a form regarding ftp protocol while installing, put below line in wp-config.php file inside your wordpress directory

wp-config.php
define('FS_METHOD', 'direct');

References

  1. https://wiki.archlinux.org/title/Wordpress
  2. https://www.reddit.com/r/Wordpress/comments/zlymzr/how_does_wordpress_work_under_the_hood/
  3. https://developer.wordpress.org/advanced-administration/wordpress/wp-config/
  4. https://stackoverflow.com/questions/20203379/linux-wordpress-cant-not-write-wp-config-file
  5. https://github.com/WordPress/WordPress/tree/master