DNF Packages for WordPress on Linux 2023 Amazon EC2 AWS

DNF Packages for WordPress on Linux 2023 Amazon EC2 AWS

You will have previously done the basic Linux 2023 installation for disk swap space, “dnf check-release-update” etc.
The packages below may exclude mutt. I include for my own reference.
The packages for using Let’s Encrypt certbot are for those who are not using a paid SSL certificate.

Note: I use php-fpm as shown below. You do not need to if you wish, in which case, do not install it, or if you do, dnf remove it later, or simply do not enable it.

dnf install -y httpd httpd-tools mod_ssl 
dnf install -y php php-common php-pear wget php-mysqli php-devel php-mbstring
dnf install -y php-cli php-pdo php-fpm php-json php-mysqlnd php-opcache
dnf install -y gd libzip-devel httpd-devel kernel-devel php-gd postfix mutt
dnf install -y cronie cronie-anacron
dnf -y install pcre-devel gcc zlib zlib-devel
dnf -y install mariadb105
dnf -y install mariadb105-server
dnf -y install libjpeg-turbo-utils

[Install zip. When done, we edit the /etc/php.ini file.]

pecl install zip
pecl channel-update pecl.php.net


[Edit /etc/php.ini - after the Dynamic section - add "extension=zip.so;"]

vi /etc/php.ini
;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

extension=zip.so;

[save and exit]

usermod -a -G apache ec2-user

[Exit the shell login, and log back in as root]

chown -R ec2-user:apache /var/www
chmod 2775 /var/www && find /var/www -type d -exec sudo chmod 2775 {} \;
find /var/www -type f -exec sudo chmod 0664 {} \;
cd /var/www
chown apache html
chgrp apache html
chmod 2775 html

If intending to use Let’s Encrypt:

dnf install -y httpd httpd-tools mod_ssl 
dnf -y install python3 python3-devel augeas-libs
python3 -m venv /opt/certbot/
/opt/certbot/bin/pip install --upgrade pip
/opt/certbot/bin/pip install certbot certbot-apache
ln -s /opt/certbot/bin/certbot /usr/bin/certbot

We now edit some configuration files. You may have different values.

[Use your own timezone]

vi /etc/php.ini

date.timezone = Australia/Brisbane
max_execution_time = 300
max_input_time = 600
max_input_vars = 2500
post_max_size = 100M
upload_max_filesize = 100M
max_file_uploads = 20
memory_limit = 256M

[save and exit]

vi /etc/php.d/10-opcache.ini

opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=4000

[save and exit]

cd /etc/php-fpm.d
cp -p www.conf www.conf.o

[If using 256M in WordPress, we use 256 below]

[If using php-fpm:]

vi /etc/php-fpm.d/www.conf

; pm = dynamic
pm = ondemand
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.process_idle_timeout = 10s;
pm.max_requests = 500
php_admin_value[memory_limit] = 256M

[save and exit - there is a semicolon at the end of the timeout line above]

If you do not wish to use php-fpm, which works with php memory, we will simply disable it from starting up on a reboot, or do not install the package.