migrating to new host

migrating to new host

by RF Stewart -
Number of replies: 26
I have decided that siteground.com superpackage for moodlehosting is not adequate for a classroom with 25 students all logging in at once form our school computer lab. I am a public school teacher trying to provide supplemental learning experiences through my moodle site. They suggest upgrading to $89.95/month from $5.95/month, for services I was led to expect from the affordable superpackage. I have, instead, hired another host VPS package with great expectations and additional expenses. I have read everything I can find on moodle forums and documentation but am still beating my head against the wall to migrate my site with 17 courses to this new host.
I have tried a new install of moodle 1.8 but cannot get it to recognize my courses in the uploaddata file. It remains a blank shell of a new install.
I have tried a .zip total backup of the original site. I have transferred the URL name and MySQL dabase but get the following error:

Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(/home/xyzzer/public_html/learn/lib/setup.php) is not within the allowed path(s): (/home/xyzzer5:/usr/lib/php:/usr/local/lib/php:/tmp) in /home/xyzzer5/public_html/learn/config.php on line 22

Warning: require_once(/home/xyzzer/public_html/learn/lib/setup.php) [function.require-once]: failed to open stream: Operation not permitted in /home/xyzzer5/public_html/learn/config.php on line 22

Fatal error: require_once() [function.require]: Failed opening required '/home/xyzzer/public_html/learn/lib/setup.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/xyzzer5/public_html/learn/config.php on line 22

It seems so simple when I read the forum posts and docs, but I have no expericence with php and server applications. My host tech support is not experienced with moodle migration either.
What can I do to put the pieces back together again?
Average of ratings: -
In reply to RF Stewart

Re: migrating to new host

by James Shamard -

I have moved my site several times and frequently export the production database to a development site where we try new things first to insure they do not blow up the production site.

Use your PhpMyAdmin and export your database (in an SQL format) and using PhpMyAdmain on the new server (without a moodle database) import the database.It will build the database and tables and bring all content and most settings.

I would be happy to provide detail about how to export and import if needed. i know some tricks to make it quick and easy.

js

In reply to James Shamard

Re: migrating to new host

by Mark Hilliard -
James,
I am trying to do the same thing, (i.e. move copy of a production Moodle to a test Moodle) and would very much appreciate any tips/suggestions you could pass on on best way to do this...)

We have been trying to export the MySQL db from one site and restore it to another server. We also copied the courses folders with all the uploads.

But I am still seeing bad links to files etc. Is this because Moodle keeps URL's with web addresses pointing to the original server?

If you have any suggestions/tips or can point to forums-discussions that address this it would be greatly appreciated!!

Mark
In reply to Mark Hilliard

Re: migrating to new host

by Just H -
Hi Mark

For better or worse, links to uploaded files within moodle are absolute.

If you go to www.your_site/admin/replace.php you can do a search and replace for the old URL.

Do a backup first and test thoroughly afterwards to make sure everything is OK.

Regards
H
In reply to James Shamard

Re: migrating to new host

by RF Stewart -
James,
Thank you for your generous offer and guidance. I'm stumbling in the dark and trying to understand a foreign tongue when it comes to servers, databases, etc. I have unzipped my website and moved my database. The database was about 30MB so it took some time. I revised the config.php manually to point to this database. I get the following error:

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


There is something I have overlooked. Any guidance would be appreciated.
In reply to RF Stewart

Re: migrating to new host

by Richard Enison -

RFS,

With all due respect to JS, who has undoubtedly migrated infinitely many more times than I (any positive number is infinitely bigger than zero! smile), from your error msgs. it looks like your problem has nothing to do with your database but with file and folder (directory) permissions. Specifically:

  1. Are you (or your host) operating php in safe mode? See http://docs.moodle.org/en/Installing_Moodle#Requirements under Software, PHP scripting language, PHP settings.
  2. Do you have write access to the active php.ini file (see http://docs.moodle.org/en/phpinfo if you don't know which is the active one)? If not, get down on your knees and beg with tears and sackloth for your web host to comment out the open_basedir setting or add the appropriate folders to the list (pick a folder higher in the hierarchy than both the main moodle folder and the data folder if possible; if not, add both). (It can also be an Apache setting.) Which brings me to:
  3. Is your main moodle folder /home/xyzzer/public_html or /home/xyzzer5/public_html? It looks like you have some files in one and some in the other, or else you left out the 5 or put it in by mistake in answering the installation script questionnaire.
  4. Make sure all the file and folder permissions (chmod) and ownerships (chown) are correct. http://docs.moodle.org/en/Installing_Moodle#Creating_the_data_directory_.28moodledata.29 deals with the data folder, but obviously you need at least read permission (and write, for generating html forms and javascript etc., not to mention the generation of config.php by install.php) to the Moodle folder.

RLE

In reply to Richard Enison

Re: migrating to new host

by RF Stewart -
Thank you RLE for your attention to detail and thoughtful response. These are all things that I need to pay careful attention to.
#1 yes, the host has confirmed that safe_mode is off.
#2 I'm still lost. I don't see a php.ini file or recognize active. The link provided does not help me. Perhaps you could give me more direction here.
#3 the 5 of course, was added in the new installation. The site I'm transferring from did not use it. I fixed that in the config.php file. Wow! Hooray! the errors I posted have gone away. Thank you.
This error has taken its place, however.

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


#4 permission allow read, write and execute.

I found an error in the database. The original file is ten times the size of the one that migrated. I can't explain it. I uploaded the larger .sql file using phpMyAdmin. It took some time but arrived. I created a new database and changed the config.php accordingly. I still get the same error. If my database dump is corrupted along the way, how would I know?
Your continued coaching is very much appreciated.
In reply to RF Stewart

Re: migrating to new host

by Richard Enison -

RFS,

#1. Let's hope the host is correct about safe mode.

#2. Since you are using a web host, you probably don't have access to php.ini. But at this point, you don't have to worry about it since the original errors have gone away.

#3. I had a hunch those errors would go away when you took care of that 5!

#4. Same as #2.

Now, I'm a little confused by your comments about the database dump. You said the original sql file was 30MB, and the one you uploaded to the new host is only 3MB? Or have you gotten past that problem, because you said "it took some time, but it arrived"? What did? The original 30MB file? If not, at what point did it drop in size -- from the old host to your computer, or from your computer to the new host? Most hosts back up their servers. If worse comes to worse, maybe you could get a new backup file from them. Make sure it is the right type:a sql file. Describe to them how you made it, to make sure they make the right file.

One way to tell if a file has been corrupted in transit is to use error detection codes, also known as authentication codes. This is a number that is calculated from the original file before it is sent, and calculated again from the file after you receive it. If the numbers are the same, it is almost certainly unchanged, if a good authentication code algorithm is used, such as md5. But if the size is different, you already know it is not the same! But if the original is lost, it is too late to find out what the code was for it unless you can get the old host to recreate it, or unless the code was already included in the file itself. I'll look into that.

Anyway, a corrupt sql file would not have anything to do with the database connection error. It would only result in a change in the content of the database after you restore it. Moodle can't even see that content until it connects to it. This is probably due to giving the Moodle installation script the wrong database parameters, such as database host. Ask your host what should be specified for that. Also, the docs have a FAQ on this error: http://docs.moodle.org/en/Installation_FAQ#Error:_database_connection_failed Many of the things it tells you to check are under control of your new host, so you'll have to ask them.

RLE

EDIT: PS. Here's a post that might help you deal with those huge database dump files: http://moodle.org/mod/forum/discuss.php?d=13889#p68244. Still looking into the codes.

In reply to Richard Enison

Re: migrating to new host

by Richard Enison -

RFS,

I ran a dump of my Moodle database using mysqldump. I did not see any error-detection code in it. I don't know whether phpMyAdmin creates one; this program does not have detailed docs online; you have to buy a book. That's why I am not using it.

RLE

In reply to Richard Enison

Re: migrating to new host

by RF Stewart -

RLE

Sorry about the ambiguous language concerning my transfer of the database. As I looked more closely at the database on my new site and the original site I noticed a big difference. The first database I installed was 3MB while the original was nearly 30MB. I scrapped the 3MB database and performed the upload again, completing the establishment of the 30MB file. At this point the size of the database looks consistent with the original. It gets confusing about the size of files when you zip; extract; transfer, etc. I wish there was a direct route from server to server that would relieve the step and transfer time through my desktop. The last time I switched hosting companies, the transfer was performed by the host and I never skipped a beat. This time its up to me and the generosity of strangers. Fortunately I have not completely abandoned my former recalcitrant host. All of my files and databases are in tact. I switched the URL names so that my new host is the original URL. My HTML front-page is in place waiting to link forward into the moodle classroom.


You mention a moodle installation script. When I install a new moodle program it has a welcome/setup dialog. As an established, transferred site I don’t trigger a welcome/setup dialog. Is there a way to trigger this installation script with my transferred site? Would that connect the database properly? Maybe you could look at my config.php file and see if there is a brazen error.

I will check out your suggested links and get back with you.

In reply to RF Stewart

Re: migrating to new host

by Richard Enison -

RFS,

Yes, there is a way of invoking the installation script (your URL/install.php), but it is probably not a good idea to run it now that your Moodle site is already installed. In fact, I think that if you tried it, it would automatically redirect to your home page.

As for a direct server-to-server transfer, that is possible, depending on what s/w your new host has made available to you. Last year I got involved with Moodle because I was hired to install it by someone who had his own server. On that server, which I accessed remotely from my home PC, there was a piece of s/w called Webmin that was similar to cPanel. One of the functions it had was downloading, whereby you could download files from other servers. I don't know whether cPanel has that, or whether your host has either one, but they probably have something similar. And even if they don't have a Download button in their control panel, if you have telnet or better still, ssh (a secure version of telnet), whereby you can type operating system commands and have them executed, you could use that to invoke a web browser or wget to download files from anywhere on the Internet.

RLE

In reply to Richard Enison

Re: migrating to new host

by RF Stewart -
I haven't made any progress with my database connection yet. I keep bouncing back and forth with this forum and my hosting company tech support. I changed the database password so that it doesn't contain any numbers since that was one of the suggestions. Nothing has changed, I still get the error posted above. Is there any other file that should be modified other than the config.php?
Could you look at the config.php file to see if there is anything that looks suspicious? I have removed the real username and password.

<?php

unset ( $CFG ) ;

$CFG->dbtype = 'mysql' ;
$CFG->dbhost = 'localhost' ;
$CFG->dbname = 'xyzzer5_moodledata' ;
$CFG->dbuser = '****' ;
$CFG->dbpass = '****';
$CFG->dbpersist = false;
$CFG->prefix = 'mdl_';

$CFG->wwwroot = 'http://www.xyzzer.org/learn' ;
$CFG->dirroot = '/home/xyzzer5/public_html/learn' ;
$CFG->dataroot = '/home/xyzzer5/public_html/learn/uploaddata' ;
$CFG->admin = 'admin' ;

$CFG->directorypermissions = 00777 ;

$CFG->unicodedb = true ;

require_once ( "$CFG->dirroot/lib/setup.php" ) ;

?>


In reply to RF Stewart

Re: migrating to new host

by Richard Enison -

RFS,

You have said you have gone back and forth between consulting the forum and your host's tech support, but you haven't said you looked at the FAQ I linked to in my previous post. Have you tried the things it suggested doing? Have you followed any links in it that might apply?

What version of MySQL are you using? What version of PHP? Some hosts require using a different database host designation from localhost. Have you asked tech support about that? Are you sure the database name, user, and p/w are correct? Are you able to access your database with phpMyAdmin or other MySQL client program using them? Have you run the phpinfo script (see http://docs.moodle.org/en/phpinfo) to verify you have the PHP extensions for MySQL installed?

RLE

In reply to Richard Enison

Re: migrating to new host

by RF Stewart -
RLE,
Thank you for your patience. This has been an uphill battle for me given my inexperience with the server side of life. I have read your posts and followed those links. The faq was helpful. My host technician checked settings and versions of MySQL and PHP.
We have at last unravelled the mystery of database access. I set up the database with a username and password. I changed the config.php accordingly. What I didn't realize was that the real username and password had the prefix xyzzer5_ appended. So what was happening, I told moodle to look for database username: 'myname' when it really needed to look for username: xyzzer5_myname'.
Thank you again for your guidance. You have helped lead me out of the darkness and restored my hope.
Now I have to figure out why my moodle site doesn't recognize my administrative login.
In reply to RF Stewart

Re: migrating to new host

by Richard Enison -

RFS,

Your welcome. I'm glad you've gotten past another problem (by my count, that's the second one this thread). (EDIT: Frankly, I was not surprised it prepended your account name to the database name and user name, but I was surprised that it did to your password (p/w).) Now, about the admin login problem:

Just for laughs (because this forum is riddled with people having the same problem for lots of different reasons), can you use phpMyAdmin to look at the record (row) in mdl_user where the username field (column) is admin? First, make sure the auth field says manual. If you are using some external method of authentication like ldap, I can't help you. The default is manual, which is what I am using. Then look at the password field. You should see a jumble of hexadecimal digits (that is, the digits 0 through 9 and the letters a through f). What you need to do is apply the md5 function to your password and compare the result to that. One way to do that is to run a SQL query:

SELECT md5('your p/w');

Another way would be to create a PHP script; call it jumble.php or whatever you want to call it; and its content would be:

<?php echo md5('your p/w'); ?>

Save it in your main Moodle folder, where config.php and install.php are. Make sure your web server is running and type into your browser

http://YourMoodleURL/jumble.php

If you do not get a perfect match, Moodle does not have your password. In that case, you can take the hexadecimal jumble you just created, and put it into the password field in the admin record of mdl_user; or, you can use a feature of phpMyAdmin (so I'm told; I don't use the program myself) whereby you can enter the password itself into the field, and click a drop-down button and select md5 from the drop-down list.

HTH

RLE

PS In case you're wondering how I would do that without using phpMyAdmin: I use the mysql client program. I would run the following query:

UPDATE mdl_user SET password=md5('my p/w') WHERE username='admin';

EDIT: I don't actually type the SQL keywords in all caps like that. I just do that in forum posts to make the queries easier to read and understand. That goes for the SELECT query earlier in this post as well.

In reply to Richard Enison

Re: migrating to new host

by RF Stewart -
Well, that was fun. I never tried navigating a database before. I found my username and password, ran the PHP script, md5, and got the identical match you predicted. The auth field says manual. I also edited the password and applied the md5, with the same hexadecimal code as the result. I didnot find the admin record for mdl_usr, however. This is an interesting education and exploration but I have not made any progress.
By the way, you were correct (again), the prepended username was accompanied by the normal, solitary password.
In reply to RF Stewart

Re: migrating to new host

by Richard Enison -

RFS,

OK. The fact that there is no record in mdl_user with username admin explains why you cannot login as admin. But you said you found your username and password (md5-crypted) in the table. Maybe that is the admin user. Try logging in using that username and see if you have admin privileges. If not, we might be able to fix that, although I'm not sure why that would be necessary. One of the last things the installation script asks you for (or gives you, I'm not sure which; memory escapes) is the admin password. I also don't remember whether it gives you a choice of admin username as well.

RLE

In reply to Richard Enison

Re: migrating to new host

by RF Stewart -
As it happens, I cannot login as anyone. I have also registered as a student with a separate username and password. During the original setup I chose my own administrative username and password. When I found that username and password in the database it was listed as the third entry. It should have been the first entry. There was no entry number one. I changed the entry number of my login to #1 thinking that it should be in that position. I read in one of the posts that #1 was the default for admin. This change did not give me access, however. I have just requested that my host double check the functions of the database server.
In reply to RF Stewart

Re: migrating to new host

by Richard Enison -

RFS,

I don't know whether you misunderstood the post you read, or the post was wrong, but it doesn't matter what the id of your record in the mdl_user table is. In mine, id number 1 is guest and 2 is admin; and I guarantee you logging in as guest does not give you administrator privileges. Changing the id in that record could make things worse, so I would suggest changing it back. 

Now if you had said that you can log in but you don't have administrator privileges, I believe I can help you fix that. But if you can't log in at all, offhand I don't know what is causing that. I don't think it is a problem with the database server, unless you're getting database connection errors. As I said before there seem to be many problems that can cause login failure, based on the posts I've seen. Do a search of the forum for the word login and you'll see what I mean.

What happens when you try to log in? Do you get an error msg.?

RLE

In reply to Richard Enison

Re: migrating to new host

by RF Stewart -
RLE,
When I login there is a pause of several seconds before returning to the site home page. The login page always says, 'Your session has timed out. Please login again.'

Is there another strategy I should try. I have moved my site in two pieces, the site itself and the database. Our discussion to reconnect them has lasted over a week. I am grateful for every bit of advice. But maybe there is another approach I could try. If I install a new moodle site first, is it possible to use course backups to recover the various parts of the site? I can easily reenroll my students. Their previous work is of little concern. I just need the courses recovered that I have created over the previous year.
In reply to RF Stewart

Re: migrating to new host

by Richard Enison -

RFS,

Yes, it is my understanding that restoring course backups is equivalent to restoring the data directory and the database. But without knowing what is causing your login problem, I cannot guarantee that if you restore the course backups you won't still have the same problem.

In the meantime, why not try just one more tiny thing. Could you verify that you have cookies enabled in your browser; and then delete the cookies, and try again?

RLE

In reply to Richard Enison

Re: migrating to new host

by RF Stewart -
RLE,
I'm always willing to try. I have removed old cookies and enabled cookies using IE, Firefox, and Opera. No improvement. I'm curious why it tells me that I have timed out even when cookies are removed.
In reply to Richard Enison

Re: migrating to new host

by RF Stewart -
I have checked cookies as you suggest with no change in behavior.
I looked at the MySQL database again and noticed that the column "Collation" lists latin1_swedish_ci.
Does that sound right?
In reply to RF Stewart

Re: migrating to new host

by Richard Enison -

RFS,

  1. No, it doesn't sound right. Moodle 1.8 requires the database to use character code UTF-8. I hope you are not with BlueHost or HostMonster. If you are, look at http://tracker.moodle.org/browse/MDL-11743 to find out why they are absolutely incompatible with Moodle 1.8.
  2. Otherwise, this might help. I have been looking over past forum posts reporting the same login problem as you are having. The things that have been suggested or actually tried, successfully, are:
  3. making sure the Moodle data folder is owned by the Apache user and has adequate permissions (like 755 or more);
  4. checking your php.ini for the correct value of session.save_path;
  5. deleting the sessions folder in your data folder;
  6. or if you are using dbsessions, empty the table mdl_sessions2.
  7. Programs frequently give you error msgs. that are inaccurate. Programmers write code that tests certain conditions and assume that those conditions only occur for certain reasons, so they have them display or print error msgs. that tell you things that aren't true, like your session has timed out or your browser does not have cookies enabled. The above conditions (paragraphs #3 through #6) have been reported in this forum to cause Moodle to report, incorrectly, that the session has timed out.

RLE

In reply to Richard Enison

Re: migrating to new host

by RF Stewart -

RLE,

  1. I host with webintellects.com. I’m learning that selecting a host is complicated business.
  2. I’ve been looking through the forum also but sometimes have difficulty with the non-linear format, thanks for gleaning relevant content.
  3. The default permissions on my folders is 755. By data folder, is that the one called ‘uploaddata’? I have no idea what you mean by “owned by the Apache user”. The table mdl_sessions is empty.
  4. I don’t think I have access to php.ini.
  5. Deleting the sessions folder gives me an error that the sessions folder cannot be found, and simply emptying the folder has no effect on my login status. It still says ‘Your session has timed out.’
  6. The table mdl_sessions2 is also empty.
  7. When my car’s ‘check engine’ light comes on, it doesn’t necessarily mean that there is a problem with the engine. It only means that someone needs to check under the hood.

Since I have reached a dead end here I would like to consider uninstalling and starting over fresh with the migration or install a new moodle and import my courses. Would you advise me on this next step?

In reply to RF Stewart

Re: migrating to new host

by Richard Enison -

RFS,

  1. I'm not familiar with that host.
  2. Moodle forums have a drop down list box that let you control how posts are presented: nested (the default, which is my choice), threaded, flat with newest first, flat with oldest first. Frankly, I'm not sure what the difference is between nested and threaded. Try each, see which you like best.
  3. Uploaddata is the name Fantisco (which I think is anything but fantastic) gives to it. The standard example name for it in the docs is moodledata, which is what I use. You can call it MarkTwain if you want, it doesn't care. Now almost two weeks ago, in my first post in this discusison, I suggested checking file permissions and ownerships, and you didn't ask me what I meant by ownerships, so I presume you know what file ownership means. So when you say you have no idea what I mean by "owned by the Apache user", I presume your question is about the Apache user, not ownership. The apache user is the operating system (Linux, Unix, etc.) user name Apache runs as. If you launch Apache while you are logged on as anyone but root, Apache runs as you, which is not too useful because you probably don't have enough permissions for Apache to do its job. But if you launch Apache as root, then Apache runs as the user specified in its configuration file, httpd.conf, usually apache or nobody. Since you are using a web host, you probably don't have access to that file, so you can ask tech support what user Apache runs as.
  4. You're probably right, but you can set php settings with .htaccess, if your host allows it.
  5. OK
  6. OK
  7. Exactly my point.

If you are asking me whether to start over with the migration or do a new install and import, what's the difference? I guess you mean whether you should restore a site backup or use course backups. As I said before, the two should be equivalent. If you have a lot of courses, restoring course backups could be cumbersome. Other than that ...

My main advice at this point is don't use Fantastico. Follow the instructions in the docs. Watch the videos (Eric Hagley's video on installation using cPanel without Fantastico is linked to from the Moodle Installation doc page(http://docs.moodle.org/en/Installing_Moodle), third paragraph; Jeff Woods' videos are at moodledemo.org). Be sure your database is Unicode.

RLE

In reply to RF Stewart

Re: migrating to new host

by Just H -
Do you have shell access on both servers?

If so, you can do a direct transfer with a couple of commands. Assuming starting from scratch on a clean server:

1 On your new server, create an empty database for Moodle then login to shell on your old server using putty or your tool of choice.

2 To move your database, execute the following command replacing the parts in capitals with your details:

mysqldump --allow-keywords --opt -uMYSQL_USERNAME -pPASSWORD DATABASE | ssh USER@DOMAIN "mysql -uMYSQL_USERNAME -pPASSWORD DATABASE"

3 Still in the old server, execute the following command to move whatever directories you want (e.g. moodledata and public_html):

rsync -av -e ssh SOURCE_DIRECTORY/ USERNAME@NEW.URL:/PATH/TO/DESTINATION/

4 Update config.php on your new server with the relevant details

5 Use your_site/admin/replace.php to search and replace old urls for links etc. you have in your site

Note, first time you try this you will be asked to trust the new server, and you will be asked for the password.

I used this method to move a few sites when I upgraded to a dedicated server and also use it to create test sites.

Hope it helps.

Regards
H