Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add "Deployment to Shared Hosting Services" #8554

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions user_guide_src/source/installation/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,85 @@ Setting Environment

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


.. _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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I tested this method in practice, it works well.
@kenjis, thank you for following up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method (and a few hacks) worked on 000webhostapp.
https://kenjis.000webhostapp.com/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh!! In 2022, someone asked me this question in an email 😇

Screenshot 2024-02-20 131713

=====================

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) <https://forum.codeigniter.com/showthread.php?tid=76779>`_
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

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

<FilesMatch "^\.">
Require all denied
Satisfy All
</FilesMatch>

*********************
Bootstrapping the App
*********************
Expand Down