Hi all,
I'm trying to setup Moodle 3.1 locally on my FreeBSD box for testing purposes, and to familiarize myself with it.
I installed via the FreeBSD ports collection. However, I've chosen to use Moodle, Nginx, MySQL and PHP56 (not apache). I'm new to Moodle, and hosting in general so I may have done something stupid.
Below, I will detail the steps I've taken, and show what my config files contain. But first let me show the problem; When I navigate to the locally hosted Moodle installation (localhost), I get the following message:
404 Not Found
nginx/1.10.1
Here are the installation options.
LDAP=off: LDAP protocol support MIMETEX=off: mimeTeX filter functionality support ====> Options available for the single BACKEND: you have to select exactly one of them MYSQL=on: MySQL database support PGSQL=off: PostgreSQL database support MSSQL=off: Microsoft SQL Server support
Then I installed and configured nginx using THIS PAGE. The results were as expected, according to the page. Navigating to "localhost" brings up the Nginx welcome page, and the php test page work fine. So far, so good.
Then I followed THIS GUIDE to set up nginx with Moodle.
Then I followed THIS GUIDE to set up MySQL and Moodle.
Now when I navigate to 'localhost' in my browser, I get the "404" error message, as described above.
However, when I change moodle config.php settings to use the default username / password combo, IE:
$CFG->dbuser = 'username' ;
$CFG->dbpass = 'password' ;
I get the following message from Moodle:
Error: Database connection failed
It is possible that the database is overloaded or otherwise not running properly.
The site administrator should also check that the database details have been correctly specified in config.php
I don't understand what is happening here.
Here are the (I think) relevant contents of my config files:
nginx.conf:
server { listen 80; server_name localhost ; root /usr/local/www/moodle; index index.php index.html index.htm; location / { # First attempt to serve request as file try_files $uri $uri/index.php; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ [^/]\.php(/|$) { fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { return 404; } #free to choose between port or sock file. #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_index index.php; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location /dataroot/ { internal; alias /usr/local/moodledata/ ; } }
Here is my Moodle config.php
<?php
$CFG = new stdClass();
$CFG->dbtype = 'mysqli'; // 'pgsql', 'mariadb', 'mysqli', 'mssql', 'sqlsrv' or 'oci'
$CFG->dblibrary = 'native'; // 'native' only at the moment
$CFG->dbhost = 'localhost'; // eg 'localhost' or 'db.isp.com' or IP
$CFG->dbname = 'moodle'; // database name, eg moodle
$CFG->dbuser = 'moodleuser'; // your database username
$CFG->dbpass = 'MYPASSWD'; // your database password
$CFG->prefix = 'mdl_'; // prefix to use for all table names
$CFG->dboptions = array(
'dbpersist' => false, // should persistent database connections be
// used? set to 'false' for the most stable
// setting, 'true' can improve performance
// sometimes
'dbsocket' => false, // should connection via UNIX socket be used?
// if you set it to 'true' or custom path
// here set dbhost to 'localhost',
// (please note mysql is always using socket
// if dbhost is 'localhost' - if you need
// local port connection use '127.0.0.1')
'dbport' => '', // the TCP port number to use when connecting
// to the server. keep empty string for the
// default port
);
$CFG->wwwroot = 'localhost';
$CFG->dataroot = '/usr/local/moodledata';
$CFG->directorypermissions = 02777;
$CFG->admin = 'admin';
$CFG->xsendfile = 'X-Accel-Redirect'; // Nginx {@see http://wiki.nginx.org/XSendfile
$CFG->xsendfilealiases = array(
'/dataroot/' => $CFG->dataroot,
);
Does anyone know what is going on? Or can anyone provide me with a useful link so I can work it out?