In this tutorial i will show you how to install and configure LEMP stack. I’m gonna install Nginx, MariaDB (mysql), php7, php8, phpMyAdmin

Install Nginx web server

sudo pacman -S nginx-mainline

Start nginx server

sudo systemctl start nginx

Start nginx on boot

sudo systemctl enable nginx

Install MariaDB (MySQL)

sudo pacman -S mariadb
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Start mariadb server

sudo systemctl start mariadb

Start mariadb on boot

sudo systemctl enable mariadb

Secure installation. More info

sudo mysql_secure_installation

Answer: ENTER, N, N, Y, Y, Y

Access MySQL

sudo mysql -u root

Create your first MySQL user

CREATE USER 'arch'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON `arch\_%` .  * TO 'arch'@'%';
FLUSH PRIVILEGES;
exit

If you want you can create an superuser (admin). More info

CREATE USER 'arch'@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'arch'@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit

Install php

By default arch will install the latest version of php which is is 8.x.x. I recommend install php8 and php7, because some scripts my not be ready for php8 yet.

sudo pacman -S php php-fpm php-gd
sudo pacman -S php7 php7-gd php7-fpm

Start php-fpm7 and enable on boot. If you want to sty on php8 just remove 7

sudo systemctl start php-fpm7
sudo systemctl enable php-fpm7

Open php.ini

sudo vim /etc/php7/php.ini

Uncomment following lines:

extension=curl
extension=gd
extension=iconv
extension=soap
extension=mysqli
zend_extension=opcache
extension=zip
extension=exif
extension=pdo_mysql

Uncomment OPCache

[OPCache]
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=40000

Install phpMyAdmin

sudo pacman -S phpmyadmin

Create symbolic link

sudo ln -s /usr/share/webapps/phpMyAdmin /usr/share/nginx/html

Open config.inc.php file

sudo vim /usr/share/webapps/phpMyAdmin/config.inc.php

Add the followning line below /* Authentication type */

$cfg['TempDir'] = '/tmp/phpmyadmin';

Change blowfish_secret

$cfg['blowfish_secret'] = 'mrgQxxk8C-y}U7ji2BO9o5jLf}Qhe-BI[~6SUa';

Set extra security layout for phpMyAdmin

openssl passwd

Add new password file user:password

sudo vim /etc/nginx/pma_pass