I installed moodle on ubuntu server. I successfully installed the moodle using the wizard on www.example.com
. below are my moodle.conf
and config.php
<?php // Moodle configuration file
unset($CFG);
global $CFG;
$CFG = new stdClass();
$CFG->dbtype = 'pgsql';
$CFG->dblibrary = 'native';
$CFG->dbhost = 'localhost';
$CFG->dbname = 'moodle';
$CFG->dbuser = 'moodleuser';
$CFG->dbpass = 'password';
$CFG->prefix = 'mdl_';
$CFG->dboptions = array (
'dbpersist' => 0,
'dbport' => 5432,
'dbsocket' => '',
);
$CFG->wwwroot = 'https://www.example.com';
$CFG->dataroot = '/var/www/moodledata';
$CFG->admin = 'admin';
$CFG->directorypermissions = 0777;
require_once(__DIR__ . '/lib/setup.php');
for nginx moodle.conf
upstream php-handler {
server unix:/run/php/php-fpm.sock;
}
server {
server_name example.com www.example.com;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
add_header X-Content-Type-Options nosniff;
resolver_timeout 5s;
root /var/www/moodle;
rewrite ^/(.*.php)(/)(.*)$ /$1?file=/$3 last;
location ^~ / {
try_files $uri $uri/ /index.php?q=$request_uri;
index index.php index.html index.htm;
location ~ .php$ {
include fastcgi.conf;
fastcgi_pass php-handler;
}
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = example.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name example.com www.example.com;
listen 80 default_server;
return 404; # managed by Certbot
}
my site is running on example.com
. I want to run it on example.com/moodle
. When i change the $CFG->wwwroot
to example.com/moodle
i get too_many_redirects
error. how to fix it
question from:
https://stackoverflow.com/questions/65863359/how-to-change-moodle-url 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…