0

I am trying to install moodle in my centos system. everything works fine untill I try to access http://localhost/moodle/install.php.

Instead of running the script the entire script is displayed on the screen. Can you please tell me where am I going wrong? However other scripts are displayed correctly. I have not altered install.php in any way.

2 Answers2

1

What happens when you run http://localhost/moodle/index.php (instead of install.php)?

Have you tried manually setting up your Moodle config.php file? If not, make a copy of the config-dist.php file in your Moodle folder and rename it to config.php (replacing any existing config.php file you might have).

Then edit that new config.php in a text editor and fill in all the config settings, like $CFG->dbhost, $CFG->dbname, $CFG->wwwroot and $CFG->dataroot.

When that's done save the config.php file and run http://localhost/moodle/index.php again. What happens now?

luisdev
  • 558
  • 7
  • 22
  • thx for the answer. when i've done that, the index file shows up in text, but the php does not run. any ideas where to search now? – BenKoshy Jan 17 '16 at 03:12
  • 1
    Try deleting your Moodle config.php file (back it up first). Then open http://localhost/moodle/index.php. What happens? – luisdev Jan 19 '16 at 11:32
  • 1
    When a PHP file shows up as text in the web browser it normally means that there's something wrong with your PHP/Apache configuration. Apache isn't processing the .php scripts/pages correctly. What happens when you run a .php file containing just the phpinfo() command? – luisdev Jan 19 '16 at 11:35
  • i ran this command but all it did was display it in text form. nothing else happened. and when i deleted the moodle config file, all it seemed to do was to display index.php in the text form. any advice? – BenKoshy Jan 19 '16 at 23:40
  • Seems like there's something with your PHP setup then. Check /etc/httpd/conf.d/php.conf and /etc/httpd/conf/httpd.conf to see if any of them contains the lines: "AddHandler php5-script .php" and "AddType text/html .php". If not, your Apache isn't handling .php scripts correctly and you need to fix that. – luisdev Jan 22 '16 at 15:59
  • luis you've been a huge help! i've fixed the problem. it turns out that the the .php file was missing it's ?> closing bracket. your suggestion that I use the phpinfo() command demonstrated that the PHP/apache configuration was working so i realised that there was a problem with the actual config file itself. somehow or other, the closing bracket was deleted. I added it in and -- VOILA moodle now works! you solved it all without me knowing any php or apache :) – BenKoshy Jan 25 '16 at 21:16
  • Mmm. It's interesting that it's working now, considering that the Moodle config.php should NOT have that closing PHP tag. – luisdev Jan 27 '16 at 16:19
  • Hello Luis, my apologies, there was no closing tag in the INDEX.php file -- I have now added one in there. i accidentally said "config.php" instead of index.php - which was what i really meant. Is a closing bracket required for the index.php file? do you know where I can download a sample copy of the index.php file as it should be? – BenKoshy Jan 27 '16 at 22:06
  • None of the Moodle .php files have the PHP closing tags (apparently "it prevents trailing whitespace problems" - see: http://stackoverflow.com/questions/4410704/why-would-one-omit-the-close-tag), So adding the closing tags is not the right way to fix this. There's something wrong with your Apache config... Have a look at these links and check your config according to the recommendations: http://stackoverflow.com/questions/5121495/php-code-is-not-being-executed-i-can-see-it-on-source-code-of-page http://stackoverflow.com/questions/12142172/apache-shows-php-code-instead-of-executing – luisdev Jan 29 '16 at 06:49
0

you should install libapache2-mod-php to enable apache to run php scripts.

sudo apt install php libapache2-mod-phplib
Simas Joneliunas
  • 2,890
  • 20
  • 28
  • 35