Site admin not working after Moodle Migration

Site admin not working after Moodle Migration

by Binita P -
Number of replies: 23

I have duplicated Moodle environment to the same server as another instance.

And noticed all site administrator links are redirected to dashboard (/my).
Front page links(including courses) looks like working.


Tried removing cache folder. updating slash arguement to 0 through database based on some discussion forums.

But no difference.


Can anyone suggest a solution to?




Average of ratings: -
In reply to Binita P

Re: Site admin not working after Moodle Migration

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Moodle version?  Migration process?

In reply to Emma Richardson

Re: Site admin not working after Moodle Migration

by Binita P -

Hi,

Thanks for your reply.

My Moodle version is 3.1.5.

And followed the first one (Recommended method) for Migration.
https://docs.moodle.org/29/en/Moodle_migration

But mostly through Linux command prompt. so cp commands.


In reply to Binita P

Re: Site admin not working after Moodle Migration

by Ken Task -
Picture of Particularly helpful Moodlers

You can check what you did via usage of the history command.

As the root user, history  [ENTER]

will show all the commands issued recently and in the order in which they were executed.

Sorting stuff out might be a little difficult so I sometimes get lost and can't recall what I did so

history >  commandstrack.txt

Will create a commandstrack.txt file rather than displaying the history to the screen.

I then can open the commandstrack.txt file with a browser remotely IF I copy it to web root.   Then use the command line to correct my errant ways! ;)

If you'd like, you could edit the commandstrack.txt for just the commands you issued to clone the site to another directory and share back here for another set of eyes to inspect.

One thing that won't do is show any mysql commands you may have issued while inside the mysql> prompt nor any commands/actions you might have done in nano or other app.

'spirit of sharing', Ken


In reply to Ken Task

Re: Site admin not working after Moodle Migration

by Binita P -

Thanks Ken for looking into.

All I did was tar -cvf my full moodle folder on dev and move it to prod

Later on prod commands would be like

  • tar -xvf *.tar

  • cd moodle
    vi config.php 

  • service nginx restart
    service php-fpm restart

  • Tried clearing cache through command line as restarting server did not work
  • php admin/cli/purge_caches.php

  • Does this help?

In reply to Binita P

Re: Site admin not working after Moodle Migration

by Binita P -

Checked error log and got 

 *212 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: ******, server: myserver.ca, request: "GET /moodleroot/admin/settings.php?section=http HTTP/1.0", upstream: "fastcgi://unix:/var/run/php5-fpm.moodle.sock:", host: "myhost.ca"


Can this be an issue?

In reply to Binita P

Re: Site admin not working after Moodle Migration

by Ken Task -
Picture of Particularly helpful Moodlers

When sharing the commands like this where one was located makes a difference in how tar archives/creates the tar ball.   To be really informative one would have to look at commands issued before one tar balled "my full moodle folder'.   The way I interpret that indicates what had running on local host for development was insecure ... no biggy cause that package installed using localhost.   But move that to production serve one has to adjust knowing the differences.

So if you tar balled 'full moodle folder' ... did that moodle folder contain the moodledata directory?   Does that moodledata directory now reside in a place where one could use a browser to navigate directly to it without having to login to Moodle?   Example: http://myprodsite/moodle/moodledata/

In a migration, one also has to get a mysqldump of localhost moodle database, xfer the .sql file to the production server, edit the .sql dump file to search and replace for http://localhost/ replace with http://IPaddress/ and then import the edited .sql into a new/fresh database.

Also, like you show you did, edit the config.php file ... and in there there's more than the URL to the Moodle to change ... DB Host still local?  DB user?  DB password? Full path to moodledata? and at the bottom of that file, think it standard now to include a line or it has a line that says 'admin' is 'admin'.

'spirit of sharing', Ken


In reply to Ken Task

Re: Site admin not working after Moodle Migration

by Binita P -

My dev and prod websites are on the same server right now.

Just using different folders.

Yes, folder structure is exactly same so in root/moodle, root/moodledata.

Tried setting up full permission on both.


I did mysql search/replace. And checked that images are now referring to prod url.

In reply to Ken Task

Re: Site admin not working after Moodle Migration

by Binita P -

If this one helps.

Got some more detail i.e. even in site admin, I can access Manage courses, Manage grades etc.

The urls I found problematic are mostly /admin/... , /user/... 

In reply to Binita P

Re: Site admin not working after Moodle Migration

by Ken Task -
Picture of Particularly helpful Moodlers

is this line present in config.php?

$CFG->admin     = 'admin';

If not, add it.

'spirit of sharing', Ken


In reply to Ken Task

Re: Site admin not working after Moodle Migration

by Binita P -

Thanks Ken.


Checked out. $CFG->admin     = 'admin';  is already there in config.php

To check I added

print "index"; exit; line at the very beginning in admin/index.php 


Restarted nginx and php-fpm. 

Purged caches through command line. 

Looks like it is not reaching to this file at all. Instead goes to mysite.com/my

In reply to Binita P

Re: Site admin not working after Moodle Migration

by Binita P -

Hi ken,


Can you give me a hint to debug.

I am not working with Moodle. Just helping a guy to setup environment as webadmin

In reply to Binita P

Re: Site admin not working after Moodle Migration

by Ken Task -
Picture of Particularly helpful Moodlers

Assuming you can get there via Moodle UI as admin level user:

Site Admin menu -> Development -> Debugging

Set to 'Developer' and check the box that Displays ... but note what it says.

Afterwards reset the optons.

If cannot navigate the menus, try direct URL to the same area:

http://site/admin/settings.php?section=debugging

But note ... it has 'admin' i the URL.

Could be one is experiencing something at the server config level OR a network level ... filter?  Proxy?  Reverse Proxy?

But have you pursued what error you've shared?

https://www.google.com/search?q=FastCGI+sent+in+stderr%3A+%22Primary+script+unknown%22+while+reading+response+header+from+upstream&ie=utf-8&oe=utf-8

Finds quite a few ... which one is your?

If you are blocked from the URL above (the admin), then suggest installing an sos.html page in local directory of the code.

See: https://moodle.org/mod/forum/discuss.php?d=347811#p1403050

As explaned ... local/sos.html doesn't require login and gives direct links to admin areas one cannot reach via Moodle UI for some reason.   It is 'secure' in that all of the areas to which the sos.html file points does require admin level login to the Moodle.

Now one more for ya ... "setup environment as webadmin" is webadmin an app?  or is that your role in this?   We are on Linux?

'spirit of sharing', Ken


In reply to Ken Task

Re: Site admin not working after Moodle Migration

by Binita P -

That's where the issue is:

I cannot use direct url.

It rediects all to /my.

In reply to Binita P

Re: Site admin not working after Moodle Migration

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

What is the webroot listed as in your config.php file?

In reply to Binita P

Re: Site admin not working after Moodle Migration

by Ken Task -
Picture of Particularly helpful Moodlers

In the config-dist.php file, which is locate in the moodlecode directory and is well commented, you'll find lines to turn on debugging from the current config.php file.   Copy those lines to config.php.  Hit the site and let's see what it says.   As you know, those lines are case sensitive and also sensitive to ticks and ending ';' at each line.

Don't have to restart any services ... after the lines are added and config.php file is saved, the next hit via web brower, debugging is in affect.

Come back here and paste the text of what is shown ... if anything.

'spirit of sharing', Ken


In reply to Binita P

Re: Site admin not working after Moodle Migration

by Ken Task -
Picture of Particularly helpful Moodlers

So you cloned a site to another instance on the same server by a different FQDN.

That means separate DB, separate data directory, separate code directory.

They can't both be using the same FQDN so you must have had to do a config file for the cloned site in virtual apache configurations ... and maybe other configs for php-fmp or whatever.

The original site ... the one you cloned from, still works.

It's the cloned site running under a different FQDN on same server that's semi messed up ... any 'admin' link will not work.

Mind sharing what the file system looks like with focus on the two instances of Moodle?

Example:

FQDN1 - the moodle instance you cloned.

code: /var/www/html/

data: /var/www/moodledata

DB server: localhost

DB: fqdn1moodle

FQDN2 - the clone

code: /home/clone/html/

data: /home/clone/moodledata

DB server: localhost

DB: fqdn2moodle

Nothing is shared between them ...

DB server might be on localhost but the DB's are different.

In order for that to work there must be virtual apache configs for the virtual sites.

What do those look like?

Also ... any .htaccess files .... in any code directory?  When you tar balled the code directory of FQDN1 and it had an .htaccess file that same .htaccess file is in FQDN2.  Anything in the cloned .htaccess file that might cause this?

Any rewrite rules set for default virtual apache server?

Don't think that disclosing what operating system running is a security concern ... if anything, best to share with 'white hats' rather than let 'black hats' help you discover stuff.

Uhhh ... Emma and I do wear white hats! ;)

'spirit of sharing', Ken



In reply to Ken Task

Re: Site admin not working after Moodle Migration

by Binita P -

Hi Ken,


Our website is hosted on linux and using nginx.

So no .htaccess rewrite rules.

and nginx conf file is exactly same as dev server. With server and root changes only.

In reply to Binita P

Re: Site admin not working after Moodle Migration

by Ken Task -
Picture of Particularly helpful Moodlers

Ahhhh ... finally ... something new!   nginx.

Don't run nginx myself but ...

what does nginx -t show?  Might look at the online help for other switches.

The one showed is like apache's control command which checks config file for any syntax issues and there's switch for checking virtual server settings as well.

Surely nginx has such switches that might prove to be informative.

https://linux.die.net/man/8/nginx

-t' Don't run, just test the configuration file. The nginx checks configuration for correct syntax and then tries to open files referred in configuration.

That man page shows that nginx can be compiled for debugging as well.

set the debug level of the error_log:

error_log /path/to/log debug;

It is also possible to enable the debugging for some IP address:

events {

debug_connection 127.0.0.1;

}

might be better than the requested debugging output from config.php of the troubled moodle install.

Since we still don't now what Linux distro ... seLinux must not be in play.

Might bookmark/favorite this:
https://www.nginx.com/resources/wiki/?_ga=1.20166270.799570568.1490758030
The official wiki for nginx.

'spirit of sharing', Ken


In reply to Ken Task

Re: Site admin not working after Moodle Migration

by Binita P -

Thanks Ken.


I missed your comment enabling debugging with code from config-dist.php

Trying it now.


In reply to Binita P

Re: Site admin not working after Moodle Migration

by Binita P -

Thanks Ken and Emma for all your help.

We figured out the solution for.


This wasn't about Moodle configuration.

It was due to the proxy setting on our server.