Skip to content

Commit b371688

Browse files
authored
Merge pull request #8554 from kenjis/docs-deploy-shared-hosting
docs: add "Deployment to Shared Hosting Services"
2 parents cc9ce52 + ef7b1e9 commit b371688

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

user_guide_src/source/installation/running.rst

+79
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,85 @@ 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+
Check with your hosting service provider to see if you can change the document root.
453+
Unfortunately, if you cannot change the document root, go to the next way.
454+
455+
Using Two Directories
456+
=====================
457+
458+
The second way is to use two directories, and adjust the path.
459+
One is for the application and the other is the default document root.
460+
461+
Upload the contents of the **public** folder to **public_html** (the default
462+
document root) and the other files to the directory for the application::
463+
464+
├── example.com/ (for the application)
465+
│ ├── app/
466+
│ ├── vendor/ (or system/)
467+
│ └── writable/
468+
└── public_html/ (the default document root)
469+
├── .htaccess
470+
├── favicon.ico
471+
├── index.php
472+
└── robots.txt
473+
474+
See
475+
`Install CodeIgniter 4 on Shared Hosting (cPanel) <https://forum.codeigniter.com/showthread.php?tid=76779>`_
476+
for details.
477+
478+
Adding .htaccess
479+
================
480+
481+
The last resort is to add **.htaccess** to the project root.
482+
483+
It is not recommended that you place the project folder in the document root.
484+
However, if you have no other choice, you can use this.
485+
486+
Place your project folder as follows, where **public_html** is the document root,
487+
and create the **.htaccess** file::
488+
489+
└── public_html/ (the default document root)
490+
└── example.com/ (project folder)
491+
├── .htaccess
492+
└── public/
493+
494+
And edit **.htaccess** as follows:
495+
496+
.. code-block:: apache
497+
498+
<IfModule mod_rewrite.c>
499+
RewriteEngine On
500+
RewriteRule ^(.*)$ public/$1 [L]
501+
</IfModule>
502+
503+
<FilesMatch "^\.">
504+
Require all denied
505+
Satisfy All
506+
</FilesMatch>
507+
429508
*********************
430509
Bootstrapping the App
431510
*********************

0 commit comments

Comments
 (0)