Deploy CakePHP 4.x

Hi all,

My FIRST CakePHP project is not complete and I would like to deploy it. I have a shared hosting from Ionos (Essential pack), offering SSH. But now I am quite lost on how to deploy my project. I do not find any tutorial/documentation on how to proceed. What should I do now ? Usually I upload all the files through FTP and that’s it… But here it seems that I will need SSH and composer to make a “composer install” and so on… Can you please guide me ? Thank you very much.


Start by reading: Deployment - 4.x

You can ssh in with putty or similar,

But you can have all setup and ftp up. I don’t know that host limitations.

Make sure you point to webroot as your document root. Also remember, Nginx and Apache have different setups. Refer to their documentation as required.

Thanks for your answer. “CakePHP applications should have the document root set to the application’s webroot”. But my hosting provider is telling me that they cannot change the document root and so they are not able to host my website properly. I see people hosting cakePHP website on many cheaper providers and however it seems to be so tricky for me… I see some of them upload the files through FTP and that’s it. I do not understand what’s the issue here…

The hosting provider doesn’t change the document root, you do. You point to webroot as as the document root. If you cannot via a virtual host, you can actually use two htaccess files. The following is a laravel example, so adapt it to cakephp.

In the root folder you can have an htaccess file similar to:
This htaccess points to webroot.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]

RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ webroot/$1       

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php    ////// adapt lower portion to cakephp

And in webroot

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

In webroot use the one that comes with cakephp.

But again do some searching (Google) and adapt as needed as my example is a laravel 8 install on a shared host.

1 Like

Thanks. Sounds clear to me. Let’s try :slight_smile: