Skip to content

Commit 4464c87

Browse files
committed
description for running PHP's built-in web server in the background
1 parent 440e004 commit 4464c87

File tree

3 files changed

+88
-11
lines changed

3 files changed

+88
-11
lines changed

book/installation.rst

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,24 @@ If there are any issues, correct them now before moving on.
274274
Note that using the ACL is recommended when you have access to them
275275
on your server because changing the umask is not thread-safe.
276276

277-
**4. Use the same user for the CLI and the web server**
278-
279-
In development environments, it is a common practice to use the same unix
280-
user for the CLI and the web server because it avoids any of these permissions
281-
issues when setting up new projects. This can be done by editing your web server
282-
configuration (e.g. commonly httpd.conf or apache2.conf for Apache) and setting
283-
its user to be the same as your CLI user (e.g. for Apache, update the User
284-
and Group values).
277+
**4. Use the built-in web server in development environments**
278+
279+
In development environments, the easiest way to test your application,
280+
is to use PHP's built-in web server:
281+
282+
.. code-block:: bash
283+
284+
$ php app/console server:start
285+
286+
When you are finished, stop it using the ``server:stop`` command:
287+
288+
.. code-block:: bash
289+
290+
$ php app/console server:stop
291+
292+
.. seealso::
293+
294+
Read more about the internal server :doc:`in the cookbook </cookbook/web_server/built_in>`.
285295

286296
When everything is fine, click on "Go to the Welcome page" to request your
287297
first "real" Symfony webpage:

cookbook/web_server/built_in.rst

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ a full-featured web server such as
1515
The built-in web server is meant to be run in a controlled environment.
1616
It is not designed to be used on public networks.
1717

18+
Running the Server in the Foreground
19+
------------------------------------
20+
1821
Starting the Web Server
19-
-----------------------
22+
~~~~~~~~~~~~~~~~~~~~~~~
2023

2124
Running a Symfony application using PHP's built-in web server is as easy as
2225
executing the ``server:run`` command:
@@ -37,7 +40,7 @@ can change the socket passing an ip address and a port as a command-line argumen
3740
$ php app/console server:run 192.168.0.1:8080
3841
3942
Command Options
40-
---------------
43+
~~~~~~~~~~~~~~~
4144

4245
The built-in web server expects a "router" script (read about the "router"
4346
script on `php.net`_) as an argument. Symfony already passes such a router
@@ -58,3 +61,61 @@ you have to pass the correct location using the ``--docroot`` option:
5861
5962
.. _`built-in web server`: http://www.php.net/manual/en/features.commandline.webserver.php
6063
.. _`php.net`: http://php.net/manual/en/features.commandline.webserver.php#example-401
64+
65+
Moving the Process to the Background
66+
------------------------------------
67+
68+
.. versionadded:: 2.6
69+
The ability to run the server as a background process was introduced
70+
in Symfony 2.6.
71+
72+
The ``server:run`` command runs the web server in the foreground blocking
73+
the current terminal window. You can also run the server in a background process:
74+
75+
.. code-block:: bash
76+
77+
$ php app/console server:start
78+
79+
The ``server:start`` command accepts the same options and arguments as the
80+
``server:run`` command. For example, the following command will tell the server
81+
to listen on port 8080 on the network interface with the 192.168.0.1 ip address
82+
assigned to:
83+
84+
.. code-block:: bash
85+
86+
$ php app/console server:start 192.168.0.1:8080
87+
88+
This way, you can start several server processes listening on different sockets
89+
without bothering with a clutter of terminal windows.
90+
91+
Stopping the Server
92+
~~~~~~~~~~~~~~~~~~~
93+
94+
To stop a server running in the background, you simply call the ``server:stop``
95+
command passing it the socket the server is listening on.
96+
97+
.. code-block:: bash
98+
99+
$ php app/console server:stop 127.0.0.1:8080
100+
101+
Similar to the commands that are used to start the web server, omitting the
102+
socket argument for the ``server:stop`` command stops the server listening
103+
on port 8000 on the loopback device.
104+
105+
Monitoring the Server Status
106+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
107+
108+
You can check status of the web server for a particular socket using the ``server:status``
109+
command (127.0.0.1:8000 being the default socket again):
110+
111+
.. code-block:: bash
112+
113+
$ php app/console server:status 127.0.0.1:8080
114+
115+
.. caution::
116+
117+
The information shown by the ``server:status`` command would not be reliable
118+
if you didn't terminate the server using the ``server:stop`` command (by
119+
using the UNIX ``kill`` command or the Windows task manager, for example).
120+
121+
.. _`built-in web server`: http://www.php.net/manual/en/features.commandline.webserver.php

quick_tour/the_big_picture.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ to run Symfony:
7070

7171
.. code-block:: bash
7272
73-
$ php app/console server:run
73+
$ php app/console server:start
74+
75+
When you are finished, you can stop it with the ``server:stop`` command:
76+
77+
.. code-block:: bash
78+
79+
$ php app/console server:stop
7480
7581
.. seealso::
7682

0 commit comments

Comments
 (0)