Welcome Guest, Not a member yet? Register   Sign In
More than one site with CodeIgniter
#1

[eluser]Marc Cools[/eluser]
Hi,

I 'm new to Codeigniter.

When you have a site running with Codeigniter your structure is like this:

/path/to/myspace/{CodeIgniter core}
/path/to/myspace/application
/path/to/myspace/index.php

When I want more than one site but using the same framework (so avoiding more than one Codeingniterinstallation) what do I have to do?

So I want somthing like this:

@www.secondsite.com

path/to/my/secondsite/index.php <-- What code do I need here?

@www.firstsite.com

path/to/my/firstsite/{Codeigniter core} <-- common library, frontcontroller and so on.
path/to/my/firstsite/application_firstsite
path/to/my/firstsite/application_second_site
path/to/my/firstsite/index.php <-- kickstart for www.firstsite.com


What about the URI? How can I transfer it to the Codeigniter framework on the other site without showing up the other sites' name in the URI?
How do i set the right basepath in secondsite/index.php refering to .../firstsite/...

Yeah, I know. Lot's to learn. But I 'm a fast learner!

Thanks,
Marc
#2

[eluser]pistolPete[/eluser]
Running Multiple Applications with one CodeIgniter Installation
#3

[eluser]Marc Cools[/eluser]
The problem is sites on other locations.
When someone sends 'www.firstsite.com' the file path/to/firstsite/I/got/from/my/provider/index.php is called.
When someone sends 'www.secondsite.com' the file path/to/secondsite/I/got/from/my/other/provider/index.php is called.
How do i even get to the firstsite from the secondsite?
#4

[eluser]jdfwarrior[/eluser]
If I'm understanding correctly, sounds more like your trying to run two sites in two different locations from the same CI installtation? pistolPete is talking about running two actual applications from within the same area. Which are you doing?
#5

[eluser]jedd[/eluser]
Hi Marc and welcome to CI.

Because CI is inexpensive (in every sense of the word) to run, it might be easier to run them as two entirely separate codebases - unless(!) you're intending to share a lot of code between the two sites .. ? There are advantages to sharing a single CI instance, but OTOH there are some compelling reasons to keep them separate.

You may (though it's not clear from your question) be looking for something like mod_proxy for the apache web server, but I'll wait until you answer jdfwarrior's question.
#6

[eluser]Marc Cools[/eluser]
I prefere one installation. I just like it. All together.
My problem is that I don't understand how I can 'redirect' a second site.

The first site has an index.php file. In that file is the next code:
Code:
error_reporting(E_ALL);
$system_folder = "system";
$application_folder = "application";
if (strpos($system_folder, '/') === FALSE)
{
    if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
    {
        $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
    }
}
else
{
    // Swap directory separators to Unix style for consistency
    $system_folder = str_replace("\\", "/", $system_folder);
}
define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
define('FCPATH', __FILE__);
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('BASEPATH', $system_folder.'/');
if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ($application_folder == '')
    {
        $application_folder = 'application';
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;
Now when I have an other site with the same provider, I have for that site an other 'workspace'. So I think I have a security issue. I just can't pick up a file from that other 'workspace'. So how do I get there? Note that the BASEPATH is set by using the location of the index.php file. Hardcoding the other basepath isn't the most secure way and isn't still handling the security problem. For a site located at an other provider, the problem is the same.

I know the the second site has to set
Code:
$application_folder = "application_other_site";
or like the manual suggest
Code:
$application_folder = "application/second";
.
That is not the problem.

When there is just one workspace where there is no security problem with accessing other files, I still don't get it. When I send 'http://www.firstsite.com', I will be redirected to 'path/to/workspace/index.php'. Where will I be when I send 'http://www.secondsite.com'. It can't be 'path/to/workspace/index.php'? How will I know who's calling mij index.php?

So, onces I can redirect correctly (setting $application_folder and BASEPATH) my problem is solved.

Maybe now you understand what my problem is?
My question is a foolisch one. Sorry that I realy don't get it.

Thanks.
Marc
#7

[eluser]jedd[/eluser]
Hi Marc,

Don't worry - the question isn't foolish, I am just not sure I understand what you're trying to gain here, and so I'm hoping I can talk you out of trying to do it! Wink

Quote:I prefer one installation. I just like it. All together.

Okay, but keep in mind ...

Doing this only makes sense if the two systems are going to share a lot of code, and even then it's better practice (IMO) to put the shared code into libraries, and you can then easily sync those out to multiple CI instances.

CI is 2MB. So - you're saving 2MB of disk space (value : $0.00004 approximately) by doing this.

You're also going to hit problems if you ever want to upgrade a CI version for one of your sites, but not necessarily for the other (you haven't tested it on that one app yet, a known bug or 'feature change' will bite you, etc).

Most importantly ... the current problem. Smile


Now, if you're not convinced, back to the actual problem.

It doesn't sound like you've read this page (but perhaps you have?) :
[url="http://ellislab.com/codeigniter/user-guide/general/managing_apps.html"]http://ellislab.com/codeigniter/user-guide/general/managing_apps.html[/url]

Particularly the bit down the bottom, about having multiple index.php files, but of course they can/will be named something else.

EDIT Hang on .. I just re-read the entire thread .. so your big problem is how you get from one different *physical* site, not just 'site' in the sense of sub-directory under CI .. is that it? You want to be able to do a link between two different web server instances .. ?
#8

[eluser]tomcode[/eluser]
You can share one system installation with several applications.

1. have serveral of CI's index.php files in one folder by calling them differently, application1.php, application2.php, a.s.o.
2. have several folders each with it's own index.php

in both cases You have to set the paths accordingly :

for 1. You just need to changethe application path
for 2. You'll have Your system probably somewhere else, so You need to set the system path, too

then You bind the applications via DNS entries.
#9

[eluser]Marc Cools[/eluser]
DNS?
#10

[eluser]tomcode[/eluser]
DNS = Domain Name Service

In the admin area of Your Web space account you should be able to configure the DNS Zones, that's also where You create Your subdomaines.

Though not all hoster offer these kind of services.




Theme © iAndrew 2016 - Forum software by © MyBB