Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I put my cakephp 3.0 project on a shared hosting server?

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?

like image 912
anupamapanchal Avatar asked Apr 01 '15 21:04

anupamapanchal


People also ask

Where is CakePHP installed?

Installing CakePHP Go to the folder where wamp is located for windows users and in www/ folder, create a folder cakephp4/. For Linux users, create the folder var/www/html/ and then create folder cakephp4/. cakephp4/ is the folder where we are going to install CakePHP.


3 Answers

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';
like image 78
jjz Avatar answered Sep 17 '22 04:09

jjz


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.

like image 27
wouter Avatar answered Sep 21 '22 04:09

wouter


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!

like image 34
Gaurav Avatar answered Sep 19 '22 04:09

Gaurav