Lamp Server - Almalinux
Notes
- Make sure almalinux is updated to latest version
- Either disable selinux now or suffer... (you can also learn how to live with it)
1) HTTPD Installation:
dnf install httpd
Enable and start it
systemctl enable httpd && systemctl start httpd
Make sure it up (optional)
systemctl status httpd
2) Mariadb Installation:
Right now, mariadb 10.6 is the latest version, but the default install gives you 10.3, so install the latest like this:
create repo for mariadb 10.6
vim /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.6/rhel8-amd64
module_hotfixes=1
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Run dnf update to make sure the os sees the repo
dnf update
Install MariaDb
dnf install mariadb-server mariadb
Start and Enable it
systemctl enable mariadb && systemctl start mariadb
Secure the installation
run mariadb-secure-installation and follow the on-screen instructions
3) PHP Installation
Install REMI repo
dnf install http://rpms.remirepo.net/enterprise/remi-release-8.rpm
List the available versions:
dnf module list php
Reset the default(which is 7.2)
dnf module reset php
Select the php version you need (7.4 here)
dnf module enable php:remi-7.4
Install the php
dnf install php74 php74-php-fpm -y
Enable and start the FPM service
systemctl start php74-php-fpm && systemctl enable php74-php-fpm
4) Virtualhost Config
Create relevant directories
mkdir -p /var/www/vhosts/DOMAIN_NAME/httpdocs
mkdir -p /var/www/vhosts/DOMAIN_NAME/logs
cd /var/www/vhosts/DOMAIN_NAME/logs
touch error.log access.log
cd /etc/httpd/conf.d/
mkdir php_conf && cd php_conf
Create php config
vim php74.conf
<IfModule !mod_php7.c>
<FilesMatch \.(php|phar)$>
SetHandler "proxy:unix:/var/opt/remi/php74/run/php-fpm/www.sock|fcgi://localhost"
</FilesMatch>
</IfModule>
Create the VirtualHost and Copy the content
vim DOMAIN_NAME.conf
<VirtualHost *:80>
ServerAdmin hpc@tau.ac.il
ServerName hpc-zabbix.tau.ac.il
DocumentRoot /var/www/vhosts/hpc-zabbix.tau.ac.il/httpdocs
### php conf start ###
Include /etc/httpd/conf.d/php_conf/php74.conf
### php conf end ###
<Directory /var/www/vhosts/hpc-zabbix.tau.ac.il/httpdocs/>
Require all granted
</Directory>
ErrorLog /var/www/vhosts/hpc-zabbix.tau.ac.il/logs/error.log
CustomLog /var/www/vhosts/hpc-zabbix.tau.ac.il/logs/access.log combined
</VirtualHost>
5) Make sure php error get written to custom log
cd /etc/opt/remi/php74/
vim php.ini
#If you want to set error log by host
[HOST=www.example.com]
error_log=/var/www/myapplication/path/to/my/error.log
[HOST=sub.example.com]
error_log=/var/www/mysubapplication/path/to/my/error.log
#If you want to set error log by path (handy if you're working on a server with an IP address but no domain)
[PATH=/var/www/myapplication]
error_log=/var/www/myapplication/path/to/my/error.log
[PATH=/var/www/mysubapplication]
error_log=/var/www/mysubapplication/path/to/my/error.log
Now go to:
cd /etc/opt/remi/php74/php-fpm.d/
In that directory, edit the file www.conf. Note the values for user and group in that file, whose out-of-the-box setting is www-data for both. Look for the term catch_workers_output and make sure it is uncommented and set to yes, like so:
catch_workers_output = yes
systemctl restart php74-php-fpm