Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start server in current directory (php/apache)

Apparently, you can start a temporary server with Python, by using:

python -m SimpleHTTPServer

Is there a way to do this for PHP and Apache? e.g. one command which will serve the current folder as the localhost? On Mac.

like image 922
cannyboy Avatar asked May 11 '13 14:05

cannyboy


2 Answers

You can start PHP development server in versions 5.4 and above with:

php -S localhost:8008

I don't think Apache supports anything similar (being itself a web server), but PHP dev server is enough for testing scripts, including serving static contents.

like image 58
Stefano Sanfilippo Avatar answered Sep 22 '22 07:09

Stefano Sanfilippo


PHP 5.4 added a simple web server to the PHP cli. You can start it with php -S <addr>:<port> it will serve the current directory on address <addr> over port <port>

like image 43
Colin Avatar answered Sep 24 '22 07:09

Colin