Skip to content

Instantly share code, notes, and snippets.

@stealingudc
Last active May 20, 2024 17:50
Show Gist options
  • Save stealingudc/d44b89da0aa69ea47c171b9368108828 to your computer and use it in GitHub Desktop.
Save stealingudc/d44b89da0aa69ea47c171b9368108828 to your computer and use it in GitHub Desktop.
Setting up a LAMP stack development environment with Arch Linux

Setting up a LAMP stack development environment with Arch Linux

This guide assumes that you're developing an app on Arch, not that you're running a server.

If you're looking to run a server on Arch Linux, then you've got bigger problems than this.

Linus Torvalds have mercy on your soul.

1. Install base packages

Install PHP, Apache and MariaDB

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

OPTIONAL, but useful: Install Composer for PHP

$ sudo pacman -S composer

2. Apache settings for PHP

  • Append following lines to /etc/httpd/conf/httpd.conf:
LoadModule php_module modules/libphp.so
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

Note: Make sure you comment out or delete other mpm modules. Otherwise, the Apache server won't start due to module conflicts.

  • Also append to /etc/httpd/conf/httpd.conf:
<Directory "absolute/path/to/project/root">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
    DirectoryIndex index.php
</Directory>
  • OPTIONAL: Set global directory index for any Apache server, just in case.
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

3. Create a user for your MariaDB server

Creating a user is as simple as:

$ sudo systemctl start mariadb.service
$ mariadb

Then, using basic MySQL:

MariaDB> CREATE USER 'my-cool-user'@'localhost' IDENTIFIED BY 'my-cool-password';

Don't use "my-cool-password".

4. Get apache-pwd

Instructions on how to get apache-pwd can be found at the original repo.

<sarcasm> Props to the repo owner, he's such a cool guy! </sarcasm>

5. Run your server

Go into your project directory, ./apache-pwd [port] and see the magic unfold.

Good luck and may your code-nerves be of steel.

6. OPTIONAL: Install phpMyAdmin

When it comes to installing phpMyAdmin, you have two choices:

  • The Arch Linux way: cloning the repo. If you're going this route, you probably know how to do it. (repo)
  • The Mentally Stable way: Using Composer. This requires you to have installed Composer in Step 1.

For the sake of this gist, we'll go with the Option B.

Go to your project directory and run composer create-project phpmyadmin/phpmyadmin. This will create a "phpmyadmin" directory in your project root, which you can then access at localhost:[port]/phpmyadmin/.

Log in with the user you created in Step 3 and have fun!

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