Migration problems

Migration problems

by Henry Foster -
Number of replies: 5

I am trying to migrate our moodle installation (3.0.2) to a new dedicated hosted server, and have got to the point where the moodle software, moodledata directory and database have been transferred/restored. Now when I try to access the site, I get a 500 Internal Server Error. The error log gives me this: 

[Fri Aug 26 22:41:33 2016] [alert] [client 217.73.208.154] /home/ktuelea6/public_html/.htaccess: Invalid command 'php_flag', perhaps misspelled or defined by a module not included in the server configuration

I tried removing the php_flag lines from the .htaccess file, and then it gave me errors about php_value. I tried removing those lines as well, and then I got an error about FcgidWrapper. When I removed that too, next I got an error message (in the browser) saying Syntax error, unexpected '['  in a certain line of a certain file. Then I restored the original .htaccess configuration and came here. As those of you who have helped me before know, I'm kind of in over my head in terms of server configuration and management, meaning I don't have the faintest idea of what I am doing, so please be patient with me. The new server we're on here is a managed server, meaning that the help staff are willing to do almost anything for me, but that does not mean they are experts w/r/t moodle.

I'm guessing, in my foggy and uneducated way, that the server we were on before required an .htaccess file for the sake of configuration, but perhaps the new one does not?

I would greatly appreciate any advice or ideas of how to proceed from here.


Average of ratings: -
In reply to Henry Foster

Re: Migration problems

by Ken Task -
Picture of Particularly helpful Moodlers

First, don't think it would hurt to disclose where it's hosted.   Sometimes hosting provider has publically accessible FAQ's designed for customers having issues or seeking knowledge of how provider sets them up (not all providers do things the same way).

The new 'dedicated hosted server' ... does that mean you are the only customer on that server?  And are you moving the server from shared hosting to dedicated hosted box ON the same provider's network?

By the error we can tell it's Linux, but knowing what specific distribution it would help ... Ubuntu?  CentOS? (verison numbers would be of help also).   Subtle differences but still significant ... In CentOS the web server is 'apache' where as in Ubuntu it's 'www-data' (typically, but not always).

The error you saw about '[' could be related to PHP version so it probably would be a good idea to find out how your provider sets up PHP on 'dedicated' servers.   They might have more than one version of PHP.

Am guessing there is a cPanel and might be a WHM thang you access?    Reason I say that the path shown in the error /home/customerlogin/public_html/ is typical on those systems.

Basically,  providers system has you setup in a 'user jail' (/home/customerid/).    There is a config file for apache server (assuming apache) that sets restrictions to 'user directories'.   That's why you had an .htaccess file in moodleata.

The requirement of Moodle is that moodledata cannot be directly accessible via a web browser:

http://site/moodledata/

Moodle security checks won't allow that ... or shouldn't.   But, due to user jail, a work-around is to use an .htaccess file that only prevents browsing the directory.

The following link is old but still the part about htaccess applies to your setup

https://docs.moodle.org/20/en/Creating_Moodle_site_data_directory

I'd make sure I have a copy of that .htaccess file archived so you an refer to thei other lines contained therein later.   They may/may not be needed in your new system.

Reason for keeping the .htaccess file from old system ... it contain some references to PHP settings which you might need to set else where ... cPanel/whatever or typically in php.ini

Since you've not mentioned those lines specificallly ... ie, what they said, it's anyone's guess.   I don't believe, however, those lines contain anything that would compromise your server (I'd be very surprised if there were).    So you might want also to respond the contents of the current .htaccess file including nothing relate to passwords etc. of course.   Those PHP tweaks will probably need to be applied on this new server.

There could also be tweaks needed to apache's FastCGI but without specific info, my educated guess would be to move the moodledata directory ... it's contents into your 'public_html' directory **AND** use only the lines shown in the link above in an .htaccess file at the root of moodledata.

You then must edit config.php and change whatever needs changing ... DB host, DB user, DB password, path to moodledata, etc., etc.

Haven't mentioned any command line for two reasons: 1. dunno what OS you are running and don't want to draw this out. 2. not sure you want to use any CLI but will say that even in a jail usage of the CLI is, IMHO, 'better' than using cPanel for many things.

If your profile has the current URL of site it appears you have been on SiteGroud? Is the site moving to another hosting provider?

'spirit of sharing', Ken

In reply to Henry Foster

Re: Migration problems

by Ken Task -
Picture of Particularly helpful Moodlers

Am sorry ... I have to say this ...

"The new server we're on here is a managed server, meaning that the help staff are willing to do almost anything for me."

Uhhhh .... you pay for that 'management' ... and absolving them of finding the issues and resolving those for them means *you are managing via proxy*.   Unless they've a legal/beagle way out by fine print saying just the operating system is managed by them ... and customer is responsible for the applications.    Some errors, however, should indicate where the problem resides AND they should have enough expertise at hosting to be able to give you, the customer that's paying for this 'management', a clue ... or even links to technical docs related to the app..

Even if that were true, they should be good enough at managing a linux server to get to the bottom of some of those errors themselves.   One of them should be posting here!

GRRRRR ... as you can tell this makes me angry! :\

'spirit of sharing', Ken



In reply to Ken Task

Re: Migration problems

by Henry Foster -

Thanks, as always, Ken. Actually, I haven't even asked them about this one yet, because then I wouldn't get to bask in your wisdom personally. I guess I'll throw it at them and see if they can figure it out before muddling on further by myself.

I wasn't intentionally withholding any information, I just never know what is going to be necessary info to get to the bottom of a given problem. We had our site on a dedicated server at Joe's (http://www.joeswebhosting.net/) which was not managed at all, and was VPS, not a physical server. Now we are (well, the university is) renting a managed, dedicated stand-alone server at SiteGround (for a considerably higher price). I'm pretty sure it's CentOS - when you try to access the site (ktu-e-learn.net), the error message gives "Apache/2.2.24 (Unix)". 

As you guessed, I am using cPanel and WHM. I do have root access, but I'm not very adept at CLI.

The content of the .htaccess file is as shown below.

The SiteGround cPanel has a section for setting PHP versions. I have set the PHP version for public_html to 5.4.4.

Anyway, I'll see if SiteGround's support staff can sort this out for me, and if not, I'll post here again.

Thanks again, Ken. I always seriously appreciate your help.


# AddHandler application/x-httpd-php52 .php .php5 .php4 .php3

# AddHandler application/x-httpd-php54 .php .php5 .php4 .php3

# On some PHP servers it may help if this file is copied
# to the main moodle directory and renamed .htaccess
#
# As soon as you do this, check your web site.  Is it
# still working OK?  If you are getting a "configuration
# error" then you may need to enable overrides by editing
# the main httpd.conf for Apache and in the main server
# or virtual server area, adding something like:
#
# <directory web="" moodle="">
#     AllowOverride All
# </directory>
#

Options -Indexes

### Firstly, if you are using Apache 2, you need the following
### three lines to allow Apache to pass a PATH_INFO variable
### correctly for URLs like http://server/file.php/arg1/arg2

<ifdefine apache2="">
    AcceptPathInfo on
</ifdefine>

### Secondly, you can define the default files in the Moodle
### directories as follows:

DirectoryIndex index.php index.html index.htm

### Thirdly, set up some PHP variables that Moodle needs

php_flag file_uploads            1
php_flag short_open_tag          1
php_flag session.auto_start      0
php_flag session.bug_compat_warn 0

### Fourthly, sometimes Apache limits the size of uploaded files
### (this is a separate limit to the one in PHP, see below).
### The setting here turns off this limitation

LimitRequestBody 0


### These are optional - you may not want to override php.ini
### To enable them, remove the leading hash (#)

#php_value upload_max_filesize 2M
#php_value post_max_size 2M
#php_value session.gc_maxlifetime 7200


### You can change the following line to point to the
### error/index.php file in your Moodle distribution.
### It provides a form which emails you (the admin)
### about 404 errors (URL not found).

#ErrorDocument 404 http://example.org/moodle/error/index.php


### People have reported that these can help in some cases
### (unusual) when you see errors about undefined functions

#php_value auto_prepend_file none
#php_value include_path .

php_value memory_limit 128M
php_flag magic_quotes_runtime 0
LimitRequestBody 0
php_value upload_max_filesize 20M
php_value post_max_size 20M

FcgidWrapper /usr/local/cpanel/cgi-sys/php7 .php
AddHandler fcgid-script .php

<files 403.shtml="">
order allow,deny
allow from all
</files>
In reply to Henry Foster

Re: Migration problems

by Henry Foster -

Problem solved. On your prompting, Ken, I posted a ticket at SiteGround and within 5 minutes they had me sorted out. He hashtagged out the lines in the .htaccess file he said were not pertinent, and he bumped the php version up to 5.6. Now everything seems to be working normally.

For what its worth, I have always been pleased with SiteGround's service (that's why I persuaded the university to let us move back there). Of course, for a standalone dedicated server, you have to pay (we're renting a "Power Server" at $330/mo), but the support is good.

Thank you again, Ken, for your help.

In reply to Henry Foster

Re: Migration problems

by Ken Task -
Picture of Particularly helpful Moodlers

"because then I wouldn't get to bask in your wisdom personally" ... oh, please!!! ... but thanks for the thought.

Am glad to hear that provider honors what services they sell.   Refreshing to hear/see that.

Thanks for sharing the .htaccess file .... interesting ... they even had it commented for customers ... nice touch.

SiteGround doesn't program cPanel.   cPanel is a commercial product (whose usage on a server is actually an additional fee to the customer).  Have no idea how they decide how much it adds to monthly.   It is made for persons who care not to use CLI on a Linux box.   But, don't think cPanel makers have a version for a true standalone - one customer - machine.   Thus, customer's web space gets into a 'user jail' that's not configured like the true 'apache root'.   For a CentOS server that's /var/www/ Set up like that there is NO need for an .htaccess file in moodledata.   And there is no need for .htaccess files anywhere in any directory of any app *unless* recommended by the makers of the app ... like Joomla or WordPress.  Am not suggesting you request that change ... stick with what works right now.

Depending upon your version of Moodle, I'd check into the use of PHP 7 as opposed to the version they have setup on now.  PHP 7 has been said to improve performance.   One must have Moodle 3.0.1> however (as I understand it) to take advantage of that version (it is possible to get further ahead with PHP than Moodle).

Your old .htaccess file did show it running PHP 7.

PHP 5.5 is compatible with what you are running now, but in future? (everything moves upwards) As Moodle direction seems to be going 'upwards', for all the features, server/hosting will have to provide more so it's wise to have moved to a dedicated (one customer) server.   You're stie should/will have the ability to use those newest features of 3.1->.   In your case, with assistance from provider.   That version, from what I understand, is the highest LTS (long term support) version available.   Be interesting to watch providers to see if they increase their fees or not - new feature requirements.  Suggest you inquire about it.

And we've not touched MySQL .... yet.

BTW, these forums are like social media to providers who are concerned about their rep.  So it's perfectly OK to mention who's providing services.  Good PR and free advertising to some extent for those who take care of their Moodle customers ... whose needs are greater than those that host a WordPress or a Joomla.

'spirit of sharing', Ken