Where to Discuss?

Local Group

Preface

Goal: Setting-up LAMP stack with Artix OpenRC. Configure the Apache + PHP tier.


Install PHP Packages

We do not need any other service handler. But we need to tie the apache with php.

  • php
  • php-apache
❯ sudo pacman -S php php-apache
resolving dependencies...
looking for conflicting packages...

Packages (2) php-8.2.4-1  php-apache-8.2.4-1

Total Installed Size:  41.00 MiB

:: Proceed with installation? [Y/n] y

LAMP OpenRC: PHP: Install PHP Packages

(2/2) checking keys in keyring                    
(2/2) checking package integrity                  
(2/2) loading package files                       
(2/2) checking for file conflicts                 
(2/2) checking available disk space               
:: Processing package changes...
(1/2) installing php                              
(2/2) installing php-apache 

LAMP OpenRC: PHP: Install PHP Packages


Configure PHP Library

This is not a PHP configuration. But rather talk about a HTTPD configuration.

The php library name has changed from time to time. I can find the name of this php library here.

❯ ls /usr/lib/httpd/modules | grep php
libphp.so

For my basic usage, I mostly use this configuration.

# epsi!

LoadModule mpm_prefork_module modules/mod_mpm_prefork.so
LoadModule php_module modules/libphp.so
LoadModule rewrite_module modules/mod_rewrite.so

LAMP OpenRC: PHP: Configure PHP Library

Configure PHP Module

Since we need to take care different sites. We need to manage which modules to be added to HTTPD.

❯ ls /etc/httpd/conf/extra/
httpd-autoindex.conf  httpd-languages.conf	     httpd-ssl.conf	 phpmyadmin.conf
httpd-dav.conf	      httpd-manual.conf		     httpd-userdir.conf  proxy-html.conf
httpd-default.conf    httpd-mpm.conf		     httpd-vhosts.conf
httpd-info.conf       httpd-multilang-errordoc.conf  php_module.conf

LAMP OpenRC: PHP: Configure PHP Module

We can add this basic module here.

# epsi!
Include conf/extra/php_module.conf

LAMP OpenRC: PHP:

You can have a look at the file, and compare.

LAMP OpenRC: PHP:

I think it is definitely easier than my last 2015 article. Just one line, and the PHP just up and running.


PHP Info

Again, test!

How I would I know that PHP works?

I like the idea to use phpinfo() in my localhost. But be aware that using this in production is bad bad idea, as it leads to security holes, when somebody know what’s inside your machine.

Consider make a script in www directory. This www directory might be different, for different linux distribution

❯ sudo touch /srv/http/phpinfo.php

LAMP OpenRC: PHP: PHP Info

And add this line using any text editor.

<?php phpinfo();

LAMP OpenRC: PHP: PHP Info

Don;t worry. I won’t push you to use Vim. You can use any text ediotr.

Browser

Now you can open your localhost.

LAMP OpenRC: PHP: Browser

And click into localhost/phpinfo.php.

LAMP OpenRC: PHP: Browser

It works perfectly. At least on my machine.


What is Next 🤔?

Finally what we need. A tools to manage our database.

Consider continue reading [ LAMP - PHPMyAdmin ].

Thank you for reading.