i finally make it to work, i test it on a virtual machine with:
nginx version: nginx/1.10.0
PHP 7.1.6
mysql Ver 14.14 Distrib 5.7.18
To the nginx default file i add this:
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location /dataroot/ {
internal;
alias /var/www/moodledata/; # ensure the path ends with /
}
To the config.php file of moodle i added this:
$CFG->xsendfile = 'X-Accel-Redirect';
$CFG->xsendfilealiases = array(
'/dataroot/' => $CFG->dataroot
);
This is how my default nginx file looks like:
Server block:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
}
location /dataroot/ {
internal;
alias /var/www/moodledata/; # ensure the path ends with /
}
try_files $uri $uri/ /index.php?args;
}
And this is the moodle config.php file:
<?php
unset($CFG); // Ignore this line
global $CFG; // This is necessary here for PHPUnit execution
$CFG = new stdClass();
$CFG->dbtype = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'dbusername';
$CFG->dbpass = 'dbpassword';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array(
'dbpersist' => 0,
'dbsocket' => '',
'dbport' => 3306,
'dbhandlesoptions' => false,
'dbcollation' => 'utf8mb4_general_ci',
);
$CFG->wwwroot = 'http://localhost/moodle';
$CFG->dataroot = '/var/www/moodledata';
$CFG->directorypermissions = 0777;
$CFG->admin = 'admin';
$CFG->xsendfile = 'X-Accel-Redirect';
$CFG->xsendfilealiases = array(
'/dataroot/' => $CFG->dataroot
);
require_once(__DIR__ . '/lib/setup.php'); // Do not edit
I did not modified the php.ini file. or the www.conf of php.
Here is the page where i got the info:
To configure nginx and moodles config.php file:
https://docs.moodle.org/33/en/Nginx#XSendfile_aka_X-Accel-Redirect
When install PHP i do recomend to install these modules:
sudo apt-get install php7.1-fpm php7.1-mysql php7.1-common php7.1-cgi php7.1-curl php7.1-cli php7.1-dev php7.1-gd php7.1-gmp php7.1-xml php7.1-xmlrpc php7.1-zip php7.1-xls php7.1-opcache php7.1-mbstring php7.1-soap php7.1-intl graphviz aspell php7.1-pspell php7.1-ldap