Skip to content

Instantly share code, notes, and snippets.

@bagus-Arya
Last active November 22, 2024 02:06
Show Gist options
  • Save bagus-Arya/248801a014161ee376ee27d35c590ce8 to your computer and use it in GitHub Desktop.
Save bagus-Arya/248801a014161ee376ee27d35c590ce8 to your computer and use it in GitHub Desktop.

Guide to install and setup a Laravel framework on your archlinux system and serve php-based database applications.
LLAMP stands for a Laravel (php framework) Linux system with Apache (webserver), MariaDB (database) and PHP (programming language). In this guide we will also install PhpMyAdmin (database admin GUI) to easily manage the SQL tables.

Laravel

laravel logo

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.

Install packages

If you don't have PHP and Composer installed on your local machine, the following commands will install PHP, Composer, and the Laravel installer:

/bin/bash -c "$(curl -fsSL https://php.new/install/linux)"

If you already have PHP and Composer installed, you may install the Laravel installer via Composer:

composer global require laravel/installer

After you have installed PHP, Composer, and the Laravel installer, you're ready to create a new Laravel application. The Laravel installer will prompt you to select your preferred testing framework, database, and starter kit:

laravel new your-app-name

Create your database first

Update the .env file in your project with the database name you want to connect to, as well as the other environment variables if they differ from the default.

Once the application has been created, you can start Laravel's local development server, queue worker, and Vite development server using the dev Composer script:

cd example-app
npm install && npm run build
composer run dev

Update Arch Package

sudo pacman -Syu

Apache

apache logo

The Apache HTTP Server is an open-source and free product of the Apache Software Foundation and one of the most widely used web servers on the Internet. In addition to factors such as performance, expandability, security, freedom from license costs and support from a very large community, its long-term availability for a wide variety of operating systems is one of the reasons for its widespread use; it is most frequently used as a LAMP system.

Install packages

sudo pacman -S apache

PHP

php logo
PHP (for "PHP: Hypertext Preprocessor") is a scripting language with a syntax based on C and Perl, which is mainly used to create dynamic websites or web applications. PHP is distributed as free software under the PHP license. PHP is characterized by broad database support and Internet protocol integration as well as the availability of numerous function libraries.

Install Packages

sudo pacman -S php php-cgi php-gd php-pgsql php-apache

MariaDB

mariadb logo
MariaDB is a free, relational open source database management system that was created by a fork from MySQL. The project was initiated by MySQL's former main developer Michael Widenius, who also developed the storage engine Aria, on which MariaDB was originally based.

Install Packages

sudo pacman -S mariadb

Config MariaDB

Run mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

Start the mariadb service: systemctl enable --now mariadb

Secure MariaDB Installation

mysql_secure_installation

Connect to mysql server from your root systemuser via socket (no password required)

mysql --protocol=socket #run this command as root (e.g. prefixed with sudo)

Setup User

sudo mysql -u root # I had to use "sudo" since it was a new installation

mysql> USE mysql;
mysql> CREATE USER 'YOUR_SYSTEM_USER'@'localhost' IDENTIFIED BY 'YOUR_PASSWD';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'YOUR_SYSTEM_USER'@'localhost';
mysql> UPDATE user SET plugin='auth_socket' WHERE User='YOUR_SYSTEM_USER';
mysql> FLUSH PRIVILEGES;
mysql> exit;

sudo systemctl restart/start/stop mysql

⚠️ Got Error Delete User: FLUSH PRIVILEGES sudo rm -rf /etc/mysql sudo rm -rf /var/lib/mysql

PhpMyAdmin

pma logo
phpMyAdmin (PMA for short) is a free web application for the administration of MySQL databases and MariaDB. The software is implemented in PHP, hence the name phpMyAdmin. Most functions can be executed without writing SQL statements, such as listing data records, creating/deleting tables, adding columns, creating/deleting databases and managing users.

Install Packages

sudo pacman -S phpmyadmin

Config PhpMyAdmin

Create the Apache configuration file:

/etc/httpd/conf/extra/phpmyadmin.conf

Alias /phpmyadmin "/usr/share/webapps/phpMyAdmin"
<Directory "/usr/share/webapps/phpMyAdmin">
    DirectoryIndex index.php
    AllowOverride All
    Options FollowSymlinks
    Require all granted
</Directory>

And include it in /etc/httpd/conf/httpd.conf:

# phpMyAdmin configuration
Include conf/extra/phpmyadmin.conf

You can now access the PhpMyAdmin webinterface at: http://localhost/phpmyadmin

Visual Studio Code

sudo pacman -S code

Use your application

Make sure to restart the apache daemon after your configurations: systemctl restart httpd systemctl status httpd systemctl start httpd systemctl enable/disable httpd Open your browser and go to: http://localhost/yout-app-name

source ref

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment