Skip to content

Commit bde3c36

Browse files
committed
docs: add "Deployment to Shared Hosting Services"
1 parent 872025d commit bde3c36

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

user_guide_src/source/installation/running.rst

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,87 @@ Setting Environment
426426

427427
See :ref:`Handling Multiple Environments <environment-nginx>`.
428428

429+
430+
.. _deployment-to-shared-hosting-services:
431+
432+
*************************************
433+
Deployment to Shared Hosting Services
434+
*************************************
435+
436+
.. important::
437+
**index.php** is no longer in the root of the project! It has been moved inside
438+
the **public** folder, for better security and separation of components.
439+
440+
This means that you should configure your web server to "point" to your project's
441+
**public** folder, and not to the project root.
442+
443+
Specifying the Document Root
444+
============================
445+
446+
The best way is to set the document root to the **public** folder in the server
447+
configuration::
448+
449+
└── example.com/ (project folder)
450+
└── public/ (document root)
451+
452+
For example, if you use cPanel, see:
453+
454+
- `How to change the document root of the primary domain <https://support.cpanel.net/hc/en-us/articles/360055211213-How-to-change-the-document-root-of-the-primary-domain>`_
455+
- `How can I change the document root for an Addon Domain or Subdomain? <https://support.cpanel.net/hc/en-us/articles/360057802373-How-can-I-change-the-document-root-for-an-Addon-Domain-or-Subdomain>`_
456+
457+
Using Two Directories
458+
=====================
459+
460+
The second way is to use two directories, and adjust the path.
461+
One is for the application and the other is the default document root.
462+
463+
Upload the contents of the **public** folder to **public_html** (the default
464+
document root) and the other files to the directory for the application::
465+
466+
├── example.com/ (for the application)
467+
│ ├── app/
468+
│ ├── vendor/ (or system/)
469+
│ └── writable/
470+
└── public_html/ (the default document root)
471+
├── .htaccess
472+
├── favicon.ico
473+
├── index.php
474+
└── robots.txt
475+
476+
See
477+
`Install CodeIgniter 4 on Shared Hosting (cPanel) <https://forum.codeigniter.com/showthread.php?tid=76779>`_
478+
for details.
479+
480+
Adding .htaccess
481+
================
482+
483+
The last resort is to add **.htaccess** to the project root.
484+
485+
It is not recommended that you place the project folder in the document root.
486+
However, if you have no other choice, you can use this.
487+
488+
Place your project folder as follows, where **public_html** is the document root,
489+
and create the **.htaccess** file::
490+
491+
└── public_html/ (the default document root)
492+
└── example.com/ (project folder)
493+
├── .htaccess
494+
└── public/
495+
496+
And edit **.htaccess** as follows:
497+
498+
.. code-block:: apache
499+
500+
<IfModule mod_rewrite.c>
501+
RewriteEngine On
502+
RewriteRule ^(.*)$ public/$1 [L]
503+
</IfModule>
504+
505+
<FilesMatch "^\.">
506+
Require all denied
507+
Satisfy All
508+
</FilesMatch>
509+
429510
*********************
430511
Bootstrapping the App
431512
*********************

0 commit comments

Comments
 (0)