And some more ...
And another thought ... when migrating, one usually does NOT migrate a old cPanel to a new environment. One migrates only a site backup of moodle.
From command line an in production moodle code location, issue:
ps aux |grep php
The 'darling' setup now for more modern OS's is php-fpm.
The 503 error is a gateway error and could be coming from a php-fpm setup that needs tweaking upwards. php-fpm does use a gateway.
What you should see is something like:
root 1114 0.0 0.1 470460 37004 ? Ss Mar28 0:26 php-fpm: master process (/etc/opt/remi/php82/php-fpm.conf)
apache 1674 0.0 0.5 549400 166516 ? S Mar28 4:03 php-fpm: pool www
apache 1675 0.0 0.5 549928 163288 ? S Mar28 4:06 php-fpm: pool www
apache 1676 0.0 0.5 549456 166660 ? S Mar28 4:07 php-fpm: pool www
apache 1677 0.0 0.5 494160 183624 ? S Mar28 4:08 php-fpm: pool www
apache 1680 0.0 0.5 549744 163020 ? S Mar28 4:03 php-fpm: pool www
apache 12502 0.0 0.4 475836 153856 ? S Mar28 4:13 php-fpm: pool www
apache 12749 0.0 0.4 549468 162044 ? S Mar28 4:13 php-fpm: pool www
apache 116759 0.0 0.4 477832 154220 ? S Mar28 4:00 php-fpm: pool www
apache 453553 0.0 0.5 555504 170928 ? S Mar29 3:26 php-fpm: pool www
apache 633036 0.0 0.4 549820 160352 ? S Mar30 2:55 php-fpm: pool www
your path to the master php-fpm.conf file would be different.
cd your path and then ls
You should see something like:
opt php.d php-fpm.conf php-fpm.d php.ini pki pm skel sysconfig X11 xdg xinetd.d
At the bottom of php-fpm.conf, you might need to add php tweaks upwards. Example from one of my severs:
php_admin_value[max_input_vars] = 6000
php_admin_value[memory_limit] = 256Mphp
php_admin_value[post_max_size] = 256M
php_admin_value[upload_max_filesize] = 256M
php_admin_value[max_execution_time] = 90
php_admin_value[max_input_time] = 120
You probably do not have those in yours.
Also, there is a conf file for php-fpm pool which points to a www.conf file. That's another area of php tweaks you need to investigate.
If you do make tweaks, the php-fpm process needs to be restarted.
systemctl reload php-fpm
systemctl status php-fpm
You can test the setup:
/opt/remi/php82/root/usr/sbin/php-fpm -tt
your path to php-fpm would be different than in above example.
And, you've a 'moodle march' ahead ... 3.8 is very very old and to 'march' the moodle upwards will require changing PHP version the domain runs under just before an update of moodle code to a higher version. Suggest, when you do regain access to the admin side of that moodle, going to Server -> Environment check and update the component.
And consulting the moodle releases site for versions higher than 3.8 to see what is required during the march.
One last ... by far the best way to update/maintain a moodle is using git versioning. Might be well worth your time to get your current 3.8 under git versioning first - which would result in an upgrade to the highest 3.8 available.
https://docs.moodle.org/501/en/Git_for_Administrators
Not sure I'd take the sites all the way to 5.1 ... might stop at 4.5.highest for now. 5.1 involves a restructuring of moodle code/files that's 'different'. And you might want to practice that on your DEV system first ... that's why it's important to be able to control php version and setup per domains on your server.
My more than 2 cents.
'SoS', Ken