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
(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
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
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
We can add this basic module here.
# epsi!
Include conf/extra/php_module.conf
You can have a look at the file, and compare.
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
And add this line using any text editor.
<?php phpinfo();
Don;t worry. I won’t push you to use Vim. You can use any text ediotr.
Browser
Now you can open your localhost.
And click into localhost/phpinfo.php.
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.