Skip to content
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
48 changes: 24 additions & 24 deletions user_guide_src/source/installation/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ Initial Configuration
run using the "production" environment. See also :ref:`environment-constant`.

.. note:: If you will be running your site using a web server (e.g., Apache or Nginx),
you will need to modify the permissions for the ``writable`` folder inside
you will need to modify the permissions for the **writable** folder inside
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 use the ``serve`` script to launch it,
with the following command line in the main directory::
with CodeIgniter routing. You can launch it, with the following command line
in the main directory::

> php spark serve

Expand All @@ -64,8 +64,8 @@ This will launch the server and you can now view your application in your browse
be used on a production server.

If you need to run the site on a host other than simply localhost, you'll first need to add the host
to your ``hosts`` file. The exact location of the file varies in each of the main operating systems, though
all unix-type systems (include OS X) will typically keep the file at **/etc/hosts**.
to your **hosts** file. The exact location of the file varies in each of the main operating systems, though
all unix-type systems (including macOS) will typically keep the file at **/etc/hosts**.

The local development server can be customized with three command line options:

Expand All @@ -87,7 +87,7 @@ Hosting with Apache
===================

A CodeIgniter4 webapp is normally hosted on a web server.
Apache's ``httpd`` is the "standard" platform, and assumed in much of our documentation.
Apache HTTP Server is the "standard" platform, and assumed in much of our documentation.

Apache is bundled with many platforms, but can also be downloaded in a bundle
with a database engine and PHP from `Bitnami <https://bitnami.com/stacks/infrastructure>`_.
Expand All @@ -99,12 +99,12 @@ 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**::

LoadModule rewrite_module modules/mod_rewrite.so

Also make sure that the default document root's <Directory> element enables this too,
in the "AllowOverride" setting::
Also make sure that the default document root's ``<Directory>`` element enables this too,
in the ``AllowOverride`` setting::

<Directory "/opt/lamp/apache2/htdocs">
Options Indexes FollowSymLinks
Expand All @@ -124,18 +124,18 @@ We recommend using "virtual hosting" to run your apps.
You can set up different aliases for each of the apps you work on,

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**::

LoadModule vhost_alias_module modules/mod_vhost_alias.so

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 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

Add a <VirtualHost> element for your webapp inside the virtual hosting configuration,
e.g., ``apache2/conf/extra/httpd-vhost.conf``::
Add a ``<VirtualHost>`` element for your webapp inside the virtual hosting configuration,
e.g., **apache2/conf/extra/httpd-vhost.conf**::

<VirtualHost *:80>
DocumentRoot "/opt/lamp/apache2/htdocs/myproject/public"
Expand All @@ -145,26 +145,26 @@ e.g., ``apache2/conf/extra/httpd-vhost.conf``::
</VirtualHost>

If your project folder is not a subfolder of the Apache document root, then your
<VirtualHost> element may need a nested <Directory> element to grant the web server access to the files.
``<VirtualHost>`` element may need a nested ``<Directory>`` element to grant the web server access to the files.

With mod_userdir (shared hosts)
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.

The following assumes that the server is already configured for mod_userdir. A guide to enabling this module is available `in the Apache documentation <https://httpd.apache.org/docs/2.4/howto/public_html.html>`_.

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).
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**::

UserDir public_html

So you will need to configure Apache to look for CodeIgniter's public directory first before trying to serve the default::

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::

<IfModule mod_userdir.c>
UserDir "public_html/public" "public_html"
Expand Down Expand Up @@ -221,15 +221,15 @@ See :ref:`Handling Multiple Environments <environment-apache>`.
Testing
-------

With the above configuration, your webapp would be accessed with the URL ``http://myproject.local`` in your browser.
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 7.3 FPM (unix sockets) under Ubuntu Server.
Here you can find an example configuration using PHP 8.1 FPM (unix sockets) under Ubuntu Server.

default.conf
------------
Expand All @@ -255,7 +255,7 @@ This configuration enables URLs without "index.php" in them and using CodeIgnite
include snippets/fastcgi-php.conf;

# With php-fpm:
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
fastcgi_pass unix:/run/php/php8.1-fpm.sock;
# With php-cgi:
# fastcgi_pass 127.0.0.1:9000;
}
Expand All @@ -279,7 +279,7 @@ 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
handy for using third-party tools to analyze and modify your code. The framework comes
with a separate bootstrap script specifically for this scenario: ``system/Test/bootstrap.php``.
with a separate bootstrap script specifically for this scenario: **system/Test/bootstrap.php**.

Most of the paths to your project are defined during the bootstrap process. You may use
pre-defined constants to override these, but when using the defaults be sure that your
Expand Down