Is there a way to create a multisite YII application with one database for multiple domains

We plan to host one CMS for several sites.

Is there a way in YII, we can do it. The idea is simple: we want to share one application and a single database for all domains, but we will allow them to choose different themes for different sites.

By website I mean completely different Domains.

What else needs to be done to specify all domains on one server?

Edit ::

I do not need a different service directory for each domain. what i want to do is keep the installation only one.

i.e. / Server / WWW / master

then all domains

a.com, b.com, c.com read the same directory "/ server / www / master" and the same DB. and the records get the file based on the site.

+4
2

Yii, , .

Apache ( ServerAlias ​​- http://httpd.apache.org/docs/2.2/mod/core.html#serveralias).

-, .

ApplicationConfigBehavior.php:: beginRequest ( ), - :

/**
     * Load configuration that cannot be put in config/main
     */
    public function beginRequest()
    {
        if(empty(Yii::app()->session['community'])){
            $current_community = Community::model()->with(array(
                'communityHosts'=>array(
                    'joinType'=>'INNER JOIN',
                    'condition'=>'`communityHosts`.hostname= :hostname',
                    'params' => array(':hostname' => $_SERVER['SERVER_NAME'])
                ),
            ))->find(); 
            Yii::app()->session['community'] = serialize($current_community);
        }
        else{
            $current_community = unserialize(Yii::app()->session['community']);
        }

        if(!empty($current_community)){
            Yii::app()->name = $current_community->name;
            Yii::app()->params['currentCommunity'] = $current_community;
            Yii::app()->language = $current_community->language;
        }
        else{
            //TODO: Throw error
            session_unset();
            die('Hostname ' . $_SERVER['SERVER_NAME'] .' not found');
        }


    }

, , "" ( ) (, ..) .

. . , , -.

+2

apache

SetEnv SITE_NAME "CMSA"

,

defined('SITE_NAME') || define('SITE_NAME', ( getenv('SITE_NAME') );

.

.

0

All Articles