0

I am having trouble deploying my CakePHP application onto a shared web server. Here's what I've done:

1) I zipped the application from my local machine: application.zip 2) I then uploaded the zip file on to my public_html on the server and extracted it

So now my application sits at www.mydomain.com/application which works fine, but once I move the contents of the application folder onto public_html (so that my application sits at www.mydomain.com) it doesn't load the application properly. It only loads SOME of the links of the home page and none of the styles.

So to sum it up.. the app works fine right after extracting to public_html/application/ But once I move the contents of the application folder to public_html it doesn't work.

How am I supposed to set up the folder structure so that my application sits at www.mydomain.com?

Any help would be greatly appreciated.

4
  • Hi. Are you using Apache? And who's hosting your server? It's not 1and1, is it? Commented Apr 26, 2014 at 16:22
  • Yes it's Apache. And no I'm not using 1and1. Commented Apr 26, 2014 at 16:56
  • Hmm, all I can say is to make sure all the CakePHP .htaccess files are there (in the root of the application, in the app directory and in app/webroot) Commented Apr 26, 2014 at 17:02
  • 1
    most likely you haven't moved public_html/application/.htaccess to public_html/.htaccess. What you describe is mod rewrite not being enabled. It would be a better idea to put all your application files out of the document root and make public_html a symlink to the app/webroot folder (or some similar permutation) - it's the only folder that should be in a web-accessible location. Commented Apr 27, 2014 at 10:44

2 Answers 2

2

I just happened to try deploying a Cake app in the same way to a shared server using CPanel and had exactly the same problem. What I discovered is that somehow (I think when I extracted the zip to the public_html directory there was an empty .htaccess file that didn't want to be replaced) the .htaccess file in the root of the application was empty.

Just make sure the .htaccess file in the root of your application (i.e. in public_html) contains this:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule    ^$ app/webroot/    [L]
    RewriteRule    (.*) app/webroot/$1 [L]
</IfModule>

Worked fine for me and I'm all set now!

Sign up to request clarification or add additional context in comments.

6 Comments

Or (as indicated by my comment to the question) use a production install and make sure the document root points at the webroot folder. +1 anyway.
Noticed your comment, but as I'm using Cpanel I don't think this was possible, as it seems CPanel, and maybe other shared hosting, can't make use of DocumentRoot. For dedicated hosting though, yeah that would be the best way to go (and it's what I normally do - it's rare that I have to use a shared server, or Apache for that matter).
You don't need to be able to change the document root to have a production install; only be able to put your application files outside the document root, and either link or copy the webroot to the document root (if it's copied, the ROOT constant needs redefining).
This seems to have solved my problem. Thanks a lot mate.
@AD7six I see. Didn't think of moving the webroot, not sure if linking it would be possible using shared hosting though. Maybe it's something to consider next time - I'm used to using Nginx with root access though, so usually it's more straightforward.
|
0

You could also try deleting cache files in app/tmp/cache Not the folders but the files in the folders

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.