Skip to content

Instantly share code, notes, and snippets.

@tatumroaquin
Last active June 24, 2021 01:40
Show Gist options
  • Save tatumroaquin/1708415a5ee5be07e3138c6d7ae07dc2 to your computer and use it in GitHub Desktop.
Save tatumroaquin/1708415a5ee5be07e3138c6d7ae07dc2 to your computer and use it in GitHub Desktop.
simple LEMP stack web server

Arch Linux LEMP Stack

Install NGINX Web Server

  1. sudo pacman --noconfirm -S nginx
  2. sudo vim /etc/nginx/nginx.conf
// Modify the following
location / {
   root           /usr/share/nginx/html;
   index          index.html index.php;
}

location ~ \.php$ {
   root           /usr/share/nginx/html;
   fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
   fastcgi_index  index.php;
   fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
   include        fastcgi_params;
}
  1. sudo nginx -t
  2. sudo systemctl start nginx
  3. sudo systemctl enable nginx

Install MariaDB/MySQL Database

  1. sudo pacman --noconfirm -S mariadb
  2. sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
  3. sudo systemctl start mariadb
  4. sudo systemctl enable mariadb
  5. sudo mysql_secure_installation
// Answer the following, change the root password if needed
Enter current password for root (enter for none): Enter
Switch to unix_socket authentication [Y/n]: Enter
Change the root password? [Y/n]: N
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tablse now? [Y/n]: Y
  1. mysql -u root -p
  2. CREATE USER 'admin'@'localhost' IDENTIFIED BY 'password'
  3. GRANT ALL PRIVILEGES ON DBName.* TO 'admin'@'localhost'

SQL Password Reset

// https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
sudo mysql -u root -p
ALTER USER 'user'@'localhost' IDENTIFIED BY 'newpass';
FLUSH PRIVILEGES;

Install PHP Application Server

  1. sudo pacman -S php php-fpm
  2. sudo vim /etc/php/php.ini
// Uncomment the following, phpMyAdmin requires iconv and mysqli
;extensions=iconv
;extensions=mysqli
;extensions=pdo_mysql
  1. sudo systemctl start php-fpm
  2. sudo systemctl enable php-fpm
  3. sudo vim /usr/share/nginx/html/info.php
<?php phpinfo(); ?>
  1. http://localhost/info.php

Install phpMyAdmin CPanel

  1. sudo pacman --noconfirm -S phpmyadmin
  2. sudo ln -s /usr/share/webapps/phpMyAdmin /usr/share/nginx/html/
  3. http://localhost/phpMyAdmin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment