production HTTP server such as nginx or Apache. The built-in server is only designed to be used for development
and testing purposes. It can be started by using the -S flag:
Code: Select all
php -S <host/ip>:<port>
Example usage
1. Create an index.php file containing:
Code: Select all
<?php
echo "Hello World from built-in PHP server";
http://
. This will start a web server listening on port 8080 using the current directory that you are in as the
document root.
3. Open the browser and navigate to http://localhost:8080. You should see your "Hello World" page.
Configuration
To override the default document root (i.e. the current directory), use the -t flag:
Code: Select all
php -S <host/ip>:<port> -t <directory>
localhost:8080 -t public/.
Logs
Every time a request is made from the development server, a log entry like the one below is written to the
command line.
[Mon Aug 18 18:20:19 2019] ::1:52455 [200]: /