CodeIgniter4/installation/running.html
2023-10-22 21:43:30 +00:00

757 lines
56 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Running Your App &mdash; CodeIgniter 4.4.2 documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/citheme.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/citheme_dark.css" type="text/css" />
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<!--[if lt IE 9]>
<script src="../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/js/citheme.js"></script>
<script src="../_static/js/carbon.js"></script>
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Troubleshooting" href="troubleshooting.html" />
<link rel="prev" title="Manual Installation" href="installing_manual.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html">
<img src="../_static/ci-logo-text.svg" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul>
<li class="toctree-l1"><a class="reference internal" href="../intro/index.html">Welcome to CodeIgniter4</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../intro/index.html">Welcome to CodeIgniter4</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intro/requirements.html">Server Requirements</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intro/credits.html">Credits</a></li>
<li class="toctree-l2"><a class="reference internal" href="../intro/psr.html">PSR Compliance</a></li>
<li class="toctree-l2"><a class="reference internal" href="../license.html">License Agreement</a></li>
</ul>
</li>
</ul>
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Installation</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="installing_composer.html">Composer Installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="installing_manual.html">Manual Installation</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Running Your App</a></li>
<li class="toctree-l2"><a class="reference internal" href="troubleshooting.html">Troubleshooting</a></li>
<li class="toctree-l2"><a class="reference internal" href="../changelogs/index.html">Change Logs</a></li>
<li class="toctree-l2"><a class="reference internal" href="upgrading.html">Upgrading From a Previous Version</a></li>
<li class="toctree-l2"><a class="reference internal" href="repositories.html">CodeIgniter Repositories</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../tutorial/index.html">Build Your First Application</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/static_pages.html">Static Pages</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/news_section.html">News Section</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/create_news_items.html">Create News Items</a></li>
<li class="toctree-l2"><a class="reference internal" href="../tutorial/conclusion.html">Conclusion</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../concepts/index.html">CodeIgniter4 Overview</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../concepts/structure.html">Application Structure</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/mvc.html">Models, Views, and Controllers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/autoloader.html">Autoloading Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/services.html">Services</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/factories.html">Factories</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/http.html">Working with HTTP Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="../concepts/security.html">Security Guidelines</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../general/index.html">General Topics</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../general/configuration.html">Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/urls.html">CodeIgniter URLs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/helpers.html">Helper Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/common_functions.html">Global Functions and Constants</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/logging.html">Logging Information</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/errors.html">Error Handling</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/caching.html">Web Page Caching</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/ajax.html">AJAX Requests</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/modules.html">Code Modules</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/managing_apps.html">Managing your Applications</a></li>
<li class="toctree-l2"><a class="reference internal" href="../general/environments.html">Handling Multiple Environments</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../incoming/index.html">Controllers and Routing</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../incoming/routing.html">URI Routing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/controllers.html">Controllers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/filters.html">Controller Filters</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/message.html">HTTP Messages</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/request.html">Request Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/incomingrequest.html">IncomingRequest Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/content_negotiation.html">Content Negotiation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/methodspoofing.html">HTTP Method Spoofing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../incoming/restful.html">RESTful Resource Handling</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../outgoing/index.html">Building Responses</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/views.html">Views</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_cells.html">View Cells</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_renderer.html">View Renderer</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_layouts.html">View Layouts</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_parser.html">View Parser</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/view_decorators.html">View Decorators</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/table.html">HTML Table Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/response.html">HTTP Responses</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/api_responses.html">API Response Trait</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/localization.html">Localization</a></li>
<li class="toctree-l2"><a class="reference internal" href="../outgoing/alternative_php.html">Alternate PHP Syntax for View Files</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../database/index.html">Working with Databases</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../database/examples.html">Quick Start: Usage Examples</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/configuration.html">Database Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/connecting.html">Connecting to a Database</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/queries.html">Running Queries</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/results.html">Generating Query Results</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/helpers.html">Query Helper Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/query_builder.html">Query Builder Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/transactions.html">Transactions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/metadata.html">Getting MetaData</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/call_function.html">Custom Function Calls</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/events.html">Database Events</a></li>
<li class="toctree-l2"><a class="reference internal" href="../database/utilities.html">Database Utilities</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../models/index.html">Modeling Data</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../models/model.html">Using CodeIgniter's Model</a></li>
<li class="toctree-l2"><a class="reference internal" href="../models/entities.html">Using Entity Classes</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../dbmgmt/index.html">Managing Databases</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/forge.html">Database Manipulation with Database Forge</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/migration.html">Database Migrations</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/seeds.html">Database Seeding</a></li>
<li class="toctree-l2"><a class="reference internal" href="../dbmgmt/db_commands.html">Database Commands</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../libraries/index.html">Library Reference</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../libraries/caching.html">Caching Driver</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/cookies.html">Cookies</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/curlrequest.html">CURLRequest Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/email.html">Email Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/encryption.html">Encryption Service</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/files.html">Working with Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/file_collections.html">File Collections</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/honeypot.html">Honeypot Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/images.html">Image Manipulation Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/pagination.html">Pagination</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/publisher.html">Publisher</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/security.html">Security</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/sessions.html">Session Library</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/throttler.html">Throttler</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/time.html">Times and Dates</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/typography.html">Typography</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/uploaded_files.html">Working with Uploaded Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/uri.html">Working with URIs</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/user_agent.html">User Agent Class</a></li>
<li class="toctree-l2"><a class="reference internal" href="../libraries/validation.html">Validation</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../helpers/index.html">Helpers</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../helpers/array_helper.html">Array Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/cookie_helper.html">Cookie Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/date_helper.html">Date Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/filesystem_helper.html">Filesystem Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/form_helper.html">Form Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/html_helper.html">HTML Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/inflector_helper.html">Inflector Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/number_helper.html">Number Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/security_helper.html">Security Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/test_helper.html">Test Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/text_helper.html">Text Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/url_helper.html">URL Helper</a></li>
<li class="toctree-l2"><a class="reference internal" href="../helpers/xml_helper.html">XML Helper</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../testing/index.html">Testing</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../testing/overview.html">Getting Started</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/database.html">Database</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/fabricator.html">Generating Data</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/controllers.html">Controller Testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/feature.html">HTTP Testing</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/response.html">Testing Responses</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/benchmark.html">Benchmarking</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/debugging.html">Debugging Your Application</a></li>
<li class="toctree-l2"><a class="reference internal" href="../testing/mocking.html">Mocking</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../cli/index.html">Command Line Usage</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_overview.html">CLI Overview</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_controllers.html">Running Controllers via CLI</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli/spark_commands.html">Spark Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_commands.html">Creating Spark Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_generators.html">CLI Generators</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_library.html">CLI Library</a></li>
<li class="toctree-l2"><a class="reference internal" href="../cli/cli_request.html">CLIRequest Class</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../extending/index.html">Extending CodeIgniter</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../extending/core_classes.html">Creating Core System Classes</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/common.html">Replacing Common Functions</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/events.html">Events</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/basecontroller.html">Extending the Controller</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/authentication.html">Authentication</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/composer_packages.html">Creating Composer Packages</a></li>
<li class="toctree-l2"><a class="reference internal" href="../extending/contributing.html">Contributing to CodeIgniter</a></li>
</ul>
</li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../libraries/official_packages.html">Official Packages</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">CodeIgniter</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<a class="btn btn-neutral float-right" href="https://github.com/codeigniter4/CodeIgniter4/edit/develop/user_guide_src/source/installation/running.rst">Edit this page</a>
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="index.html">Installation</a></li>
<li class="breadcrumb-item active">Running Your App</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="running-your-app">
<h1>Running Your App<a class="headerlink" href="#running-your-app" title="Permalink to this headline"></a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><p><a class="reference internal" href="#initial-configuration" id="id3">Initial Configuration</a></p>
<ul>
<li><p><a class="reference internal" href="#configure-for-your-site-uris" id="id4">Configure for Your Site URIs</a></p></li>
<li><p><a class="reference internal" href="#configure-database-connection-settings" id="id5">Configure Database Connection Settings</a></p></li>
<li><p><a class="reference internal" href="#set-to-development-mode" id="id6">Set to Development Mode</a></p></li>
<li><p><a class="reference internal" href="#set-writable-folder-permission" id="id7">Set Writable Folder Permission</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#local-development-server" id="id8">Local Development Server</a></p></li>
<li><p><a class="reference internal" href="#hosting-with-apache" id="id9">Hosting with Apache</a></p>
<ul>
<li><p><a class="reference internal" href="#configure-main-config-file" id="id10">Configure Main Config File</a></p>
<ul>
<li><p><a class="reference internal" href="#enabling-mod-rewrite" id="id11">Enabling mod_rewrite</a></p></li>
<li><p><a class="reference internal" href="#setting-document-root" id="id12">Setting Document Root</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#hosting-with-virtualhost" id="id13">Hosting with VirtualHost</a></p>
<ul>
<li><p><a class="reference internal" href="#enabling-vhost-alias-module" id="id14">Enabling vhost_alias_module</a></p></li>
<li><p><a class="reference internal" href="#adding-host-alias" id="id15">Adding Host Alias</a></p></li>
<li><p><a class="reference internal" href="#setting-virtualhost" id="id16">Setting VirtualHost</a></p></li>
<li><p><a class="reference internal" href="#testing" id="id17">Testing</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#hosting-with-subfolder" id="id18">Hosting with Subfolder</a></p>
<ul>
<li><p><a class="reference internal" href="#making-symlink" id="id19">Making Symlink</a></p></li>
<li><p><a class="reference internal" href="#using-alias" id="id20">Using Alias</a></p></li>
<li><p><a class="reference internal" href="#adding-htaccess" id="id21">Adding .htaccess</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#hosting-with-mod-userdir-shared-hosts" id="id22">Hosting with mod_userdir (Shared Hosts)</a></p></li>
<li><p><a class="reference internal" href="#removing-the-index-php" id="id23">Removing the index.php</a></p></li>
<li><p><a class="reference internal" href="#setting-environment" id="id24">Setting Environment</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#hosting-with-nginx" id="id25">Hosting with nginx</a></p>
<ul>
<li><p><a class="reference internal" href="#default-conf" id="id26">default.conf</a></p></li>
<li><p><a class="reference internal" href="#id2" id="id27">Setting Environment</a></p></li>
</ul>
</li>
<li><p><a class="reference internal" href="#bootstrapping-the-app" id="id28">Bootstrapping the App</a></p></li>
</ul>
</div>
<p>A CodeIgniter 4 app can be run in a number of different ways: hosted on a web server,
using virtualization, or using CodeIgniters command line tool for testing.
This section addresses how to use each technique, and explains some of the pros and cons of them.</p>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>You should always be careful about the case of filenames. Many
developers develop on case-insensitive file systems on Windows or macOS.
However, most server environments use case-sensitive file systems. If the
file name case is incorrect, code that works locally will not work on the
server.</p>
</div>
<p>If youre new to CodeIgniter, please read the <a class="reference internal" href="../intro/index.html"><span class="doc">Getting Started</span></a>
section of the User Guide to begin learning how to build dynamic PHP applications. Enjoy!</p>
<section id="initial-configuration">
<span id="id1"></span><h2><a class="toc-backref" href="#id3">Initial Configuration</a><a class="headerlink" href="#initial-configuration" title="Permalink to this headline"></a></h2>
<section id="configure-for-your-site-uris">
<h3><a class="toc-backref" href="#id4">Configure for Your Site URIs</a><a class="headerlink" href="#configure-for-your-site-uris" title="Permalink to this headline"></a></h3>
<p>Open the <strong>app/Config/App.php</strong> file with a text editor.</p>
<ol class="arabic">
<li><dl>
<dt>$baseURL</dt><dd><p>Set your base URL to <code class="docutils literal notranslate"><span class="pre">$baseURL</span></code>. If you need more flexibility, the baseURL may
be set within the <a class="reference internal" href="../general/configuration.html#dotenv-file"><span class="std std-ref">.env</span></a> file as <code class="docutils literal notranslate"><span class="pre">app.baseURL</span> <span class="pre">=</span> <span class="pre">'http://example.com/'</span></code>.
<strong>Always use a trailing slash on your base URL!</strong></p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If you dont set the <code class="docutils literal notranslate"><span class="pre">baseURL</span></code> correctly, in development mode,
the debug toolbar may not load properly and web pages may take considerably
longer to display.</p>
</div>
</dd>
</dl>
</li>
<li><dl>
<dt>$indexPage</dt><dd><p>If you dont want to include <strong>index.php</strong> in your site URIs, set <code class="docutils literal notranslate"><span class="pre">$indexPage</span></code> to <code class="docutils literal notranslate"><span class="pre">''</span></code>.
The setting will be used when the framework generates your site URIs.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>You may need to configure your web server to access your site with a URL
that does not contain <strong>index.php</strong>. See <a class="reference internal" href="../general/urls.html#urls-remove-index-php"><span class="std std-ref">CodeIgniter URLs</span></a>.</p>
</div>
</dd>
</dl>
</li>
</ol>
</section>
<section id="configure-database-connection-settings">
<h3><a class="toc-backref" href="#id5">Configure Database Connection Settings</a><a class="headerlink" href="#configure-database-connection-settings" title="Permalink to this headline"></a></h3>
<p>If you intend to use a database, open the
<strong>app/Config/Database.php</strong> file with a text editor and set your
database settings. Alternately, these could be set in your <strong>.env</strong> file.</p>
</section>
<section id="set-to-development-mode">
<h3><a class="toc-backref" href="#id6">Set to Development Mode</a><a class="headerlink" href="#set-to-development-mode" title="Permalink to this headline"></a></h3>
<p>If it is not on the production server, set <code class="docutils literal notranslate"><span class="pre">CI_ENVIRONMENT</span></code> to <code class="docutils literal notranslate"><span class="pre">development</span></code>
in <strong>.env</strong> file to take advantage of the debugging tools provided. See
<a class="reference internal" href="../tutorial/index.html#setting-development-mode"><span class="std std-ref">Setting Development Mode</span></a> for the detail.</p>
<div class="admonition important">
<p class="admonition-title">Important</p>
<p>In production environments, you should disable error display and
any other development-only functionality. In CodeIgniter, this can be done
by setting the environment to “production”. By default, the application will
run using the “production” environment. See also <a class="reference internal" href="../general/environments.html#environment-constant"><span class="std std-ref">The ENVIRONMENT Constant</span></a>.</p>
</div>
</section>
<section id="set-writable-folder-permission">
<h3><a class="toc-backref" href="#id7">Set Writable Folder Permission</a><a class="headerlink" href="#set-writable-folder-permission" title="Permalink to this headline"></a></h3>
<p>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 <strong>writable</strong> folder inside
your project, so that it is writable by the user or account used by your
web server.</p>
</section>
</section>
<section id="local-development-server">
<h2><a class="toc-backref" href="#id8">Local Development Server</a><a class="headerlink" href="#local-development-server" title="Permalink to this headline"></a></h2>
<p>CodeIgniter 4 comes with a local development server, leveraging PHPs built-in web server
with CodeIgniter routing. You can launch it, with the following command line
in the main directory:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">php spark serve</span>
</pre></div>
</div>
<p>This will launch the server and you can now view your application in your browser at <a class="reference external" href="http://localhost:8080">http://localhost:8080</a>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>The built-in development server should only be used on local development machines. It should NEVER
be used on a production server.</p>
</div>
<p>If you need to run the site on a host other than simply localhost, youll first need to add the host
to your <strong>hosts</strong> 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 <strong>/etc/hosts</strong>.</p>
<p>The local development server can be customized with three command line options:</p>
<ul>
<li><p>You can use the <code class="docutils literal notranslate"><span class="pre">--host</span></code> CLI option to specify a different host to run the application at:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">php spark serve --host example.dev</span>
</pre></div>
</div>
</div></blockquote>
</li>
<li><p>By default, the server runs on port 8080 but you might have more than one site running, or already have
another application using that port. You can use the <code class="docutils literal notranslate"><span class="pre">--port</span></code> CLI option to specify a different one:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">php spark serve --port 8081</span>
</pre></div>
</div>
</div></blockquote>
</li>
<li><p>You can also specify a specific version of PHP to use, with the <code class="docutils literal notranslate"><span class="pre">--php</span></code> CLI option, with its value
set to the path of the PHP executable you want to use:</p>
<blockquote>
<div><div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">php spark serve --php /usr/bin/php7.6.5.4</span>
</pre></div>
</div>
</div></blockquote>
</li>
</ul>
</section>
<section id="hosting-with-apache">
<h2><a class="toc-backref" href="#id9">Hosting with Apache</a><a class="headerlink" href="#hosting-with-apache" title="Permalink to this headline"></a></h2>
<p>A CodeIgniter4 webapp is normally hosted on a web server.
Apache HTTP Server is the “standard” platform, and assumed in much of our documentation.</p>
<p>Apache is bundled with many platforms, but can also be downloaded in a bundle
with a database engine and PHP from <a class="reference external" href="https://bitnami.com/stacks/infrastructure">Bitnami</a>.</p>
<section id="configure-main-config-file">
<h3><a class="toc-backref" href="#id10">Configure Main Config File</a><a class="headerlink" href="#configure-main-config-file" title="Permalink to this headline"></a></h3>
<section id="enabling-mod-rewrite">
<h4><a class="toc-backref" href="#id11">Enabling mod_rewrite</a><a class="headerlink" href="#enabling-mod-rewrite" title="Permalink to this headline"></a></h4>
<p>The “mod_rewrite” module enables URLs without “index.php” in them, and is assumed
in our user guide.</p>
<p>Make sure that the rewrite module is enabled (uncommented) in the main
configuration file, e.g., <strong>apache2/conf/httpd.conf</strong>:</p>
<div class="highlight-apache notranslate"><div class="highlight"><pre><span></span><span class="nb">LoadModule</span><span class="w"> </span>rewrite_module<span class="w"> </span>modules/mod_rewrite.so
</pre></div>
</div>
</section>
<section id="setting-document-root">
<h4><a class="toc-backref" href="#id12">Setting Document Root</a><a class="headerlink" href="#setting-document-root" title="Permalink to this headline"></a></h4>
<p>Also make sure that the default document roots <code class="docutils literal notranslate"><span class="pre">&lt;Directory&gt;</span></code> element enables this too,
in the <code class="docutils literal notranslate"><span class="pre">AllowOverride</span></code> setting:</p>
<div class="highlight-apache notranslate"><div class="highlight"><pre><span></span><span class="nt">&lt;Directory</span><span class="w"> </span><span class="s">&quot;/opt/lamp/apache2/htdocs&quot;</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="nb">Options</span><span class="w"> </span>Indexes<span class="w"> </span>FollowSymLinks
<span class="w"> </span><span class="nb">AllowOverride</span><span class="w"> </span><span class="k">All</span>
<span class="w"> </span><span class="nb">Require</span><span class="w"> </span><span class="k">all</span><span class="w"> </span>granted
<span class="nt">&lt;/Directory&gt;</span>
</pre></div>
</div>
</section>
</section>
<section id="hosting-with-virtualhost">
<h3><a class="toc-backref" href="#id13">Hosting with VirtualHost</a><a class="headerlink" href="#hosting-with-virtualhost" title="Permalink to this headline"></a></h3>
<p>We recommend using “virtual hosting” to run your apps.
You can set up different aliases for each of the apps you work on,</p>
<section id="enabling-vhost-alias-module">
<h4><a class="toc-backref" href="#id14">Enabling vhost_alias_module</a><a class="headerlink" href="#enabling-vhost-alias-module" title="Permalink to this headline"></a></h4>
<p>Make sure that the virtual hosting module is enabled (uncommented) in the main
configuration file, e.g., <strong>apache2/conf/httpd.conf</strong>:</p>
<div class="highlight-apache notranslate"><div class="highlight"><pre><span></span><span class="nb">LoadModule</span><span class="w"> </span>vhost_alias_module<span class="w"> </span>modules/mod_vhost_alias.so
</pre></div>
</div>
</section>
<section id="adding-host-alias">
<h4><a class="toc-backref" href="#id15">Adding Host Alias</a><a class="headerlink" href="#adding-host-alias" title="Permalink to this headline"></a></h4>
<p>Add a host alias in your “hosts” file, typically <strong>/etc/hosts</strong> on unix-type platforms,
or <strong>c:WindowsSystem32driversetchosts</strong> on Windows.</p>
<p>Add a line to the file.
This could be <code class="docutils literal notranslate"><span class="pre">myproject.local</span></code> or <code class="docutils literal notranslate"><span class="pre">myproject.test</span></code>, for instance:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="mf">127.0</span><span class="o">.</span><span class="mf">0.1</span> <span class="nx">myproject</span><span class="o">.</span><span class="nx">local</span>
</pre></div>
</div>
</section>
<section id="setting-virtualhost">
<h4><a class="toc-backref" href="#id16">Setting VirtualHost</a><a class="headerlink" href="#setting-virtualhost" title="Permalink to this headline"></a></h4>
<p>Add a <code class="docutils literal notranslate"><span class="pre">&lt;VirtualHost&gt;</span></code> element for your webapp inside the virtual hosting configuration,
e.g., <strong>apache2/conf/extra/httpd-vhost.conf</strong>:</p>
<div class="highlight-apache notranslate"><div class="highlight"><pre><span></span><span class="nt">&lt;VirtualHost</span><span class="w"> </span><span class="s">*:80</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="nb">DocumentRoot</span><span class="w"> </span><span class="s2">&quot;/opt/lamp/apache2/myproject/public&quot;</span>
<span class="w"> </span><span class="nb">ServerName</span><span class="w"> </span>myproject.local
<span class="w"> </span><span class="nb">ErrorLog</span><span class="w"> </span><span class="s2">&quot;logs/myproject-error_log&quot;</span>
<span class="w"> </span><span class="nb">CustomLog</span><span class="w"> </span><span class="s2">&quot;logs/myproject-access_log&quot;</span><span class="w"> </span>common
<span class="w"> </span><span class="nt">&lt;Directory</span><span class="w"> </span><span class="s">&quot;/opt/lamp/apache2/myproject/public&quot;</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="nb">AllowOverride</span><span class="w"> </span><span class="k">All</span>
<span class="w"> </span><span class="nb">Require</span><span class="w"> </span><span class="k">all</span><span class="w"> </span>granted
<span class="w"> </span><span class="nt">&lt;/Directory&gt;</span>
<span class="nt">&lt;/VirtualHost&gt;</span>
</pre></div>
</div>
<p>The above configuration assumes the project folder is located as follows:</p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>apache2/
├── myproject/ (Project Folder)
│ └── public/ (DocumentRoot for myproject.local)
└── htdocs/
</pre></div>
</div>
<p>Restart Apache.</p>
</section>
<section id="testing">
<h4><a class="toc-backref" href="#id17">Testing</a><a class="headerlink" href="#testing" title="Permalink to this headline"></a></h4>
<p>With the above configuration, your webapp would be accessed with the URL <strong>http://myproject.local/</strong> in your browser.</p>
<p>Apache needs to be restarted whenever you change its configuration.</p>
</section>
</section>
<section id="hosting-with-subfolder">
<h3><a class="toc-backref" href="#id18">Hosting with Subfolder</a><a class="headerlink" href="#hosting-with-subfolder" title="Permalink to this headline"></a></h3>
<p>If you want a baseURL like <strong>http://localhost/myproject/</strong> with a subfolder,
there are three ways.</p>
<section id="making-symlink">
<h4><a class="toc-backref" href="#id19">Making Symlink</a><a class="headerlink" href="#making-symlink" title="Permalink to this headline"></a></h4>
<p>Place your project folder as follows, where <strong>htdocs</strong> is the Apache document root:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="nx">├──</span> <span class="nx">myproject</span><span class="o">/</span> <span class="p">(</span><span class="nx">project</span> <span class="nx">folder</span><span class="p">)</span>
<span class="nx"></span> <span class="nx">└──</span> <span class="k">public</span><span class="o">/</span>
<span class="nx">└──</span> <span class="nx">htdocs</span><span class="o">/</span>
</pre></div>
</div>
<p>Navigate to the <strong>htdocs</strong> folder and create a symbolic link as follows:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="go">cd htdocs/</span>
<span class="go">ln -s ../myproject/public/ myproject</span>
</pre></div>
</div>
</section>
<section id="using-alias">
<h4><a class="toc-backref" href="#id20">Using Alias</a><a class="headerlink" href="#using-alias" title="Permalink to this headline"></a></h4>
<p>Place your project folder as follows, where <strong>htdocs</strong> is the Apache document root:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="nx">├──</span> <span class="nx">myproject</span><span class="o">/</span> <span class="p">(</span><span class="nx">project</span> <span class="nx">folder</span><span class="p">)</span>
<span class="nx"></span> <span class="nx">└──</span> <span class="k">public</span><span class="o">/</span>
<span class="nx">└──</span> <span class="nx">htdocs</span><span class="o">/</span>
</pre></div>
</div>
<p>Add the following in the main configuration file, e.g., <strong>apache2/conf/httpd.conf</strong>:</p>
<div class="highlight-apache notranslate"><div class="highlight"><pre><span></span><span class="nb">Alias</span><span class="w"> </span><span class="sx">/myproject</span><span class="w"> </span><span class="sx">/opt/lamp/apache2/myproject/public</span>
<span class="nt">&lt;Directory</span><span class="w"> </span><span class="s">&quot;/opt/lamp/apache2/myproject/public&quot;</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="nb">AllowOverride</span><span class="w"> </span><span class="k">All</span>
<span class="w"> </span><span class="nb">Require</span><span class="w"> </span><span class="k">all</span><span class="w"> </span>granted
<span class="nt">&lt;/Directory&gt;</span>
</pre></div>
</div>
<p>Restart Apache.</p>
</section>
<section id="adding-htaccess">
<h4><a class="toc-backref" href="#id21">Adding .htaccess</a><a class="headerlink" href="#adding-htaccess" title="Permalink to this headline"></a></h4>
<p>The last resort is to add <strong>.htaccess</strong> to the project root.</p>
<p>It is not recommended that you place the project folder in the document root.
However, if you have no other choice, like on a shared server, you can use this.</p>
<p>Place your project folder as follows, where <strong>htdocs</strong> is the Apache document root,
and create the <strong>.htaccess</strong> file:</p>
<div class="highlight-html+php notranslate"><div class="highlight"><pre><span></span><span class="nx">└──</span> <span class="nx">htdocs</span><span class="o">/</span>
<span class="nx">└──</span> <span class="nx">myproject</span><span class="o">/</span> <span class="p">(</span><span class="nx">project</span> <span class="nx">folder</span><span class="p">)</span>
<span class="nx">├──</span> <span class="o">.</span><span class="nx">htaccess</span>
<span class="nx">└──</span> <span class="k">public</span><span class="o">/</span>
</pre></div>
</div>
<p>And edit <strong>.htaccess</strong> as follows:</p>
<div class="highlight-apache notranslate"><div class="highlight"><pre><span></span><span class="nt">&lt;IfModule</span><span class="w"> </span><span class="s">mod_rewrite.c</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="nb">RewriteEngine</span><span class="w"> </span><span class="k">On</span>
<span class="w"> </span><span class="nb">RewriteRule</span><span class="w"> </span>^(.*)$<span class="w"> </span>public/$1<span class="w"> </span>[L]
<span class="nt">&lt;/IfModule&gt;</span>
<span class="nt">&lt;FilesMatch</span><span class="w"> </span><span class="s">&quot;^\.&quot;</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="nb">Require</span><span class="w"> </span><span class="k">all</span><span class="w"> </span>denied
<span class="w"> </span><span class="nb">Satisfy</span><span class="w"> </span><span class="k">All</span>
<span class="nt">&lt;/FilesMatch&gt;</span>
</pre></div>
</div>
</section>
</section>
<section id="hosting-with-mod-userdir-shared-hosts">
<h3><a class="toc-backref" href="#id22">Hosting with mod_userdir (Shared Hosts)</a><a class="headerlink" href="#hosting-with-mod-userdir-shared-hosts" title="Permalink to this headline"></a></h3>
<p>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.</p>
<p>The following assumes that the server is already configured for mod_userdir. A guide to enabling this module is available <a class="reference external" href="https://httpd.apache.org/docs/2.4/howto/public_html.html">in the Apache documentation</a>.</p>
<p>Because CodeIgniter4 expects the server to find the framework front controller at <strong>public/index.php</strong> 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).</p>
<p>The default user web directory <strong>~/public_html</strong> is specified by the <code class="docutils literal notranslate"><span class="pre">UserDir</span></code> directive, typically in <strong>apache2/mods-available/userdir.conf</strong> or <strong>apache2/conf/extra/httpd-userdir.conf</strong>:</p>
<div class="highlight-apache notranslate"><div class="highlight"><pre><span></span><span class="nb">UserDir</span><span class="w"> </span>public_html
</pre></div>
</div>
<p>So you will need to configure Apache to look for CodeIgniters public directory first before trying to serve the default:</p>
<div class="highlight-apache notranslate"><div class="highlight"><pre><span></span><span class="nb">UserDir</span><span class="w"> </span><span class="s2">&quot;public_html/public&quot;</span><span class="w"> </span><span class="s2">&quot;public_html&quot;</span>
</pre></div>
</div>
<p>Be sure to specify options and permissions for the CodeIgniter public directory as well. A <strong>userdir.conf</strong> might look like:</p>
<div class="highlight-apache notranslate"><div class="highlight"><pre><span></span><span class="nt">&lt;IfModule</span><span class="w"> </span><span class="s">mod_userdir.c</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="nb">UserDir</span><span class="w"> </span><span class="s2">&quot;public_html/public&quot;</span><span class="w"> </span><span class="s2">&quot;public_html&quot;</span>
<span class="w"> </span><span class="nb">UserDir</span><span class="w"> </span>disabled<span class="w"> </span>root
<span class="w"> </span><span class="nt">&lt;Directory</span><span class="w"> </span><span class="s">/home/*/public_html</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="nb">AllowOverride</span><span class="w"> </span><span class="k">All</span>
<span class="w"> </span><span class="nb">Options</span><span class="w"> </span>MultiViews<span class="w"> </span>Indexes<span class="w"> </span>FollowSymLinks
<span class="w"> </span><span class="nt">&lt;Limit</span><span class="w"> </span><span class="s">GET POST OPTIONS</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="c"># Apache &lt;= 2.2:</span>
<span class="w"> </span><span class="c"># Order allow,deny</span>
<span class="w"> </span><span class="c"># Allow from all</span>
<span class="w"> </span><span class="c"># Apache &gt;= 2.4:</span>
<span class="w"> </span><span class="nb">Require</span><span class="w"> </span><span class="k">all</span><span class="w"> </span>granted
<span class="w"> </span><span class="nt">&lt;/Limit&gt;</span>
<span class="w"> </span><span class="nt">&lt;LimitExcept</span><span class="w"> </span><span class="s">GET POST OPTIONS</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="c"># Apache &lt;= 2.2:</span>
<span class="w"> </span><span class="c"># Order deny,allow</span>
<span class="w"> </span><span class="c"># Deny from all</span>
<span class="w"> </span><span class="c"># Apache &gt;= 2.4:</span>
<span class="w"> </span><span class="nb">Require</span><span class="w"> </span><span class="k">all</span><span class="w"> </span>denied
<span class="w"> </span><span class="nt">&lt;/LimitExcept&gt;</span>
<span class="w"> </span><span class="nt">&lt;/Directory&gt;</span>
<span class="w"> </span><span class="nt">&lt;Directory</span><span class="w"> </span><span class="s">/home/*/public_html/public</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="nb">AllowOverride</span><span class="w"> </span><span class="k">All</span>
<span class="w"> </span><span class="nb">Options</span><span class="w"> </span>MultiViews<span class="w"> </span>Indexes<span class="w"> </span>FollowSymLinks
<span class="w"> </span><span class="nt">&lt;Limit</span><span class="w"> </span><span class="s">GET POST OPTIONS</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="c"># Apache &lt;= 2.2:</span>
<span class="w"> </span><span class="c"># Order allow,deny</span>
<span class="w"> </span><span class="c"># Allow from all</span>
<span class="w"> </span><span class="c"># Apache &gt;= 2.4:</span>
<span class="w"> </span><span class="nb">Require</span><span class="w"> </span><span class="k">all</span><span class="w"> </span>granted
<span class="w"> </span><span class="nt">&lt;/Limit&gt;</span>
<span class="w"> </span><span class="nt">&lt;LimitExcept</span><span class="w"> </span><span class="s">GET POST OPTIONS</span><span class="nt">&gt;</span>
<span class="w"> </span><span class="c"># Apache &lt;= 2.2:</span>
<span class="w"> </span><span class="c"># Order deny,allow</span>
<span class="w"> </span><span class="c"># Deny from all</span>
<span class="w"> </span><span class="c"># Apache &gt;= 2.4:</span>
<span class="w"> </span><span class="nb">Require</span><span class="w"> </span><span class="k">all</span><span class="w"> </span>denied
<span class="w"> </span><span class="nt">&lt;/LimitExcept&gt;</span>
<span class="w"> </span><span class="nt">&lt;/Directory&gt;</span>
<span class="nt">&lt;/IfModule&gt;</span>
</pre></div>
</div>
</section>
<section id="removing-the-index-php">
<h3><a class="toc-backref" href="#id23">Removing the index.php</a><a class="headerlink" href="#removing-the-index-php" title="Permalink to this headline"></a></h3>
<p>See <a class="reference internal" href="../general/urls.html#urls-remove-index-php-apache"><span class="std std-ref">CodeIgniter URLs</span></a>.</p>
</section>
<section id="setting-environment">
<h3><a class="toc-backref" href="#id24">Setting Environment</a><a class="headerlink" href="#setting-environment" title="Permalink to this headline"></a></h3>
<p>See <a class="reference internal" href="../general/environments.html#environment-apache"><span class="std std-ref">Handling Multiple Environments</span></a>.</p>
</section>
</section>
<section id="hosting-with-nginx">
<h2><a class="toc-backref" href="#id25">Hosting with nginx</a><a class="headerlink" href="#hosting-with-nginx" title="Permalink to this headline"></a></h2>
<p>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.</p>
<section id="default-conf">
<h3><a class="toc-backref" href="#id26">default.conf</a><a class="headerlink" href="#default-conf" title="Permalink to this headline"></a></h3>
<p>This configuration enables URLs without “index.php” in them and using CodeIgniters “404 - File Not Found” for URLs ending with “.php”.</p>
<div class="highlight-nginx notranslate"><div class="highlight"><pre><span></span><span class="k">server</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kn">listen</span><span class="w"> </span><span class="mi">80</span><span class="p">;</span>
<span class="w"> </span><span class="kn">listen</span><span class="w"> </span><span class="s">[::]:80</span><span class="p">;</span>
<span class="w"> </span><span class="kn">server_name</span><span class="w"> </span><span class="s">example.com</span><span class="p">;</span>
<span class="w"> </span><span class="kn">root</span><span class="w"> </span><span class="s">/var/www/example.com/public</span><span class="p">;</span>
<span class="w"> </span><span class="kn">index</span><span class="w"> </span><span class="s">index.php</span><span class="w"> </span><span class="s">index.html</span><span class="w"> </span><span class="s">index.htm</span><span class="p">;</span>
<span class="w"> </span><span class="kn">location</span><span class="w"> </span><span class="s">/</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kn">try_files</span><span class="w"> </span><span class="nv">$uri</span><span class="w"> </span><span class="nv">$uri/</span><span class="w"> </span><span class="s">/index.php</span><span class="nv">$is_args$args</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="kn">location</span><span class="w"> </span><span class="p">~</span><span class="w"> </span><span class="sr">\.php$</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kn">include</span><span class="w"> </span><span class="s">snippets/fastcgi-php.conf</span><span class="p">;</span>
<span class="w"> </span><span class="c1"># With php-fpm:</span>
<span class="w"> </span><span class="kn">fastcgi_pass</span><span class="w"> </span><span class="s">unix:/run/php/php8.1-fpm.sock</span><span class="p">;</span>
<span class="w"> </span><span class="c1"># With php-cgi:</span>
<span class="w"> </span><span class="c1"># fastcgi_pass 127.0.0.1:9000;</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="kn">error_page</span><span class="w"> </span><span class="mi">404</span><span class="w"> </span><span class="s">/index.php</span><span class="p">;</span>
<span class="w"> </span><span class="c1"># deny access to hidden files such as .htaccess</span>
<span class="w"> </span><span class="kn">location</span><span class="w"> </span><span class="p">~</span><span class="w"> </span><span class="sr">/\.</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kn">deny</span><span class="w"> </span><span class="s">all</span><span class="p">;</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</section>
<section id="id2">
<h3><a class="toc-backref" href="#id27">Setting Environment</a><a class="headerlink" href="#id2" title="Permalink to this headline"></a></h3>
<p>See <a class="reference internal" href="../general/environments.html#environment-nginx"><span class="std std-ref">Handling Multiple Environments</span></a>.</p>
</section>
</section>
<section id="bootstrapping-the-app">
<h2><a class="toc-backref" href="#id28">Bootstrapping the App</a><a class="headerlink" href="#bootstrapping-the-app" title="Permalink to this headline"></a></h2>
<p>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: <strong>system/Test/bootstrap.php</strong>.</p>
<p>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
paths align with the expected directory structure for your installation method.</p>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="installing_manual.html" class="btn btn-neutral float-left" title="Manual Installation" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="troubleshooting.html" class="btn btn-neutral float-right" title="Troubleshooting" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2019-2023 CodeIgniter Foundation.
<span class="lastupdated">Last updated on Oct 22, 2023.
</span></p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(false);
});
</script>
</body>
</html>