使用PHP內建web伺服器的教程

來源:互聯網
上載者:User

PHP 5.4起就在CLI SAPI中內建了web伺服器,這給開發人員帶來了方便。
只需在項目目錄下執行

php -S localhost:8001

訪問連結,終端就會產生access log

E:\php\test\web_server>php -S localhost:8001
PHP 5.4.33 Development Server started at Sat Sep 26 12:10:01 2015
Listening on http://localhost:8001
Document root is E:\php\test\web_server
Press Ctrl-C to quit.
[Sat Sep 26 12:10:07 2015] 127.0.0.1:65349 [200]: /phpinfo.php
[Sat Sep 26 12:10:07 2015] 127.0.0.1:65350 [200]: /phpinfo.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42
[Sat Sep 26 12:10:07 2015] 127.0.0.1:65351 [200]: /phpinfo.php?=PHPE9568F35-D428-11d2-A769-00AA001ACF42
[Sat Sep 26 12:10:07 2015] 127.0.0.1:65352 [404]: /favicon.ico - No such file or directory

可指定目錄和不同的php.ini配置

php -S localhost:8001 -t E:\php\test\web_server\ -c D:\software\amp\php-5.6.5-Win32-VC11-x64\php.ini

原來PHP 5.4起就在CLI SAPI內建了伺服器哦,小編使用的最高版本也是php5.3哦。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.