Skip to content

Commit a03831b

Browse files
authored
Added docs about command line options (#56)
* Added docs about command line options This will fix #54 * Bugfix * fixed issues
1 parent 4d8c8df commit a03831b

File tree

1 file changed

+103
-29
lines changed

1 file changed

+103
-29
lines changed

README.md

Lines changed: 103 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Contributions and suggestions are welcome.
3333
Below is an example of a simple 'Hello, World!' FastCGI application in PHP.
3434

3535
```php
36-
<?php // command.php
36+
<?php // fastCGI_app.php
3737

3838
// Include the composer autoloader
3939
require_once dirname(__FILE__) . '/../vendor/autoload.php';
@@ -60,9 +60,14 @@ $application->run();
6060

6161
### NGINX
6262

63-
With NGINX, you need to use a process manager such as [supervisord](http://supervisord.org/) to manage instances of your application. Have a look at [AstroSplash](http://astrosplash.com/) for an [example supervisord configuration](https://github.com/AndrewCarterUK/AstroSplash/blob/master/supervisord.conf).
63+
With NGINX, you need to use a process manager such as [supervisord](http://supervisord.org/)
64+
to manage instances of your application. Have a look at [AstroSplash](http://astrosplash.com/)
65+
for an [example supervisord configuration](https://github.com/AndrewCarterUK/AstroSplash/blob/master/supervisord.conf).
6466

65-
Below is an example of the modification that you would make to the [Symfony NGINX configuration](https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/). The core principle is to replace the PHP-FPM reference with one to a cluster of workers.
67+
Below is an example of the modification that you would make to the
68+
[Symfony NGINX configuration](https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/).
69+
The core principle is to replace the PHP-FPM reference with one to a cluster of
70+
workers.
6671

6772
```nginx
6873
# This shows the modifications that you would make to the Symfony NGINX configuration
@@ -91,16 +96,8 @@ server {
9196

9297
If you are using Apache 2.4.10 or later you need to use [mod_proxy_fcgi](https://httpd.apache.org/docs/2.4/mod/mod_proxy_fcgi.html).
9398
You need to use a process manager such as [supervisord](http://supervisord.org/) to manage instances of your application.
94-
For development you only need to start you application with:
95-
96-
```sh
97-
php /path/to/application.php run --port=5000 --host=localhost
98-
99-
# Or with Symfony:
100-
php /path/to/bin/console speedfony:run --env=prod --port=5000 --host=localhost
101-
```
102-
103-
Then add the following to your VirtualHost config:
99+
For development you only need to start you application (see [Running the server](#running-the-server)) then add the
100+
following to your VirtualHost config:
104101

105102
```
106103
<FilesMatch ^index\.php$>
@@ -114,41 +111,118 @@ to exist but could be an empty file.
114111

115112
### Apache 2.0 - 2.2
116113

117-
If you wish to configure your FastCGI application to work with the apache web server, you can use the apache FastCGI module to process manage your application.
114+
If you wish to configure your FastCGI application to work with the apache web server,
115+
you can use the apache FastCGI module to process manage your application.
118116

119-
This can be done by creating a FCGI script that launches your application and inserting a FastCgiServer directive into your virtual host configuration.
117+
This can be done by creating a FCGI script that launches your application and inserting
118+
a FastCgiServer directive into your virtual host configuration.
120119

121120
Here is an example `script.fcgi`:
122121

123122
```sh
124123
#!/bin/bash
124+
125+
# Run the server
125126
php /path/to/application.php run
126127
```
127128

128-
Or with Symfony:
129+
See other commands to run the server [here](#running-the-server).
129130

130-
```sh
131-
#!/bin/bash
132-
php /path/to/bin/console speedfony:run --env=prod
133-
```
134131

135-
In your configuration, you can use the [FastCgiServer](https://web.archive.org/web/20150913190020/http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiServer) directive to inform Apache of your application.
132+
In your configuration, you can use the [FastCgiServer](https://web.archive.org/web/20150913190020/http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiServer)
133+
directive to inform Apache of your application.
136134

137135
```
138136
FastCgiServer /path/to/script.fcgi
139137
```
140138

141-
By default, the daemon will listen on FCGI_LISTENSOCK_FILENO, but it can also be configured to listen on a TCP address. For example:
139+
## Running the server
142140

141+
Depending on your setup, you will have different ways of running the server. In
142+
a normal PHP application where you have created your own `fastCGI_app.php` ([see how](#usage)),
143+
you may start the server simply by:
143144

144-
```sh
145-
#!/bin/bash
146-
php /path/to/application.php run --port=5000 --host=localhost
145+
```bash
146+
php /path/to/fastCGI_app.php run
147147
```
148148

149-
Or with Symfony:
149+
In a Symfony application where you have registered `DaemonRunCommand` as a service,
150+
you may just run:
150151

151-
```sh
152-
#!/bin/bash
153-
php /path/to/bin/console speedfony:run --env=prod --port=5000 --host=localhost
152+
```bash
153+
# If installed with Symfony Flex
154+
./bin/console fastcgi-daemon:run
155+
156+
# If you use https://github.com/PHPFastCGI/SpeedfonyBundle (deprecated)
157+
./bin/console speedfony:run
158+
```
159+
160+
### Command options
161+
162+
When you run the command you have a few option you could pass to it.
163+
164+
#### Auto shutdown
165+
166+
`--auto-shutdown`
167+
168+
Perform a graceful shutdown after receiving a 5XX HTTP status code.
169+
170+
#### Driver
171+
172+
`--driver userland`
173+
174+
The implementation of the FastCGI protocol to use.
175+
176+
#### File descriptor
177+
178+
`--fd 4711`
179+
180+
File descriptor to listen on - defaults to FCGI_LISTENSOCK_FILENO.
181+
182+
#### Host
183+
184+
`--host 127.0.0.1`
185+
186+
TCP host to listen on.
187+
188+
#### Memory Limit
189+
190+
`--memory-limit 256m`
191+
192+
The memory limit on the daemon instance before shutting down.
193+
194+
#### Port
195+
196+
`--port 5000`
197+
198+
TCP port to listen on (if not present, daemon will listen on FCGI_LISTENSOCK_FILENO).
199+
200+
#### Quiet
201+
202+
`--quiet`
203+
204+
Reduces the number of log output in the console.
205+
206+
#### Request limit
207+
208+
`--request-limit 56`
209+
210+
The maximum number of requests to handle before shutting down.
211+
212+
#### Time limit
213+
214+
`--time-limit 120`
215+
216+
The time limit on the daemon in seconds before shutting down.
217+
218+
#### Verbose
219+
220+
`--verbose` or `-v`
221+
222+
Increases the log output in the console.
223+
224+
### Example run
225+
226+
```bash
227+
./bin/console fastcgi-daemon:run --port=5000 --host=127.0.0.1 -v
154228
```

0 commit comments

Comments
 (0)