How to install Drupal8 on ArchLinux
In this post, I will show you how you can install the Drupal on any Linux distribution based on ArchLinux such as Manjaro. Now be mindful about which version of drupal you are installing and which PHP versions it supports. in my case, I was installing Drupal 8.8 with PHP 7.4 as Archlinux ships latest stable packages but 8.8 only supports php 7.3 maximum so I was getting a lot of errors and couldn’t figure out why it is happening.
In this post, I will focus more on the drupal specific configuration. you should look at ArchWiki for general-purpose apache and PHP configuration
1 Install Apache
install apache from official repo like this
sudo pacman -S apache
check out the official wiki for more
2 Install PHP
install PHP from official repo like this.
sudo pacman -S php php-fpm
also, look https://wiki.archlinux.org/index.php/PHP. Now depending on the Drupal version, you might need to use a different version of PHP which is not in our official repo. but fear not. AUR has our backs.
For the drupal 8.8 maximum supported version of php is 7.3. So I installed php72 package from AUR. You can compile it from source so you should edit PKGBUILD accordingly. I added -j8 flag to make for faster compilation.
3 Configure PHP
Now you will need to configure PHP or you might get some errors while installing drupal
open /etc/php/php.ini file in your favorite editor. In my case, I, am using a special version of PHP which is 7.2 so I have to edit /etc/php72/php.ini
your php.ini file should contain the following lines
During drupal installation, I was getting 504 gateway errors. After some googling, I found out these lines and they solved my problem
max_execution_time = 600
max_input_time = 600
memory_limit = 1024M
For MySQL/MariaDB/PerconaDB
extension=mysqli
extension=pdo_mysql
This line is optional but increases performance
zend_extension=opcache
4 Configure Apache
To apply max_execution_time in php.ini, We also need to add following line in /etc/httpd/conf/httpd.conf
ProxyTimeout 600
if using another version of php like php72 (7.2) , then you must edit /etc/httpd/conf/extra/php-fpm.conf file. its content should be like this:-
DirectoryIndex index.php index.html
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php72-fpm/php-fpm.sock|fcgi://localhost/"
</FilesMatch>
5 Install drupal
You can install drupal from official repo but it’s not really a good way as drupal can update itself and you can’t install some other version you might like. So I download drupal zip from an official drupal website and unzip it in a path where apache can access it. for example /src/http
don’t forget to change permissions of the folder you just extracted.
chown http:users <your-drupal-folder> -R
6 Create Database
you don’t need to create any database for sqlite but for MySQL and PostgreSQL, you have to.
for MySQL create database like this:-
CREATE DATABASE drupaldb;
CREATE USER 'username' IDENTIFIED BY 'some very secure password'
GRANT ALL PRIVILEGES ON drupaldb.* to username;
7 Start the stack
Now you need to start the stack like this
sudo systemctl restart httpd.service php72-fpm.service
if you are using MySQL or PostgreSQL rather than Sqlite than start it as well
sudo systemctl start mysql
or
sudo systemctl start postgresql
8 That’s it
now navigate to the folder of your installation from the browser. for example, if you have unzipped drupal into /srv/http/drupalblog then go to http://localhost/drupalblog