I tried to install Moodle on my LEMP 3 times but the site could not work.
In this time, it show blank page and I deleted 2 cache folders in moodledata folder but It show another error page that is 500.
I have read some topics on the forum and Mr. Ken Task (SOS Ken) also gave me advised but I just walked few steps.
Could someone that figured out the thing on LEMP (CENTOS & NGINX) please tell me what to do to solf the problem!
My server is a VPS RAM 4GB (CENTOS 7 x64, OPcache PHP 7.3.33, Nginx, MariaDB 10.3)
Domain on Cloudflase Nameserver, I don't use SSL.
All I surfed bellow:
At first I install Moodle on GUI but I met this error https://docs.moodle.org/400/en/error/admin/installhijacked
Then I turn off turned of Proxy mode and add my local IP to Databse (Table mdl_user, Lastip) and It moved me to another error bellow.
.../user/editadvanced.php?id=2 with no way to type password for admin account on GUI.
Then I deleted all and started to intall new Moodle on CLI way, all steps following https://docs.moodle.org/400/en/Installing_Moodle
- Add domain to vps, it's automaticly located in default ~/home/ and it has folder ~/home/domain.com/public_html
- Create new blank database.
# mkdir /home/domain.com/moodledata
# chmod 0777 /home/domain.com/moodledata
Then download Moodle from moodle.org to my computer and upload to ~/home/domain.com/public_html through SFTP
I use CLI to unzip then move all folders and files in 'moodle' folder to ~/home/domain.com/public_html/
I delete the empty 'moodle' folder.
# chown -R root /home/domain.com/public_html/
# chmod -R 0755 /home/domain.com/public_html/
# chown apache /home/domain.com/public_html/
# cd /home/domain.com/public_html/admin/cli
# sudo -u apache /usr/bin/php install.php
I type apache 2 CLI command above because my VPS set Centos with Nginx as Moodle direction on the link above.
It take 2 minutest to install, while that it ask me to put some infomation and I answer:
Database: localhost, mariadb, dabasenam, databaseUser, Password
Website address, I type a subdomain like this http://abc.domain.com (it nameservered in cloud flare that I turn off DNS proxy mode already)
Moodledata: /home/domain.com/moodledata
Email and passowrd of admin
I skiped Database port and Unix rocket because I dont know.
After the terminal tell me install successed then I did one more CLI command bellow
chown -R root /home/domain.com/public_html/
Then I go to browser to access the site, it shows me a blank page, nothing to click.
Then I found a topic the tell me to delete 2 cache folders in the folder moodledata but it went to error 500.
I appreciate to someones could help this problem!!!
You are still having trouble at the web server or DNS or network level. To convince your self create an arbitrary test.html file in your Moodle code directory and visit yoursite/test.html. The page should display. Once that is OK create a phpinfo.php file in the same place and visit yoursite/phpinfo.php. The phpinfo.php file needs to have this single line:
<?php phpinfo(); ?>
So, you need to start with https://docs.moodle.org/400/en/Debugging, raised to DEVELOPER level.
More basic: Your config.php is readable to the web server and its $CFG->webroot is set to exactly your site's URL, right?
Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
Nginx configuration is also a possible cause. See https://docs.moodle.org/en/Nginx. Or the dreaded "slasharguments" https://moodle.org/mod/forum/discuss.php?d=438185#p1763855.
I followed the link https://docs.moodle.org/en/Nginx
security.limit_extensions = .php .php3 .php4 .php5
Edited: security.limit_extensions = .php
Then run two cli bellow but nothing change.
systemctl start php-fpm.service
systemctl enable php-fpm.service
I continued to add these two codes bellow respectively to /etc/nginx/nginx.conf
Then I run
systemctl start nginx systemctl enable nginx
Nothing happened.
Then the rest content of the page I dont understand what to do, I am not a coder, just newbie learner to use so I get stuck at this.

Must I use https or http to use Moodle?
i browse http://mysite.com/admin/purgecaches.php it led me to login page .../login/index.php and asked me to type username and password to login. When I click to login, it went back to page .../my with plane text as photo above that shown me I loged.
Was trying to get you directly to the script that would purge all caches instead of providing menu navigations ... so we'll do menu navigations ..
Login - go to Site Administration Menu - Development - Purge Caches
On the Purge Caches screen, purge all.
When the theme doesn't display correctly, it could be an indication you have not setup the cron job for your server. That is done outside of the moodle admin interface.
See: https://docs.moodle.org/400/en/Cron
Yes, it is advised your site run under https - lock in front of the browser url bar is shown without a red line through lock icon.
If you've not gotten a certificate for your server to run it https, please see:
https://docs.moodle.org/400/en/Transitioning_to_HTTPS
'SoS', Ken
Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
I followed dirrection from https://docs.moodle.org/400/en/Cron
I run CLi bellow and it show Cron successfull, correctly
$ /usr/bin/php /path/to/moodle/admin/cli/cron.php
Then I move to the next step in the dirrection of the link is

I run $ crontab -u apache -e
* * * * * /usr/bin/php /path/to/moodle/admin/cli/cron.php >/dev/null
Then Press ESC, then type :wq that exit the black blank screen.
I dit not know I did the right thing or not but the result the same. Moreover, it move to another error for the the whole server that all the sites host in this server are facing with Error Code 521
Could you please tell me what to do to restore to the privious state and what to do for right method?!
Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
In moodle docs, things like '/path/to/moodle/' are not literals but variables you replace according to your own server environment.
So if you just copied and pasted from those docs, then for your server environment those are incorrect.
Sorry, but if you did this:
"I run CLi bellow and it show Cron successfull, correctly
$ /usr/bin/php /path/to/moodle/admin/cli/cron.php"
NO WAY!!!! No linux system has /path/to/!!!!
Now you need to find where your moodle code is ... the /path/to/ moodlecode ... you replace /path/to/ with your servers environment true location of moodle code.
Also, sometimes docs are written for particular operating systems ... you need to be aware if those docs are written for ubuntu or centOS or Other. The 'www-data' user and group ownerships is what ubuntu uses ... CentOS uses 'apache' user/group or userlogin/userlogin depending upon if hosting is shared hosting and how the web service is setup and configured. For shared hosting consult hosting docs. For a remotely hosted VPS and you have root access and using /var/www/html as 'apache' document root then paths/ownerships/permissions are all related.
All this time you say you have CentOS ... well let's find out:
Login to server however you do that, and type: uname -an [PRESS THE ENTER KEY]
What does that command show?
To find out the full path to where the moodle code is, all I can tell you to is login to the site and use cd to change directories until you end up where you can see the moodle code. Once you arrive there, type: pwd [PRESS THE ENTER KEY]
That pwd command will show the full path to where you are located.
The cron job then is that full path with /admin/cli/ added to the path and of course the script for the cron job, which is cron.php
'SoS', Ken
Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
My moodlecode in the url like this, I just keep domain private as abc.com
/home/abc.com/public_html/admin/cli
I did CLI command:
/usr/bin/php /home/abc.com/public_html/admin/cli/cron.php

Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
About the only file one can/might edit is the config.php file at the root of moodle code. Yes, you can open files to look at it's contents, but be very careful that you don't errantly add something to the file.
First we've heard that this VPS server is serving multiple apps ... maybe even domains/subdomains ... and first we've heard about a wordpress too!
/home/[a domain]/public_html/ is something not mentioned before either.
Running of a cron job for a moodle shouldn't cause a server to throw an error 512! Neither should the execution of web based purging of cache.
Volunteers here in forums can only provide accurate fixes to issues if given accurate info about the server.
So is server still throwing 512 errors? To be honest, I have never experienced a 512 error before ... am wondering if it's an extension error code for nginx. Can't seem to find any specific information about that error!
Tip: if you are going to edit a file, make a backup of that file first. I for one, cannot tell you what was originally in a file on your server. So if, by mistake, you wipe out a file you were editing and it now contains nothing or errant lines ... ??????
Appears you are using the VI editor ... not very user friendly ... normally one can use another editor on CentOS machines called 'nano' ... it's a true text editor - commandline only.
And one more question, please ... where, with what hosting provider, is this server hosted?
'SoS', Ken
Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
In this time, I browse all the sites hosted in the VPS is getting Error code 521. All of them are using Cloudflare too.
I am using a VPS from Ethernerservers. com, the VPS is blank, and I choos Cent OS 7 to install.
$ uname -an
--> Result: Linux RAM4GB 3.10.0 #1 SMP Tue Jan 25 12:49:12 MSK 2022 x86_64 x86_64 x86_64 GNU/Linux
Then I install the rest of LEMP through a script bellow
$ curl -sO https://hocvps.com/install && bash install
The scrip also told that will support to CENTOS 7&8 and latest Webserver Nginx
While running the script option, I chose Database MariaDB 10.3, PHP7.4 include ZEND OPcache
When finish install LEMP through the script, I add domain that show the folder tree bellow.
I download Moodle-4.0.4.tar.gz to [public_html] then extract thour tar -zxvf to
[public_html]$ /usr/bin/php /home/
Following the direction https://docs.moodle.org/400/en/Cron
I run
...
I install nano editor
$ yum install nano
I added the code through SFPT while Command editor not fammiliar for me yet.
In this time, should I reinstall the VPS again or which can fix it?
Or if you also supply custom service to community, please tell me! I ask for help from local forum but no one there for long time.
Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
uname -an
--> Result: Linux RAM4GB 3.10.0 #1 SMP Tue Jan 25 12:49:12 MSK
Hmmmm ... what does:
cat /etc/redhat-release`
show?
How does your auto install script you are using:
HocVPS Script Installer v1.5
install web service/php/mysql or mariadb? or do you do that?
Any reason you are choosing lightspeed?
To edit the crontab file using Nano editor, you can optionally enter the EDITOR=nano crontab -e command
https://hocvps.com/install
FireFox shows warning ... NOT SECURE. Certificate expired.
Acquired via command line, install looks interesting ...
looks like it gets a basic Linux platform of your choice ... but I saw no apache/php/db in the script. You are doing that yourself?
What are you asking here ...
Or if you also supply custom service to community, please tell me! I ask for help from local forum but no one there for long time.
IF there is someone who can login to your server and install?
Would be difficult for anyone who doesn't at least read french!
You did say you had a wordpress already ... on same server? You'd want to keep that, would you not?
Ethernerservers.com ... do they not offer support for customers? This problem has gone beyond just moodle.
'SoS', Ken
Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
$ cat /etc/redhat-release
--> Result: CentOS Linux Release 7.9.2009 (core)
The script is automatic helping people like me to install Nginx, MariaDB and PHP with out knowing about CLI.
When I run installing the script it will offer me to choose which versions of MariaDB and PHP to install that I chose MariaDB 10.3 and PHP 7.4. I just need to choose the options and automaticly installing, I dont know how to install them manually.
Any reason you are choosing lightspeed?
Which is lightspeed?! I use the script because at first I did not know about CLI Command, and It help me to add new domain, new database with a short command that I just need to type 'hocvps'. When I type 'hocvps' then it show me options to add new website with Wordpress so I believe that suit for me at first. The developer also offer free charge but these days all comments from his blog is off.
I think now I have learned basic CLI, know how to add database and I have to learn more, but till be unconfident to install LEMP manually by myself.
EnthernetServer do have custom VPS service but this time I am here because Moodle and I would focus in it. I need to challenge with Moodle and also till keep Wordpress. I could read English so I have no reason to use local language version. Could you help me to set VPS specialize in Moodle, also suport for WP?
Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
If you going to host anything on internet then trouble shooting skills will be necessary. So stop and think a minute ... you had moodle running, but wasn't rendering as it should, originally you did not use https, and you had not setup a cron job.
In your attempt to setup the cron job is when everything broke.
So ... without starting over again, where do you think you need to focus your efforts to get the site viewable again even though not rendering correctly?
Time to learn how to fish rather than being fed fish!
https://docs.moodle.org/400/en/Cron
'SoS', Ken
Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
Some simple cli ...
Issued a command but can't remember what you issued?
history
You edited a file with nano, but can't remember the name of the file you edited:
history |grep nano
Senario - you are going to edit my.cnf for MariaDB/MySQL - before you edit, make a backup:
cp my.cnf my20221005.cnf
now nano my.cnf
Want to change a lines value?
Make note of original value in case you change your mind later by commenting out the original line and adding the new line with different value:
# innodb_buffer_pool_size=4G
innodb_buffer_pool_size=2G
Later, you want to see what original file had in comparison with your edited my.cnf
diff my.cnf my20221005.cnf
You know the name of a config file, but don't know where it is:
whereis php.conf
use systemctl to get status of service
/bin/systemctl status httpd.service
/bin/systemctl status mysqld.service
Same for restarting a service after change to config files.
'SoS', Ken
Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
Then Centminmod and an PHPFINO extention that make my Moodle site work now.
I really appreciate your help and your advices, Mr Ken SOS!
Moreover, I also understand why experts here always use Nano editor instead of sftp edit that because Nginx safty protocol, I think.
Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Trả lời: Re: Error installing Moodle on CENTOS NGINX
Welcome! and Congrats!
Your journey begins!
To me, "Centminmod" translates as CentOS Minimal and Apache as a mod?
Still CentOS 7? If so, circle on your calendar this date: June 30, 2024. On that date CentOS 7 reaches end of life ... no more fixes/patches/updates to the OS + those things that make moodle run.
Don't forget to setup cron job!
So what did you end up with?
yum repolist
php -v
mysql -V
df -h
cd /path/to/moodlecode/
fgrep '$release' version.php
while there in moodle code directory:
php admin/cli/checks.php
And some things to look into (in 'learning to fish' mode):
multitail, webmin, logwatch
for maintaining your moodle, git
'SoS', Ken