IT練習ノート

IT関連で調べたこと(実際は嵌ったこと)を書いています。

PHPでサーバ

MacにはPHPが入っているので、ちょっとしたWebサーバを動かすことができる。

(root)MacBook-Air:php foo$ php -v
PHP 5.5.29 (cli) (built: Sep  6 2015 20:20:34) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies

(root)MacBook-Air:php foo$ ls -la
total 8
drwxr-xr-x   3 foo  staff   102 11  3 18:15 .
drwxr-xr-x+ 85 foo  staff  2890 11  3 18:15 ..
-rw-r--r--   1 foo  staff    75 11  3 18:15 index.html

^C(root)MacBook-Air:php foo$ cat index.html 
<!DOCTYPE html>
<html>
<body>
<h1>My First PHP Server</h1>
</body>
</html>

(root)MacBook-Air:php foo$ php -S localhost:8000 
PHP 5.5.29 Development Server started at Thu Oct  30 18:16:05 2016
Listening on http://localhost:8000
Document root is /Users/foo/php
Press Ctrl-C to quit.
[Thu Oct  30 18:16:21 2016] ::1:51627 [200]: /