From b35216056e487e3d64334f8f64f3261c59226141 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 8 Jul 2023 09:18:24 +0900 Subject: [PATCH 01/11] docs: fix Section Headings marks --- .../source/installation/running.rst | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index 0b974180f7e7..ce17b8a0aa46 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -1,3 +1,4 @@ +################ Running Your App ################ @@ -20,8 +21,9 @@ section of the User Guide to begin learning how to build dynamic PHP application .. _initial-configuration: +********************* Initial Configuration -===================== +********************* #. Open the **app/Config/App.php** file with a text editor and set your base URL to ``$baseURL``. If you need more flexibility, the baseURL may @@ -49,11 +51,12 @@ Initial Configuration your project, so that it is writable by the user or account used by your web server. +************************ Local Development Server -======================== +************************ CodeIgniter 4 comes with a local development server, leveraging PHP's built-in web server -with CodeIgniter routing. You can launch it, with the following command line +with CodeIgniter routing. You can launch it, with the following command line in the main directory:: > php spark serve @@ -83,8 +86,9 @@ The local development server can be customized with three command line options: > php spark serve --php /usr/bin/php7.6.5.4 +******************* Hosting with Apache -=================== +******************* A CodeIgniter4 webapp is normally hosted on a web server. Apache HTTP Server is the "standard" platform, and assumed in much of our documentation. @@ -93,7 +97,7 @@ Apache is bundled with many platforms, but can also be downloaded in a bundle with a database engine and PHP from `Bitnami `_. .htaccess ---------- +========= The "mod_rewrite" module enables URLs without "index.php" in them, and is assumed in our user guide. @@ -113,12 +117,12 @@ in the ``AllowOverride`` setting:: Removing the index.php ----------------------- +====================== See :ref:`CodeIgniter URLs `. Virtual Hosting ---------------- +=============== We recommend using "virtual hosting" to run your apps. You can set up different aliases for each of the apps you work on, @@ -148,7 +152,7 @@ If your project folder is not a subfolder of the Apache document root, then your ```` element may need a nested ```` element to grant the web server access to the files. With mod_userdir (Shared Hosts) --------------------------------- +=============================== A common practice in shared hosting environments is to use the Apache module "mod_userdir" to enable per-user Virtual Hosts automatically. Additional configuration is required to allow CodeIgniter4 to be run from these per-user directories. @@ -214,25 +218,26 @@ Be sure to specify options and permissions for the CodeIgniter public directory Setting Environment -------------------- +=================== See :ref:`Handling Multiple Environments `. Testing -------- +======= With the above configuration, your webapp would be accessed with the URL **http://myproject.local/** in your browser. Apache needs to be restarted whenever you change its configuration. +****************** Hosting with Nginx -================== +****************** Nginx is the second most widely used HTTP server for web hosting. Here you can find an example configuration using PHP 8.1 FPM (unix sockets) under Ubuntu Server. default.conf ------------- +============ This configuration enables URLs without "index.php" in them and using CodeIgniter's "404 - File Not Found" for URLs ending with ".php". @@ -269,12 +274,13 @@ This configuration enables URLs without "index.php" in them and using CodeIgnite } Setting Environment -------------------- +=================== See :ref:`Handling Multiple Environments `. +********************* Bootstrapping the App -===================== +********************* In some scenarios you will want to load the framework without actually running the whole application. This is particularly useful for unit testing your project, but may also be From 35e5342899564e21ceb5f6b627752c7901b751bf Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 8 Jul 2023 09:32:10 +0900 Subject: [PATCH 02/11] docs: indent config values in sample --- user_guide_src/source/installation/running.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index ce17b8a0aa46..4161233c0d94 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -143,9 +143,9 @@ e.g., **apache2/conf/extra/httpd-vhost.conf**:: DocumentRoot "/opt/lamp/apache2/htdocs/myproject/public" - ServerName myproject.local - ErrorLog "logs/myproject-error_log" - CustomLog "logs/myproject-access_log" common + ServerName myproject.local + ErrorLog "logs/myproject-error_log" + CustomLog "logs/myproject-access_log" common If your project folder is not a subfolder of the Apache document root, then your From 92e5a8fd1e5b11bf931506253b0962ccf0ed8fea Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 8 Jul 2023 09:31:46 +0900 Subject: [PATCH 03/11] docs: add sub section titles and fix --- .../source/installation/running.rst | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index 4161233c0d94..c7a5e7e5c4b8 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -96,8 +96,11 @@ Apache HTTP Server is the "standard" platform, and assumed in much of our docume Apache is bundled with many platforms, but can also be downloaded in a bundle with a database engine and PHP from `Bitnami `_. -.htaccess -========= +Configure Main Config File +========================== + +Enabling mod_rewrite +-------------------- The "mod_rewrite" module enables URLs without "index.php" in them, and is assumed in our user guide. @@ -107,6 +110,9 @@ configuration file, e.g., **apache2/conf/httpd.conf**:: LoadModule rewrite_module modules/mod_rewrite.so +Setting Document Root +--------------------- + Also make sure that the default document root's ```` element enables this too, in the ``AllowOverride`` setting:: @@ -127,17 +133,26 @@ Virtual Hosting We recommend using "virtual hosting" to run your apps. You can set up different aliases for each of the apps you work on, +Enabling vhost_alias_module +--------------------------- + Make sure that the virtual hosting module is enabled (uncommented) in the main configuration file, e.g., **apache2/conf/httpd.conf**:: LoadModule vhost_alias_module modules/mod_vhost_alias.so +Adding Host Alias +----------------- + Add a host alias in your "hosts" file, typically **/etc/hosts** on unix-type platforms, or **c:/Windows/System32/drivers/etc/hosts** on Windows. Add a line to the file. This could be ``myproject.local`` or ``myproject.test``, for instance:: 127.0.0.1 myproject.local +Setting VirtualHost +------------------- + Add a ```` element for your webapp inside the virtual hosting configuration, e.g., **apache2/conf/extra/httpd-vhost.conf**:: From 0a1e43ad09f58459a35c06b1ee209c6936d76f13 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 8 Jul 2023 09:51:25 +0900 Subject: [PATCH 04/11] docs: add new line --- user_guide_src/source/installation/running.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index c7a5e7e5c4b8..080235aeb19e 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -146,7 +146,9 @@ Adding Host Alias Add a host alias in your "hosts" file, typically **/etc/hosts** on unix-type platforms, or **c:/Windows/System32/drivers/etc/hosts** on Windows. -Add a line to the file. This could be ``myproject.local`` or ``myproject.test``, for instance:: +Add a line to the file. + +This could be ``myproject.local`` or ``myproject.test``, for instance:: 127.0.0.1 myproject.local From c917982843ab55b3b492a715ee1516dbeb75a3f4 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 8 Jul 2023 09:51:44 +0900 Subject: [PATCH 05/11] docs: change sub section order --- .../source/installation/running.rst | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index 080235aeb19e..ce19325ec6ef 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -122,11 +122,6 @@ in the ``AllowOverride`` setting:: Require all granted -Removing the index.php -====================== - -See :ref:`CodeIgniter URLs `. - Virtual Hosting =============== @@ -168,6 +163,13 @@ e.g., **apache2/conf/extra/httpd-vhost.conf**:: If your project folder is not a subfolder of the Apache document root, then your ```` element may need a nested ```` element to grant the web server access to the files. +Testing +======= + +With the above configuration, your webapp would be accessed with the URL **http://myproject.local/** in your browser. + +Apache needs to be restarted whenever you change its configuration. + With mod_userdir (Shared Hosts) =============================== @@ -234,18 +236,16 @@ Be sure to specify options and permissions for the CodeIgniter public directory +Removing the index.php +====================== + +See :ref:`CodeIgniter URLs `. + Setting Environment =================== See :ref:`Handling Multiple Environments `. -Testing -======= - -With the above configuration, your webapp would be accessed with the URL **http://myproject.local/** in your browser. - -Apache needs to be restarted whenever you change its configuration. - ****************** Hosting with Nginx ****************** From fdf3252d2503f15a28041df436fd8a81fe78a969 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 8 Jul 2023 09:57:23 +0900 Subject: [PATCH 06/11] docs: change sub section titles and level --- user_guide_src/source/installation/running.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index ce19325ec6ef..4b99f2179258 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -122,8 +122,8 @@ in the ``AllowOverride`` setting:: Require all granted -Virtual Hosting -=============== +Hosting with VirtualHost +======================== We recommend using "virtual hosting" to run your apps. You can set up different aliases for each of the apps you work on, @@ -164,14 +164,14 @@ If your project folder is not a subfolder of the Apache document root, then your ```` element may need a nested ```` element to grant the web server access to the files. Testing -======= +------- With the above configuration, your webapp would be accessed with the URL **http://myproject.local/** in your browser. Apache needs to be restarted whenever you change its configuration. -With mod_userdir (Shared Hosts) -=============================== +Hosting with mod_userdir (Shared Hosts) +======================================= A common practice in shared hosting environments is to use the Apache module "mod_userdir" to enable per-user Virtual Hosts automatically. Additional configuration is required to allow CodeIgniter4 to be run from these per-user directories. From 18d5cf40091f314a24400338daf07b00c5f4eaee Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 8 Jul 2023 09:59:20 +0900 Subject: [PATCH 07/11] docs: change TOC depth to 3 --- user_guide_src/source/installation/running.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index 4b99f2179258..2c1a3dfdf2d0 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -4,7 +4,7 @@ Running Your App .. contents:: :local: - :depth: 2 + :depth: 3 A CodeIgniter 4 app can be run in a number of different ways: hosted on a web server, using virtualization, or using CodeIgniter's command line tool for testing. From eb465d945caffdaea55c2d087855c8e82ac1047a Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 8 Jul 2023 11:01:31 +0900 Subject: [PATCH 08/11] docs: add ".. code-block:: apache" --- .../source/installation/running.rst | 100 ++++++++++-------- 1 file changed, 57 insertions(+), 43 deletions(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index 2c1a3dfdf2d0..7b763c5ae616 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -106,7 +106,9 @@ The "mod_rewrite" module enables URLs without "index.php" in them, and is assume in our user guide. Make sure that the rewrite module is enabled (uncommented) in the main -configuration file, e.g., **apache2/conf/httpd.conf**:: +configuration file, e.g., **apache2/conf/httpd.conf**: + +.. code-block:: apache LoadModule rewrite_module modules/mod_rewrite.so @@ -114,7 +116,9 @@ Setting Document Root --------------------- Also make sure that the default document root's ```` element enables this too, -in the ``AllowOverride`` setting:: +in the ``AllowOverride`` setting: + +.. code-block:: apache Options Indexes FollowSymLinks @@ -132,7 +136,9 @@ Enabling vhost_alias_module --------------------------- Make sure that the virtual hosting module is enabled (uncommented) in the main -configuration file, e.g., **apache2/conf/httpd.conf**:: +configuration file, e.g., **apache2/conf/httpd.conf**: + +.. code-block:: apache LoadModule vhost_alias_module modules/mod_vhost_alias.so @@ -151,7 +157,9 @@ Setting VirtualHost ------------------- Add a ```` element for your webapp inside the virtual hosting configuration, -e.g., **apache2/conf/extra/httpd-vhost.conf**:: +e.g., **apache2/conf/extra/httpd-vhost.conf**: + +.. code-block:: apache DocumentRoot "/opt/lamp/apache2/htdocs/myproject/public" @@ -179,60 +187,66 @@ The following assumes that the server is already configured for mod_userdir. A g Because CodeIgniter4 expects the server to find the framework front controller at **public/index.php** by default, you must specify this location as an alternative to search for the request (even if CodeIgniter4 is installed within the per-user web directory). -The default user web directory **~/public_html** is specified by the ``UserDir`` directive, typically in **apache2/mods-available/userdir.conf** or **apache2/conf/extra/httpd-userdir.conf**:: +The default user web directory **~/public_html** is specified by the ``UserDir`` directive, typically in **apache2/mods-available/userdir.conf** or **apache2/conf/extra/httpd-userdir.conf**: + +.. code-block:: apache UserDir public_html -So you will need to configure Apache to look for CodeIgniter's public directory first before trying to serve the default:: +So you will need to configure Apache to look for CodeIgniter's public directory first before trying to serve the default: + +.. code-block:: apache UserDir "public_html/public" "public_html" -Be sure to specify options and permissions for the CodeIgniter public directory as well. A **userdir.conf** might look like:: +Be sure to specify options and permissions for the CodeIgniter public directory as well. A **userdir.conf** might look like: + +.. code-block:: apache UserDir "public_html/public" "public_html" UserDir disabled root - AllowOverride All - Options MultiViews Indexes FollowSymLinks - - # Apache <= 2.2: - # Order allow,deny - # Allow from all - - # Apache >= 2.4: - Require all granted - - - # Apache <= 2.2: - # Order deny,allow - # Deny from all - - # Apache >= 2.4: - Require all denied - + AllowOverride All + Options MultiViews Indexes FollowSymLinks + + # Apache <= 2.2: + # Order allow,deny + # Allow from all + + # Apache >= 2.4: + Require all granted + + + # Apache <= 2.2: + # Order deny,allow + # Deny from all + + # Apache >= 2.4: + Require all denied + - AllowOverride All - Options MultiViews Indexes FollowSymLinks - - # Apache <= 2.2: - # Order allow,deny - # Allow from all - - # Apache >= 2.4: - Require all granted - - - # Apache <= 2.2: - # Order deny,allow - # Deny from all - - # Apache >= 2.4: - Require all denied - + AllowOverride All + Options MultiViews Indexes FollowSymLinks + + # Apache <= 2.2: + # Order allow,deny + # Allow from all + + # Apache >= 2.4: + Require all granted + + + # Apache <= 2.2: + # Order deny,allow + # Deny from all + + # Apache >= 2.4: + Require all denied + From 9afea6f090622e8fa58fa034591c6fa6a09b8ce2 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 8 Jul 2023 13:32:36 +0900 Subject: [PATCH 09/11] docs: add new line --- user_guide_src/source/installation/running.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index 7b763c5ae616..1aa88e9b8e64 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -147,8 +147,8 @@ Adding Host Alias Add a host alias in your "hosts" file, typically **/etc/hosts** on unix-type platforms, or **c:/Windows/System32/drivers/etc/hosts** on Windows. -Add a line to the file. +Add a line to the file. This could be ``myproject.local`` or ``myproject.test``, for instance:: 127.0.0.1 myproject.local From d98ec38e635981ff025bed2b3a4252145e6fefb5 Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 8 Jul 2023 13:32:52 +0900 Subject: [PATCH 10/11] docs: change location of project folder and explanin folder structure --- user_guide_src/source/installation/running.rst | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index 1aa88e9b8e64..52b7281bf283 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -162,14 +162,25 @@ e.g., **apache2/conf/extra/httpd-vhost.conf**: .. code-block:: apache - DocumentRoot "/opt/lamp/apache2/htdocs/myproject/public" + DocumentRoot "/opt/lamp/apache2/myproject/public" ServerName myproject.local ErrorLog "logs/myproject-error_log" CustomLog "logs/myproject-access_log" common + + + AllowOverride All + Require all granted + -If your project folder is not a subfolder of the Apache document root, then your -```` element may need a nested ```` element to grant the web server access to the files. +The above configuration assumes the project folder is located as follows: + +.. code-block:: text + + apache2/ + ├── myproject/ (Project Folder) + │ └── public/ (DocumentRoot for myproject.local) + └── htdocs/ Testing ------- From 45165e101c239902a59b7805bdeae29e7d08a0e0 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 12 Jul 2023 06:36:24 +0900 Subject: [PATCH 11/11] docs: fix directory separator for Windows --- user_guide_src/source/installation/running.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/installation/running.rst b/user_guide_src/source/installation/running.rst index 52b7281bf283..eda284684642 100644 --- a/user_guide_src/source/installation/running.rst +++ b/user_guide_src/source/installation/running.rst @@ -146,7 +146,7 @@ Adding Host Alias ----------------- Add a host alias in your "hosts" file, typically **/etc/hosts** on unix-type platforms, -or **c:/Windows/System32/drivers/etc/hosts** on Windows. +or **c:\Windows\System32\drivers\etc\hosts** on Windows. Add a line to the file. This could be ``myproject.local`` or ``myproject.test``, for instance::