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

4

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?

Aerograph answered 1/4, 2015 at 21:30 Comment(2)
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!?Mineralize
There is no lib folder anymore, have you read the installation instructions? book.cakephp.org/3.0/en/installation.htmlMineralize
G
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';
Gail answered 13/5, 2015 at 17:6 Comment(0)
T
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.

Thebes answered 1/8, 2016 at 9:43 Comment(0)
E
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!

Edrick answered 6/3, 2017 at 13:28 Comment(0)
A
0

In cakePHP 4 everything is above ok only line no 37 is different in index.php

from

$server = new Server(new Application(dirname(__DIR__) . '/config'));

to

$server = new Server(new Application(dirname(__DIR__) . '/home/username/mycakeapp/config'));
Agler answered 15/2, 2024 at 6:50 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.