Skip to content

Commit 44cf965

Browse files
authored
Merge pull request #8579 from kenjis/4.5-docs-deployment
[4.5] docs: move "Deployment to Shared Hosting Services" to "Deployment" page
2 parents c965d70 + b199f9d commit 44cf965

File tree

2 files changed

+81
-77
lines changed

2 files changed

+81
-77
lines changed

user_guide_src/source/installation/deployment.rst

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ Deployment
66
:local:
77
:depth: 3
88

9-
Before deploying your CodeIgniter application to production, there are several
10-
things you can do to make your application run more efficiently.
11-
129
************
1310
Optimization
1411
************
1512

13+
Before deploying your CodeIgniter application to production, there are several
14+
things you can do to make your application run more efficiently.
15+
1616
This section describes the optimization features that CodeIgniter provides.
1717

1818
Composer Optimization
@@ -63,3 +63,80 @@ If you want to use `Preloading <https://www.php.net/manual/en/opcache.preloading
6363
we provide a
6464
`preload script <https://github.com/codeigniter4/CodeIgniter4/blob/develop/preload.php>`_.
6565

66+
.. _deployment-to-shared-hosting-services:
67+
68+
*************************************
69+
Deployment to Shared Hosting Services
70+
*************************************
71+
72+
.. important::
73+
**index.php** is no longer in the root of the project! It has been moved inside
74+
the **public** folder, for better security and separation of components.
75+
76+
This means that you should configure your web server to "point" to your project's
77+
**public** folder, and not to the project root.
78+
79+
Specifying the Document Root
80+
============================
81+
82+
The best way is to set the document root to the **public** folder in the server
83+
configuration::
84+
85+
└── example.com/ (project folder)
86+
└── public/ (document root)
87+
88+
Check with your hosting service provider to see if you can change the document root.
89+
Unfortunately, if you cannot change the document root, go to the next way.
90+
91+
Using Two Directories
92+
=====================
93+
94+
The second way is to use two directories, and adjust the path.
95+
One is for the application and the other is the default document root.
96+
97+
Upload the contents of the **public** folder to **public_html** (the default
98+
document root) and the other files to the directory for the application::
99+
100+
├── example.com/ (for the application)
101+
│ ├── app/
102+
│ ├── vendor/ (or system/)
103+
│ └── writable/
104+
└── public_html/ (the default document root)
105+
├── .htaccess
106+
├── favicon.ico
107+
├── index.php
108+
└── robots.txt
109+
110+
See
111+
`Install CodeIgniter 4 on Shared Hosting (cPanel) <https://forum.codeigniter.com/showthread.php?tid=76779>`_
112+
for details.
113+
114+
Adding .htaccess
115+
================
116+
117+
The last resort is to add **.htaccess** to the project root.
118+
119+
It is not recommended that you place the project folder in the document root.
120+
However, if you have no other choice, you can use this.
121+
122+
Place your project folder as follows, where **public_html** is the document root,
123+
and create the **.htaccess** file::
124+
125+
└── public_html/ (the default document root)
126+
└── example.com/ (project folder)
127+
├── .htaccess
128+
└── public/
129+
130+
And edit **.htaccess** as follows:
131+
132+
.. code-block:: apache
133+
134+
<IfModule mod_rewrite.c>
135+
RewriteEngine On
136+
RewriteRule ^(.*)$ public/$1 [L]
137+
</IfModule>
138+
139+
<FilesMatch "^\.">
140+
Require all denied
141+
Satisfy All
142+
</FilesMatch>

user_guide_src/source/installation/running.rst

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -426,84 +426,11 @@ Setting Environment
426426

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

429-
430-
.. _deployment-to-shared-hosting-services:
431-
432429
*************************************
433430
Deployment to Shared Hosting Services
434431
*************************************
435432

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>
433+
See :ref:`Deployment <deployment-to-shared-hosting-services>`.
507434

508435
*********************
509436
Bootstrapping the App

0 commit comments

Comments
 (0)