General help

 
 
Picture of Rick Barkley
changing from an IP address to a domain name
 

I have seen a few different moodlers with similar questions, but none of the answers have seemed to help.  I set up moodle on a rackspace server as a localhost, and people could access it via the http://ip-address/moodle.  I set up a domain name which kind of works.  It will bring me to the site, but a message pops up 

Incorrect access detected, this server may be accessed only through "http://'ip-address'/moodle" address, sorry.
Please notify server administrator.
 
then the site comes up but instead of the domain name it reverts back to the ip address.  I updated the config.php file with the domain name and also ran the "/admin/replace.php" to replace all instances of the old URL with the new one.  
 
all this has not worked......any thoughts??
 
Thanks! 
 
Average of ratings: -
when not driving the keyboard, when not climbing a mountain, when not out in the garden...
Re: changing from an IP address to a domain name
 

When you say you updated the config.php, I assume this means the $CFG->wwwroot =  line?? 

 
Average of ratings: -
Picture of Rick Barkley
Re: changing from an IP address to a domain name
 

Correct.....that is what I updated.  before I added the domain name it said http://localhost/moodle.  I changed it to http://domain-name/moodle

the server can be accessed from the internet, using the domain name url, it just reverts back to an IP address. 

 
Average of ratings: -
Picture of Ken Task
Re: changing from an IP address to a domain name
Group Particularly helpful Moodlers

No experience with RackSpace, but assume this server is a standalone (virtual) with no other customers sharing the space/ip.

Also, assume the 'domain-name' to which you refer is a fully qualified domain name ... ie (example) mdl.somenet.net (includes hostname) and NOT just somenet.net.   That being the case, can one 'lookup' in DNS mdl.somenet.net?

Sounds like apache config - virutal hosts? - have the site hard-coded with the IP address.

On a server to which you have access to httpd.conf, it has the following lines that could apply (note it is commented):

# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, in addition to the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses (0.0.0.0)
#
#Listen 12.34.56.78:80
Listen 80

# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If this is not set to valid DNS name for your host, server-generated
# redirections will not work.  See also the UseCanonicalName directive.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address anyway, and this will make
# redirections work in a sensible way.
#
#ServerName www.example.com:80

and last:

# UseCanonicalName: Determines how Apache constructs self-referencing
# URLs and the SERVER_NAME and SERVER_PORT variables.
# When set "Off", Apache will use the Hostname and Port supplied
# by the client.  When set "On", Apache will use the value of the
# ServerName directive.
#
UseCanonicalName Off

Assuming also you might be running Virtual Apaches, check the Virtual Host lines for the Moodle site.

### Section 3: Virtual Hosts
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>;
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

After changes, the apache service does need to be restarted.

'spirit of sharing', Ken

 
Average of ratings: -
Picture of Rick Barkley
Re: changing from an IP address to a domain name
 

Thanks Ken, that was my first thought that there was something with the apache2 server that had and issue. but if I go to the site (minus the /moodle) I get the typical "It Works" messasge.  The only if I use http:// not www.

the domain is www.tcsa.schober.org - http://tcsa.schober.org

the moodle site is www.tcsa.schober.org/moodle

I also tried changing the nameserver in the httpd.conf file and that did not seem to fix this.  any other thoughts?

 
Average of ratings: -
Picture of Rick Barkley
Re: changing from an IP address to a domain name
 

I have made some more changes to the config.php file, and honestly it seems like the file is not being accessed by the site.....I have changed all sorts fo fields and the site come up like nothing was changed.....is there something really obvious that I am missing here??

 
Average of ratings: -
Picture of Ken Task
Re: changing from an IP address to a domain name
Group Particularly helpful Moodlers

If the config file cannot be read, it would show an entirely different screen, but it would be a Moodle screen - ie reponse from Moodle.  One thing I didn't mention, but it shouldn't have been a problem, if when editing the config.php file, you used a text editor and heeded the warning:

// MAKE SURE WHEN YOU EDIT THIS FILE THAT THERE ARE NO SPACES, BLANK LINES,
// RETURNS, OR ANYTHING ELSE AFTER THE TWO CHARACTERS ON THE NEXT LINE.
?>

The above might show word wrapped here, but not in a text editor!

The three lines that relate to the problem (I think) are:

$CFG->wwwroot   = 'http://yoursite/moodle';
$CFG->dirroot   = '/pathto/moodle';
$CFG->dataroot  = '/pathto/moodledata';

From what you've described (kicking back to the IP address), again, sounds like apache config to me.

So if one did a dig (nslookup) for the server - both reverse and forward (like dig -x IP_address and dig fullyqualified.domain.name) - does one get correct responses?

After changes to the apache conf - to be able to use a FQDN for the site - was apache services restarted?

So that I can help, send me the IP and server FQDN via IM - here in Moodle - and I'll report back to you directly what I've been able to discover, if ya like.

'spirit of sharing', Ken

 
Average of ratings: -
Picture of Rick Barkley
Re: changing from an IP address to a domain name
 

 

this is what I have in the config.php file

$CFG->wwwroot = 'http://www.tcsa.schober.org/testdemo';
$CFG->dirroot = '/usr/share/testdemo';
$CFG->dataroot = '/var/lib/moodle';
$CFG->directorypermissions = 0777;
$CFG->admin = 'admin';

 

the only thing that gets me to the site is http://tcsa.schober.org/moodle will get me to the site but it reverts back to the IP address, nor does it reflect the testdemo change.  If I use /testdemo it says url not found

 
Average of ratings: -
Picture of Rick Barkley
Re: changing from an IP address to a domain name
 

Also, If I go back to just the localhost which pulls up with the IP address, none of the changes regarding the moodle directory seem to change anything /testdemo does not work but /moodle still does?

$CFG->dbtype = 'mysql';

$CFG->dbhost = 'localhost';
$CFG->dbname = 'testdemo';
$CFG->dbuser = 'moodle';
$CFG->dbpass = 'xxxxxxxx';
$CFG->prefix = 'mdl_';

$CFG->wwwroot = 'http://localhost/testdemo';
$CFG->dirroot = '/usr/share/testdemo';
$CFG->dataroot = '/var/lib/moodle';
$CFG->directorypermissions = 0777;
$CFG->admin = 'admin';

 

I made similar changes on a home system running as localhost and it worked perfectly. 

 
Average of ratings: -
Picture of Ken Task
Re: changing from an IP address to a domain name
Group Particularly helpful Moodlers

First, info about 'localhost'.  Typically, on all machines, localhost is pointed to 12.0.0.1 (the loopback IP address of every computer on the net).  Even your current workstation thinks localhost is equal to 127.0.0.1.  One cannot reach a server using http://localhost from another workstation/computer.   A meant-for-development-locally installed Moodle is set to work with localhost only.
You can use the browser on the same machine to access, but cannot access it via any other computer/device on your home network.   Got another computer or handheld/smartphone on your wifi?  Try going to http://localhost and see what happens.   Uhhh, I can tell ya … nothing but an error and you won't see any Moodle. ;)

Attempting to go to www.tcsa.schober.org one gets a screen that says:

----------------------------------------

   Site Not Published                                                                           
   The site you are looking for has not been published                                          
                                                                                                
   If you are the owner of the site, you can fix this message by publishing your site to        
   this address.
------------------------------------------
So it looks to be an apache config issue.  Whatever tool/control panel the hosting folks have given you, use that to 'publish' www.tcsa.schober.org

Also, the supposed 'short-cut' URL, http://tcsa.schober.org/moodle/
does get to Moodle then flips to IP address.  That's because Moodle is an app and the configuration of Moodle now takes over (briefly) … but, due to 'not published site', Apache overrides Moodle and you get IP address/moodle.  Apache is redirecting every click.

Find your apache2.conf on the server and the line that points to document root.
The Moodle folder should be in the document root.
The data folder for Moodle could be anywhere but typically up one level from document root.
But, it could be anywhere the apache user is setup to read/write to it.

Hey, TCSA!!!  Small world … am in Tx. as well!

'spirit of sharing', Ken

http://www.sosoftexas.org http://moodle.tcea.org http://sos.tcea.org

 
Average of ratings: -
Picture of Rick Barkley
Re: changing from an IP address to a domain name
 

Thanks Ken!  It is a small world indeed!  I will work on it this evening and see if I can get everything resolved. 

thanks again!

 
Average of ratings: -
Picture of winlux wini
Re: changing from an IP address to a domain name
 

I just changed my moodle installation from online hosting that worked perfectly, albeit extremely slow. I wanted to have a better user experience for customers and ended up switching to a server that ishosted on premises.

I to get the problem that is described here, but in my case I pointed the DNS to my ip. Moodle is set to my public ip and as a result, the domain name does not display.

When I set the DNS to point to my IP, I could change only the A record. The problem is not as described apache based. When I did a reverse lookup on the ip, it reads the reverse from the ISP DNS. This means that moodle relies heavily on the ability to inerpret reverse DNS.

In my case I cannot change the PTR. If you have this ability, change a PTR to point to your domain and it should work fine.

If others have some more suggestions please add, I would love to know a work around to this as well.

 
Average of ratings: -