Abstract
This is just a tutorial on how to do a LAMP stack manually on Arch Linux. Without further talks, let’s cut into this.
Setting Up
Install the required packages:
Note: You can find old versions of PHP in AUR
Configuring MariaDB
MariaDB is a reliable, high performance and full-featured database server which aims to be an ‘always Free, backward compatible, drop-in’ replacement of MySQL. Since 2013 MariaDB is Arch Linux’s default implementation of MySQL.
- To start configuring, run this command:
- Then enable and start
mariadb.service
by issuing this command:
- Log in as root user on the MySQL server by using the following command:
Note: Default root user has no password. Press enter to continue.
- Issue the command to create a user and grant the privileges:
Note: Change
your-name
with your desired username choices. Further informations can be referred from Arch Wiki MariaDB page.
Configuring PHP
PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. The main PHP configuration file is well documented and located at /etc/php/php.ini
. In order to make PHP work with MariaDB, uncomment the following lines in /etc/php/php.ini
:
Note: the extension
iconv
is to be uncommented to avoid an error in PHP8 regarding the extension itself. Further informations can be reffered from Arch Wiki PHP page.
Configuring Apache
The Apache HTTP Server, or Apache for short, is a very popular web server, developed by the Apache Software Foundation. Apache configuration files are located in /etc/httpd/conf
. The main configuration file is /etc/httpd/conf/httpd.conf
, which includes various other configuration files. The default configuration file should be fine for a simple setup. By default, it will serve the directory /srv/http
to anyone who visits your website. You can start Apache by running sudo systemctl enable --now httpd.service
. To configure Apache to work with PHP, we’ll be using the libphp
method:
- Comment the line in
/etc/httpd/conf/httpd.conf
:
- Uncomment the line:
Note: The above is required, because libphp.so included with the package does not work with mod_mpm_event, but will only work mod_mpm_prefork instead.
- To enable PHP, add these lines to
/etc/httpd/conf/httpd.conf
:
- Place this at the end of the
LoadModule
list:
- Place this at the end of the
Include
list:
- Restart
httpd.service
by issuingsudo systemctl restart httpd.service
command.Note: This method is probably the easiest, but is also the least scalable: it is suitable for a light request load. It also requires you to change the mpm module, which may cause problems with other extensions (e.g. it is not compatible with HTTP2). For further readings, refer to Arch Wiki Apache page.
Configuring phpMyAdmin
phpMyAdmin is a free and open source administration tool for MySQL and MariaDB. As a portable web application written primarily in PHP, it has become one of the most popular MySQL administration tools, especially for web hosting services.
- Create the Apache configuration file in
/etc/httpd/conf/extra/phpmyadmin.conf
:
- Include the file in
/etc/httpd/conf/httpd.conf
:
- To allow the usage of the phpMyAdmin setup script (e.g. http://localhost/phpmyadmin/setup), make sure
/usr/share/webapps/phpMyAdmin
is writable for the http user:
- Add
blowfish_secret
passphrase (You can search a generator for one) in/usr/share/webapps/phpMyAdmin/config.inc.php
:
- In
/usr/share/webapps/phpMyAdmin/config.inc.php
, uncomment and change them correspondingly to the ones you set in MariaDB configuration (your-name
andyour-pass
):
- Execute
mysql -u root -p < /usr/share/webapps/phpMyAdmin/sql/create_tables.sql
in the command line to create the required tables. - Remove temporary configuration directory once configuration is done:
- Restart the
httpd.service
again just for additional measures. For further readings, refer to Arch Wiki phpMyAdmin page.
Finishing
Open http://localhost/phpmyadmin/index.php and login to see if everything works well.
Sources
- Arch Wiki. https://wiki.archlinux.org/.
- Wikipedia. https://en.wikipedia.org/.