Improve your CONFIG.PHP

Help with getting the CMS CORE package up and running. This does not include 3rd party modules, PHP scripts, anything downloaded via module manager or from any external source.
Locked
jindravavruska

Improve your CONFIG.PHP

Post by jindravavruska »

Hello,

there are several places in config.php where host name of the instance is written. In version 1.0.2, you will typically find it in several config variables at lines 16 (hostname), 40 (root_url), 56 (uploads_url), 118 (image_uploads_url).

Values of these variables are written by the install script as string literals. If you, for whatever reason, need to change the hostname, CMS will not run correctly until you find and change all of the above variable values.

What I did is that I replaced every occurrence of the hostname in these variables by inserted expression  . $config['hostname'] . , so if you have to change the hostname, you will have to change it only once in the whole config file.

I would like to suggest the development team to include this in the next convenient version of CMS Made Simple.

The story behind this is following:

I installed an instance of CMS-MS on my home pc without too much thinking, leaving "localhost" as the hostname. Later today I tried to access running CMS-MS from my PDA via bluetooth network access, using the BT-NA default IP address 192.168.0.1 as hostname in the URL. The first strange thing was that the CMS home page came as an unformatted, text-only page (in HTML, but without the theme colors and other "bells and whistles"). The second problem was that when I went to admin.php, after filling the login form I never actually reached the site again. It was because the redirect URL supplied by CMS-MS was "http://localhost/admin.php"...

It is interesting that CMS-MS does not use PHP variables (such as _SERVER['HTTP_HOST']) to figure out hostname from request headers or other reliable source, but maybe there is a good reason for that. For me, today, this was a complication :)

Good luck,

Jindra
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: Improve your CONFIG.PHP

Post by tsw »

jindravavruska wrote:
It is interesting that CMS-MS does not use PHP variables (such as _SERVER['HTTP_HOST']) to figure out hostname from request headers or other reliable source, but maybe there is a good reason for that. For me, today, this was a complication :)
Your suggestion has come up before also. Im not fully avare of all the problems included with this change but do know that $_SERVER['HTTP_HOST'] doesnt work on all situations. Especially IIS has some of these variables set differently compared to apache.

it would be better to add this kind of things as feature requests in the tracker as forum posts tend to get lost and are hard to handle. For example I havent seen this post before you mentioned it in the other thread...
wientanz

Re: Improve your CONFIG.PHP

Post by wientanz »

Noticed that problem myself and found another thread with exactly the same proposed solution some time ago (think it was half a year ago). So it really seems to be some kind of problem to some people. Especially with people using it simultaneously as intra- and internet portal.

Just my two cents :-)
Pierre M.

Re: Improve your CONFIG.PHP

Post by Pierre M. »

jindravavruska wrote: What I did is that I replaced every occurrence of the hostname in these variables by inserted expression  . $config['hostname'] . , so if you have to change the hostname, you will have to change it only once in the whole config file.

I would like to suggest the development team to include this in the next convenient version of CMS Made Simple.
Well done, nice idea. I'd like it too.
If Jindra posts a wish in the tracker, how can I vote for it ?

PM
User avatar
Elijah Lofgren
Power Poster
Power Poster
Posts: 811
Joined: Mon Apr 24, 2006 1:01 am

Re: Improve your CONFIG.PHP

Post by Elijah Lofgren »

Pierre M. wrote:
jindravavruska wrote: What I did is that I replaced every occurrence of the hostname in these variables by inserted expression  . $config['hostname'] . , so if you have to change the hostname, you will have to change it only once in the whole config file.

I would like to suggest the development team to include this in the next convenient version of CMS Made Simple.
Well done, nice idea. I'd like it too.
If Jindra posts a wish in the tracker, how can I vote for it ?

PM
Thanks for your suggestion. I've filed it as a FR and assigned it to myself: http://dev.cmsmadesimple.org/tracker/in ... 6&atid=104
Hopefully I'll remember/have time to add this before CMSMS 2.0 is released.
Note: I don't have time to take on any more projects. I'm quite busy. I may be too busy to reply to emails or messages. Thanks for your understanding. :)
bas_otten

Re: Improve your CONFIG.PHP

Post by bas_otten »

I want to post a slight correction on the first post:

You should leave 'localhost' on line 16: $config['db_hostname'] = 'localhost';

This has to do with the connection between the webserver and the database server, not browser to webserver.

Regards.
Locked

Return to “[locked] Installation, Setup and Upgrade”