5

I made a project in cakephp 3.0 which I want to put on a shared hosting server.

Cakephp documentation have given the solution for the previous versions here http://book.cakephp.org/2.0/en/installation/advanced-installation.html where directory structure was different than the new one.

In the older version for doing an advance installation on a shared hosting server the whole project is splitted into 3 parts

  1. lib,
  2. app and
  3. webroot,

and then those path are written in the .htaccess file for running the project.

In the new version app directory has become src, webroot is as it is but I couldn't find the lib directory for the installation.

Can anyone help me that how to go about it in its latest version?

  • It's pretty much still the same as with 2.x, the directory structure is a little different, but that's it. You may want to rephrase your question and explain the actual problem that you are facing!? – ndm Apr 02 '15 at 07:32
  • There is no `lib` folder anymore, have you read the installation instructions? **http://book.cakephp.org/3.0/en/installation.html** – ndm Apr 07 '15 at 10:56

3 Answers3

4

The way I got this working was to structure the directories on the shared host like so:

/home/username/public_html/
    // webroot contents goes here
    css/
    img/
    js/
    .htaccess
    index.php

/home/username/mycakeapp/
    // necessary app directories go here
    /config
    /logs
    /plugins
    /src
    /tmp
    /vendor

Then I changed WWW_ROOT in mycakeapp/config/paths.php on line 52:

define('WWW_ROOT', '/home/username/public_html/' . DS);

Finally, I had to change the path to bootstrap.php defined in the webroot index.php file on line 28 (located at /home/username/public_html/index.php):

require '/home/username/mycakeapp/config/bootstrap.php';
jjz
  • 925
  • 1
  • 13
  • 21
4

A small update to the answer of @jjz.

Is your structure is:

/home/username/public_html (with webroot contents)
/home/username/mycakeapp (installed cakephp 3 app)

Change /home/username/public_html/index.php:

FROM: require dirname(__DIR__) . '/config/bootstrap.php';
TO: require dirname(__DIR__) . '/mycakeapp/config/bootstrap.php';

Change /home/username/mycakeapp/config/paths.php:

FROM: define('WWW_ROOT', ROOT . DS . 'webroot' . DS);
TO: define('WWW_ROOT', realpath(ROOT . DS . '../public_html' . DS));

This way your app will be more portable, it does not depend on being in /home/username.

wouter
  • 247
  • 2
  • 6
4

Given by the default configuration of CakePHP3, I've found this method to be least disruptive.

Assumptions:

  1. You have access to cPanel/File Manager
  2. Your root folder is /home/username
  3. Your public (web) folder is /home/username/public_html

Steps:

  1. Copy the contents of your application's root folder (cakephp or whatever your application folder is) to /home/username. This will result in Your application's bin folder going to /home/username/bin and so on
  2. Remove public_html folder and create a new symlink 'public_html' pointing to /home/username/webroot

That's all!

Gaurav
  • 347
  • 4
  • 12