Where to Discuss?

Local Group

Preface

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


Install Apache Packages

Just like any other service in OpenRC, we need both packages, and the init package.

  • apache
  • apache-openrc
❯ sudo pacman -S apache apache-openrc
warning: apache-2.4.56-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (2) apache-2.4.56-1
             apache-openrc-20210505-2

Total Installed Size:  6.47 MiB
Net Upgrade Size:      0.01 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               

LAMP OpenRC: Apache: Install Apache Packages

As usual, pay attention to the message below:

:: Processing package changes...
(1/2) reinstalling apache                         
(2/2) installing apache-openrc                    
:: Running post-transaction hooks...
(1/2) Creating temporary files...
(2/2) Displaying openrc service help ...
	==> Add a service to runlevel:
	rc-update add <service> <runlevel>
	==> Start/stop/restart a service:
	rc-service <service> <start/stop/restart>

LAMP OpenRC: Apache: Install Apache Packages


Running Service

For OpenRC we have this two commands:

  • rc-update,
  • rc-service
❯ sudo rc-update add httpd default
 * service httpd added to runlevel default

LAMP OpenRC: Apache: Running Service

❯ sudo rc-service httpd status
 * status: stopped
❯ sudo rc-service httpd start
httpd             | * Starting httpd ...        [ ok ]
❯ sudo rc-service httpd status
 * status: crashed

LAMP OpenRC: Apache: Running Service

Woat? It crashed.

CURL

Strange, that it works, even though the init say it crashed. And I still don’t know why.

❯ curl http://localhost
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
 <head>
  <title>Index of /</title>
 </head>
 <body>
<h1>Index of /</h1>
  <table>
   <tr><th valign="top"><img src="/icons/blank.gif" alt="[ICO]"></th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>
   <tr><th colspan="5"><hr></th></tr>
   <tr><th colspan="5"><hr></th></tr>
</table>
</body></html>
~ 

LAMP OpenRC: Apache: CURL localhost

You can also pipe the output to vim as curl http://localhost | vim -R -.


Configure HTTPD

You might have a situation where you find this server’s fully qualified domain name error.

❯ sudo rc-service httpd start
httpd             | * Caching service dependencies ...                                                  [ ok ]
httpd             | * Starting httpd ...
httpd             |AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
httpd             |httpd (pid 5849) already running 

We just need to add Servername in confgiuration.

# epsi!
ServerName localhost

LAMP OpenRC: Apache: Configure HTTPD


Browser

How I would I know that Apache works in localhost?

Consider have a look at how the web server response goes in browser.

LAMP OpenRC: Apache: Browser

This web server works well.


What is Next 🤔?

We can contiune our tier to PHP.

Consider continue reading [ LAMP - PHP Setup ].

Thank you for reading.