Install a minimum CentOS 9 Stream on a cloud based service or install it on your own server
Here we will use dnf install / update instead of yum install / update as dnf is the newer and better software package manager than yum.
Edit host file and change the host name to your server's host name:
You may need to restart network manager for the host changes to take affect:
Check your Apache install configuration:
Configure firewall to allow HTTP and HTTPS access:
Edit MPM module configuration:
I prefer mpm event module, so I edit mpm module configuration file and comment out mpm worker to disable mpm worker:
#LoadModule mpm_worker_module modules/mod_mpm_worker.so
And uncomment mpm event to enable mpm event:
LoadModule mpm_event_module modules/mod_mpm_event.so
I use below configuration for mpm event module. This configuration is for a server or a cloud that has about 8 core CPU and 64 GB RAM allocated to Apache. This configuration may not work for all scenarios so use this configuration at your own risk and monitor and test your Apache if you decide to use below configuration:
KeepAlive On KeepAliveTimeout 5 MaxKeepAliveRequests 300 TimeOut 60 <IfModule mpm_event_module> StartServers 8 ServerLimit 20 ThreadsPerChild 50 MinSpareThreads 500 MaxSpareThreads 750 ThreadLimit 64 MaxRequestWorkers 1000 MaxConnectionsPerChild 10000 </IfModule>
Restart Apache so the changes takes affect:
The default dnf install php on CentOS 9 Stream installs PHP 8.0. If you want to install a different PHP version, then you can use REMI Repository to install a different version of PHP.
Special Situation when you need to install a different version of PHP; you can use REMI Repository
For other PHP versions - examples: # dnf --enablerepo=remi install php56 # dnf --enablerepo=remi install php71 # dnf --enablerepo=remi install php73 # dnf --enablerepo=remi install php74
Edit www.conf
Update the www.conf to below configuration
; listen = 127.0.0.1:9000 listen = /var/run/php-fpm/www.sock listen.owner = apache listen.group = apache listen.mode = 0660
Edit php.conf:
And update the php.conf with below configurations
# # Redirect to local php-fpm (no mod_php in default configuration) # <IfModule !mod_php5.c> <IfModule !mod_php7.c> # Enable http authorization headers SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1 <FilesMatch \.(php|phar)$> SetHandler "proxy:unix:/var/run/php-fpm/www.sock|fcgi://localhost" </FilesMatch> </IfModule> </IfModule>
Edit PHP-FPM connection settings:
I use below configuration for PHP-FPM connections settings. This configuration is for a server or a cloud that has about 8 core CPU and 64 GB RAM allocated to PHP-FPM. This configuration may not work for all scenarios so use this configuration at your own risk and monitor and test your Apache if you decide to use below configuration
pm = static pm.max_children = 500 pm.max_requests = 8000
Start and Enable PHP-FPM
In my opinion, MariaDB is a better version of MySQL, so I install MariaDB:
Use below command to secure your MariaDB installation: