From ef7b1e932f48b39e58aeb87900b17016649bd7ba Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 17 Feb 2024 10:02:08 +0900 Subject: [PATCH] docs: add "Deployment to Shared Hosting Services" --- .../source/installation/running.rst | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index b9992ed7950a..69f89cfbdbd0 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -426,6 +426,85 @@ Setting Environment See :ref:`Handling Multiple Environments `. + +.. _deployment-to-shared-hosting-services: + +************************************* +Deployment to Shared Hosting Services +************************************* + +.. important:: + **index.php** is no longer in the root of the project! It has been moved inside + the **public** folder, for better security and separation of components. + + This means that you should configure your web server to "point" to your project's + **public** folder, and not to the project root. + +Specifying the Document Root +============================ + +The best way is to set the document root to the **public** folder in the server +configuration:: + + └── example.com/ (project folder) + └── public/ (document root) + +Check with your hosting service provider to see if you can change the document root. +Unfortunately, if you cannot change the document root, go to the next way. + +Using Two Directories +===================== + +The second way is to use two directories, and adjust the path. +One is for the application and the other is the default document root. + +Upload the contents of the **public** folder to **public_html** (the default +document root) and the other files to the directory for the application:: + + ├── example.com/ (for the application) + │ ├── app/ + │ ├── vendor/ (or system/) + │ └── writable/ + └── public_html/ (the default document root) + ├── .htaccess + ├── favicon.ico + ├── index.php + └── robots.txt + +See +`Install CodeIgniter 4 on Shared Hosting (cPanel) `_ +for details. + +Adding .htaccess +================ + +The last resort is to add **.htaccess** to the project root. + +It is not recommended that you place the project folder in the document root. +However, if you have no other choice, you can use this. + +Place your project folder as follows, where **public_html** is the document root, +and create the **.htaccess** file:: + + └── public_html/ (the default document root) + └── example.com/ (project folder) + ├── .htaccess + └── public/ + +And edit **.htaccess** as follows: + +.. code-block:: apache + + + RewriteEngine On + RewriteRule ^(.*)$ public/$1 [L] + + + + Require all denied + Satisfy All + + ********************* Bootstrapping the App *********************