Skip to content

Commit 33369f1

Browse files
Improved server configuration documentation
1 parent 4c8185a commit 33369f1

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

README.md

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,75 @@ $application = (new ApplicationFactory)->createApplication($kernel);
5656
$application->run();
5757
```
5858

59+
## Server Configuration
60+
61+
### NGINX
62+
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).
64+
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.
66+
67+
```nginx
68+
# This shows the modifications that you would make to the Symfony NGINX configuration
69+
# https://www.nginx.com/resources/wiki/start/topics/recipes/symfony/
70+
71+
upstream workers {
72+
server localhost:5000;
73+
server localhost:5001;
74+
server localhost:5002;
75+
server localhost:5003;
76+
}
77+
78+
server {
79+
# ...
80+
81+
location ~ ^/app\.php(/|$) {
82+
# ...
83+
fastcgi_pass workers;
84+
# ...
85+
}
86+
87+
# ...
88+
}
89+
```
90+
91+
### Apache
92+
5993
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.
6094

6195
This can be done by creating a FCGI script that launches your application and inserting a FastCgiServer directive into your virtual host configuration.
6296

97+
Here is an example `script.fcgi`:
98+
6399
```sh
64100
#!/bin/bash
65-
php /path/to/command.php run
101+
php /path/to/application.php run
66102
```
67103

104+
Or with Symfony:
105+
106+
```sh
107+
#!/bin/bash
108+
php /path/to/bin/console speedfony:run --env=prod
109+
```
110+
111+
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.
112+
68113
```
69-
FastCgiServer /path/to/web/root/script.fcgi
114+
FastCgiServer /path/to/script.fcgi
70115
```
71116

72117
By default, the daemon will listen on FCGI_LISTENSOCK_FILENO, but it can also be configured to listen on a TCP address. For example:
73118

119+
74120
```sh
75-
php /path/to/command.php run --port=5000 --host=localhost
121+
#!/bin/bash
122+
php /path/to/application.php run --port=5000 --host=localhost
76123
```
77124

78-
If you are using a web server such as NGINX, you will need to use a process manager to monitor and run your application.
125+
Or with Symfony:
126+
127+
```sh
128+
#!/bin/bash
129+
php /path/to/bin/console speedfony:run --env=prod --port=5000 --host=localhost
130+
```

0 commit comments

Comments
 (0)