@@ -5,8 +5,8 @@ Running Your App
55 :local:
66 :depth: 1
77
8- A CodeIgniter 4 app can be run in a number of different ways: hosted on a web server,
9- using virtualization, or using CodeIgniter’s command line tool for testing.
8+ A CodeIgniter 4 app can be run in a number of different ways: hosted on a web server,
9+ using virtualization, or using CodeIgniter’s command line tool for testing.
1010This section addresses how to use each technique, and explains some of the pros and cons of them.
1111
1212If you’re new to CodeIgniter, please read the :doc: `Getting Started </intro/index >`
@@ -72,24 +72,24 @@ The local development server can be customized with three command line options:
7272Hosting with Apache
7373=================================================
7474
75- A CodeIgniter4 webapp is normally hosted on a web server.
75+ A CodeIgniter4 webapp is normally hosted on a web server.
7676Apache’s ``httpd `` is the "standard" platform, and assumed in much of our documentation.
7777
78- Apache is bundled with many platforms, but can also be downloaded in a bundle
79- with a database engine and PHP from [ Bitnami]( https://bitnami.com/stacks/infrastructure) .
78+ Apache is bundled with many platforms, but can also be downloaded in a bundle
79+ with a database engine and PHP from ` Bitnami < https://bitnami.com/stacks/infrastructure >`_ .
8080
8181.htaccess
8282-------------------------------------------------------
8383
84- The “mod_rewrite” module enables URLs without “index.php” in them, and is assumed
84+ The “mod_rewrite” module enables URLs without “index.php” in them, and is assumed
8585in our user guide.
8686
87- Make sure that the rewrite module is enabled (uncommented) in the main
87+ Make sure that the rewrite module is enabled (uncommented) in the main
8888configuration file, eg. ``apache2/conf/httpd.conf ``::
8989
9090 LoadModule rewrite_module modules/mod_rewrite.so
9191
92- Also make sure that the default document root's <Directory> element enables this too,
92+ Also make sure that the default document root's <Directory> element enables this too,
9393in the "AllowOverride" setting::
9494
9595 <Directory "/opt/lamp7.2/apache2/htdocs">
@@ -101,21 +101,21 @@ in the "AllowOverride" setting::
101101Virtual Hosting
102102-------------------------------------------------------
103103
104- We recommend using “virtual hosting” to run your apps.
104+ We recommend using “virtual hosting” to run your apps.
105105You can set up different aliases for each of the apps you work on,
106106
107- Make sure that the virtual hosting module is enabled (uncommented) in the main
107+ Make sure that the virtual hosting module is enabled (uncommented) in the main
108108configuration file, eg. ``apache2/conf/httpd.conf ``::
109109
110110 LoadModule vhost_alias_module modules/mod_vhost_alias.so
111111
112- Add a host alias in your “hosts” file, typically ``/etc/hosts `` on unix-type platforms,
113- or ``c:/Windows/System32/drivers/etc/hosts `` on Windows.
112+ Add a host alias in your “hosts” file, typically ``/etc/hosts `` on unix-type platforms,
113+ or ``c:/Windows/System32/drivers/etc/hosts `` on Windows.
114114Add a line to the file. This could be "myproject.local" or "myproject.test", for instance::
115115
116116 127.0.0.1 myproject.local
117117
118- Add a <VirtualHost> element for your webapp inside the virtual hosting configuration,
118+ Add a <VirtualHost> element for your webapp inside the virtual hosting configuration,
119119eg. ``apache2/conf/extra/httpd-vhost.conf ``::
120120
121121 <VirtualHost *:80>
@@ -125,7 +125,7 @@ eg. ``apache2/conf/extra/httpd-vhost.conf``::
125125 CustomLog "logs/myproject-access_log" common
126126 </VirtualHost>
127127
128- If your project folder is not a subfolder of the Apache document root, then your
128+ If your project folder is not a subfolder of the Apache document root, then your
129129<VirtualHost> element may need a nested <Directory> element to grant the web s
130130erver access to the files.
131131
@@ -136,12 +136,51 @@ With the above configuration, your webapp would be accessed with the URL ``http:
136136
137137Apache needs to be restarted whenever you change its configuration.
138138
139+ Hosting with Nginx
140+ =================================================
141+ Nginx is the second most widely used HTTP server for web hosting.
142+ Here you can find an example configuration using PHP 7.3 FPM (unix sockets) under Ubuntu Server.
143+
144+ This configuration enables URLs without “index.php” in them and using CodeIgniter's “404 - File Not Found” for URLs ending with “.php”.
145+
146+ .. code-block :: nginx
147+
148+ server {
149+ listen 80;
150+ listen [::]:80;
151+
152+ server_name example.com;
153+
154+ root /var/www/example.com/public;
155+ index index.php index.html index.htm;
156+
157+ location / {
158+ try_files $uri $uri/ /index.php$is_args$args;
159+ }
160+
161+ location ~ \.php$ {
162+ include snippets/fastcgi-php.conf;
163+
164+ # With php-fpm:
165+ fastcgi_pass unix:/run/php/php7.3-fpm.sock;
166+ # With php-cgi:
167+ # fastcgi_pass 127.0.0.1:9000;
168+ }
169+
170+ error_page 404 /index.php;
171+
172+ # deny access to hidden files such as .htaccess
173+ location ~ /\. {
174+ deny all;
175+ }
176+ }
177+
139178 Hosting with Vagrant
140179=================================================
141180
142- Virtualization is an effective way to test your webapp in the environment you
143- plan to deploy on, even if you develop on a different one.
144- Even if you are using the same platform for both, virtualization provides an
181+ Virtualization is an effective way to test your webapp in the environment you
182+ plan to deploy on, even if you develop on a different one.
183+ Even if you are using the same platform for both, virtualization provides an
145184isolated environment for testing.
146185
147186The codebase comes with a ``VagrantFile.dist ``, that can be copied to ``VagrantFile ``
@@ -150,11 +189,11 @@ and tailored for your system, for instance enabling access to specific database
150189Setting Up
151190-------------------------------------------------------
152191
153- It assumes that you have installed `VirtualBox <https://www.virtualbox.org/wiki/Downloads >`_ and
154- `Vagrant <https://www.vagrantup.com/downloads.html >`_
192+ It assumes that you have installed `VirtualBox <https://www.virtualbox.org/wiki/Downloads >`_ and
193+ `Vagrant <https://www.vagrantup.com/downloads.html >`_
155194for your platform.
156195
157- The Vagrant configuration file assumes you have set up a `ubuntu/bionic64 Vagrant box
196+ The Vagrant configuration file assumes you have set up a `ubuntu/bionic64 Vagrant box
158197<https://app.vagrantup.com/ubuntu/boxes/bionic64> `_ on your system::
159198
160199 vagrant box add ubuntu/bionic64
@@ -166,6 +205,6 @@ Once set up, you can then launch your webapp inside a VM, with the command::
166205
167206 vagrant up
168207
169- Your webapp will be accessible at ``http://localhost:8080 ``, with the code coverage
170- report for your build at ``http://localhost:8081 `` and the user guide for
208+ Your webapp will be accessible at ``http://localhost:8080 ``, with the code coverage
209+ report for your build at ``http://localhost:8081 `` and the user guide for
171210it at ``http://localhost:8082 ``.
0 commit comments