After migrating website no images working

After migrating website no images working

by mathan raj -
Number of replies: 22

Hello,

I have moved the website from windows server to a new linux server. After moving everything works but no images and videos are displaying under the courses.

Surfing the issue related solution i found several and tried all, but nothing works out.

1. slashargumnet - din't work.
2. replace all image url from development url to new url(replace.php). - didn't work.
3. clear cache - didnt work
4. Config settings fine

If i upload any new image then it is working, but the existing image throws error. What else am I missing?


Average of ratings: -
In reply to mathan raj

Re: After migrating website no images working

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

You have been pretty thorough in your research!  I think you have gone through all the basics..

Did you upgrade during the migration as well?  Or did you just migrate the whole site as is...?

Did you move the moodledata folder?  

Have you flushed the caches on your browser as well as the site?  Is it a hosted server?  

Try turning on theme developer mode and leave that on until you get it fixed (that makes you pull a new copy of each page each time you call for it but does slow site down).

In reply to Emma Richardson

Re: After migrating website no images working

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Hi Mathan

Compare your notes with the documentation https://docs.moodle.org/en/Moodle_migration. (It will jump to the latest, right now 3.0, version of Moodle. If yours is different, replace /30/ with your version.)

As Emma suspected, did you do an https://docs.moodle.org/en/Upgrading at the same time? That is never a good idea, because you will not know which step broke. Anyway, if you also upgraded, somehow it broke the https://docs.moodle.org/en/Repositories. For example, during a 1.9 > 2.x the dreaded https://docs.moodle.org/en/Legacy_course_files were created. Apart from that, I have no clue. I don't think you have Unix file permissions issue, since you can upload files. What are the URLs (the pattern) of those broken images?
In reply to Visvanath Ratnaweera

Re: After migrating website no images working

by mathan raj -

HI you can see here,

Image link:  http://moodle.physicsmodels.in/pluginfile.php/42/course/section/691/image-the%203%20equations%20of%20Motion-1.png


This may ask you to login.


http://moodle.physicsmodels.in

User: testinguser

pass: Testinguser_1


The above links seems to be loading the image, but it looks like some error also triggering and hence the image is broken.




In reply to Visvanath Ratnaweera

Re: After migrating website no images working

by Ajay Kumar -

 Hi Visvanath Ratnaweera,

 I have migrated the moodle 2.9 version from old server to new server . 

 Everything is working fine.. but course image,videos and other images are not displaying 

 I have changed the URL from /replace/index.php file also but did not get solution.

 Can you help me regarding this?

In reply to Emma Richardson

Re: After migrating website no images working

by mathan raj -

Did you upgrade during the migration as well?  Or did you just migrate the whole site as is...? - I just Migrated

Did you move the moodledata folder?  Yes it is moved

Have you flushed the caches on your browser as well as the site?  Is it a hosted server?  - yes couple of times - purched the cache and tried in different system to check the output.

Try turning on theme developer mode and leave that on until you get it fixed (that makes you pull a new copy of each page each time you call for it but does slow site down). - I m looking at this. Still no error triggered. If i enable the error reporting in my php.ini, the website showing just a number like 2015051100.09 which is version of moodle.


In reply to mathan raj

Re: After migrating website no images working

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

Ok, so is the moodledata in the same place in relation to your moodle folder.  Is the correct path shown in config.php?

Does the web user own the moodle and moodledata folders and are permissions correct?

Check the database as suggested...

In reply to Emma Richardson

Re: After migrating website no images working

by mathan raj -
HI, Yes they are available in database. In fact i moved the updated database from new server to old server and checked, those images are still appearing. No issues.

Is there any gd library required like imagemagick? or is there any other settings am i missing when migrating.
In reply to mathan raj

Re: After migrating website no images working

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

You might try manually deleting the cache folders in your moodledata folder.  There is a tmp one and a cache one. Check your php environment and make sure that all your php modules are present.

In reply to mathan raj

Re: After migrating website no images working

by Sam Stevens -

Linux file permissions?

Check the permissions on one of the new files you have added that is working and then set the others to match that.

Also check that all the database entries for a working file match (in format and what should be comparable) with one that isn't working.

In reply to mathan raj

Re: After migrating website no images working

by Ahmad Nasuha -

I have same problem...! after migrating website to new dedicated server, no old images working  (header, old profile picture, etc) and get notification: Cannot read file. Either the file does not exist or there is a permission problem. More information about this error.

I'm using moodle 2.6.3 and then upgraded to 3.0.3+ but the problem not fix

This my website

anyone can help me? thank's



In reply to Ahmad Nasuha

Re: After migrating website no images working

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

Have you checked ownership and permissions on your moodledata folder?  Have you cleared caches?

In reply to Emma Richardson

Re: After migrating website no images working

by Aashish Jha -

I’m in the same situation:  After having moved to a new server, 90% of the links (and 100% of the images and CSS) on my Moodle installation aren’t working anymore.


I did enable slash arguments, I did delete cache (via the admin login interface), I did run replace.php (as mentioned), and the Moodle config.php configuration is correctly set.  Also, I did NOT upgrade the Moodle version, I simply switched servers.  I did enable (presumably) appropriate permissions on the Moodledata folder, and of course the Moodle folder itself.


One thing I noticed however, the replace.php function doesn’t seem to be replacing anything, or at least, it’s not replacing what I want it to.  I know this because after successfully running the command at the command line, when I check the database references to the old URL are still there, unaffected.  At this point I’m not even sure if those DB entries are even the culprit, there are only 5 total entries that list the old URL.


So my main question is, what can I do to get my URLS (and thus images and css) to work?


My secondary question is, are most Moodle URLs/links being generated from information stored in the DB or from the Moodle Data folder?  If they are coming from the few references I see in the DB, could I perhaps manually insert/replace corrected entries into the DB?

Thanks for any help!


- Aashish

In reply to Aashish Jha

Re: After migrating website no images working

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

Right click on an image and then select copy image link.  Open a new tab and paste.  Look at the url.  Is it using the new domain name?  If so, then your database should be correct and it is probably a moodledata issue.  Is the moodle data folder location referenced correctly in config.php?

Did you apply permissions and ownership recursively?

In reply to Emma Richardson

Re: After migrating website no images working

by Aashish Jha -

When I inspect the links, they do still show the old URL.

I did confirm that the moodle data folder location is referenced correctly in config.php.

I also did confirm that permissions have been successfully applied recursively to both the Moodle folder and Moodle data folder.  For the moment I actually granted full 777 permissions to both locations.

For reference, the only places in the DB that have any references to the old URL are:

mdl_config table:

siteidentifier = SeeminglyRandomHash<OldURL>

chat_serverhost = <OldURL>

noreplyaddress = noreply@<OldURL>

mdl_config_log table:

chat_serverhost = <OldURL>

noreplyaddress = noreply@<OldURL>

Not sure if it matters but, for reference, there are (many) more places in Moodledata that have references to the old URL in:

/cache/

/lock/

/sessions/

Thank you!

In reply to Aashish Jha

Re: After migrating website no images working

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

You can actually delete the cache and the tmpcache folders in moodledata.  That should take care of that part.  They will be recreated automatically.

You did you update config.php to show the new url right?  I would think you must have to access the site at all.

Run the replace.php once more.  Maybe something did not run correctly there the first time.

Average of ratings: Useful (1)
In reply to Emma Richardson

Re: After migrating website no images working

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

I just realized that you said that you ran replace.php from the command line - I have never tried that.  Try running it from the browser.

Average of ratings: Useful (1)
In reply to Emma Richardson

Re: After migrating website no images working

by Aashish Jha -

Yes config.php shows the new URL.

Regarding replace.php, I've actually run it several times at this point, but strangely it hasn't updated those 5 references to the old URL.

Also, I can confirm that the function is indeed running when I try it because it displays all the hundreds (or thousands) of entries in the DB that it checks.

I've been contemplating manually updating those fields in the DB by using some sort of a 'REPLACE' SQL statement, however I'd prefer to do things the official (and presumably safer) way, especially since Moodle has the replace.php function built in.  Not sure why it's not working though.

In reply to Aashish Jha

Re: After migrating website no images working

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

The no reply stuff are coming from your email settings in Moodle so they will not affect anything.  If they are the only ones in the database with the old url but the images are still showing the old url, then it has to be caching.  Someone else said that turning off javascript caching fixed theirs.  Doesn't make a whole lot of sense to me but worth a try!

Average of ratings: Useful (1)
In reply to Emma Richardson

Re: After migrating website no images working

by Aashish Jha -

Just wanted to mention the root cause of the issue, it turned out to be the way our reverse proxy was set up - which wasn't where I was actually looking.  Once the configuration on that side of things was adjusted, everything worked.  Thanks all!

In reply to Emma Richardson

Re: After migrating website no images working

by Ajay Kumar -

Yes, I have cleared cache 

and permission for moodledata  is also correct ( 0777 or 0755 both are checked ) or is there any other permission i need to set?.

any other solution ?

In reply to Ajay Kumar

Re: After migrating website no images working

by Ken Task -
Picture of Particularly helpful Moodlers

The replace script you ran should have replaced all oldurl with newurl.   When you did the search and replace, how did you search and what did you use to replace?

Search should have been: 'http://oldurl/' replace should have been 'http://newurl/' ... note the inclusion of 'http://' in front and the inclusion of a trailing slash at the end ... '/'.

Also, wonder if the DB user, as defined in config.php, has priv's to do the search/replace?   The scripts in Moodle use the DB user, DB password from config.php but doesn't escalate a users access to do x/y/z.   Could it be that, in an effort to make Moodle more secure, config.php has a user in it that doesn't have full privs to the DB?

'spirit of sharing', Ken



In reply to Ken Task

Re: After migrating website no images working

by Ajay Kumar -

Hi,

  Already replaced url from admin panel. but still not working