1
votes

I'm hosting a website on Linux server and the folders is like that

/var/www/html/agitoriosul.com.br/web/

/web is the public folder

I want put core and app folder one leve before web folder and webroot inside web folder.

I know i need configure index.php inside webroot but i've tried a lot of things and nothing works.

Now all the folders is inside web(public folder) but, first i know core and app folder cant stay inside web(public folder), second, all links created with Html->link helper is pointing to physic path(/var/www/html/agitoriosul.com.br/web/) and not virtual(agitoriosul.com.br/) path.

2

2 Answers

0
votes

/web is the public folder

Therefore using the standard folder layou there would be the following:

/var/www/html/example.com
    app
        webroot
    lib
    plugins
    vendors

But instead want this:

/var/www/html/example.com
    app
    lib
    plugins
    vendors
    web

Move and edit

The steps to achieve that are pretty simple:

move the folder

with a command such as:

$ cd /var/www/html/example.com
$ mv app/webroot web

correct the ROOT path and APP_DIR constants

I.e. the web/index.php file would contain:

//define('ROOT', dirname(dirname(dirname(__FILE__))));
define('ROOT', dirname(dirname(__FILE__)));

//define('APP_DIR', basename(dirname(dirname(__FILE__))));
define('APP_DIR', 'app');
// cannot be derived, as the app folder is not a parent

Or, if preferred:

//define('ROOT', dirname(dirname(dirname(__FILE__))));
define('ROOT','/var/www/html/example.com');

//define('APP_DIR', basename(dirname(dirname(__FILE__))));
define('APP_DIR', 'app');

Alternatively

Don't move anything around, and just symlink the webroot like so:

/var/www/html/example.com
    app
        webroot
    lib
    plugins
    vendors
    web -> app/webroot

with a command such as:

$ cd /var/www/html/example.com
$ ln -s app/webroot web

This requires no modifications to the app webroot files.

-1
votes

I have created two applications by using the same lib and plugins and vendors folder

Please see the folder structure as mentioned below:

Main Folder

/var/www/cake
/var/www/cake/lib
/var/www/cake/plugins
/var/www/cake/vendors

Application 1

/var/www/cake/cake1/app
/var/www/cake/cake1/webroot

Edits in:

/var/www/cake/cake1/webroot/index.php (only three edits)

if (!defined('ROOT')) {
    //define('ROOT', dirname(dirname(dirname(__FILE__))));
    define('ROOT', dirname(dirname(__FILE__)));
}

if (!defined('APP_DIR')) {
    //define('APP_DIR', basename(dirname(dirname(__FILE__))));
    define('APP_DIR', 'app');
}

define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__))) . DS . 'lib');

Application 2

/var/www/cake/cake2/app
/var/www/cake/cake2/webroot

Edits in:

/var/www/cake/cake2/webroot/index.php (only three edits)

if (!defined('ROOT')) {
    //define('ROOT', dirname(dirname(dirname(__FILE__))));
    define('ROOT', dirname(dirname(__FILE__)));
}

if (!defined('APP_DIR')) {
    //define('APP_DIR', basename(dirname(dirname(__FILE__))));
    define('APP_DIR', 'app');
}

define('CAKE_CORE_INCLUDE_PATH', dirname(dirname(dirname(__FILE__))) . DS . 'lib');

this is working for me for two virtual hosts on ubuntu

http://cake1/
http://cake2/