php自带的server,php自带的webserver

4037508

笔者不喜欢这样的学习方式:认识一个命令,然后把它的大部分用法学一下。理由很明确:其一枯燥,其二不知所为何用,其三笔者学习能力尤其记忆能力比较差。

笔者同时深知,学习方法只是因时因人因阶段而异,没有所谓的好与坏。上面的学习方式,在某个阶段,对于笔者而言还是有用的。只是,今天这篇文章思路不是这样,它以流程目的为主导。

插个题外话:大学有个同学,跟我讲过同样的学习方法。很荣幸认识这样的人,给我以启迪;很庆幸现在自己还记得。发现别人的优点,然后去学习。三人行,必有我师。

webserver

router.php用于php自带webserver支持,可用于快速测试

LAMP是php web开发的标配,但php自带的webserver在测试环境中可以取代Apache(不建议这样做,毕竟Apache安装配置很简单,而且好用)。

运行一条看似简单的命令即可:

➜ public pwd

/Applications/XAMPP/xamppfiles/htdocs/tp5/public

➜ public php -S localhost:8888 router.php

PHP 7.0.13 Development Server started at Thu Mar 22 00:47:46 2018 Listening on http://localhost:8888 Document root is /Applications/XAMPP/xamppfiles/htdocs/tp5/public Press Ctrl-C to quit.

1、端口号可以随意指定,一般情况下取大一点,不可以与本机已有的端口号重复。具体范围可以百度。但大于2000的四位数肯定可以。不建议8080,一般8080的端口号已被占用。

2、可以观察上面的提示,webserver 的根目录在 public 目录下面,而笔者Apache中配置的根目录只到htdocs下面。所以访问tp5时,利用Apache服务器时路径还要加上:/tp5/public,而在webserver直接输入localhost:8888 便可直接访问。

如何退出?

在讨论退出之前,我们先证明 8888 端口已启用。

两个方法:

1.浏览器直接访问:localhost:8888 , 可以进入系统,则表示已启用;

2.利用 ps 命令

下面问题来了,什么是 ps 命令?

Reports a snapshot of the status of currently running processes.

ps 命令能够给出当前系统中进程的快照。它能捕获系统在某一事件的进程状态。

➜ tp5 ps

PID TTY TIME CMD

18264 ttys000 0:00.98 /bin/zsh --login -i

22549 ttys000 0:00.10 php -S localhost:8888 router.php 19517 ttys001 0:00.79 /bin/zsh --login -i

PID: 进程号 process ID

TTY: 命令所运行的位置 teletypewriters(了解这个要稍微百度一下历史)

TIME: 运行这个命令 cpu 所占用的处理时间 time

CMD: 进程所运行的命令 command

利用ps命令看见 8888 端口已被启用。

退出进程,两个方法:

1、ctrt + c

2、kill PID (这里是kill 22549)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
YACS 是一个强大的 PHP 脚本,可以让你维护一个动态的 Web 服务器。特性:- Runs on your own server, or on a shared web site- Post articles with web forms, by e-mail, or remotely (w:bloggar)- Embed images and photos in articles --automatic resize- Each section can be a weblog, a discussion board, a book of cooking recipes,etc, or even a plain list of articles- Overlay interface for PHP developers, to add extra functionality to articles,such as polls or cooking recipes- Display the content tree in Freemind- Comments, with quoting- Archives per week and per month- The home page is updated automatically on article publishing- Categories, sub-categories, etc. --Build your own Yahoo! or DMOZ...- Real-time meetings with community members- Private discussions and messages- Search on any word --text of articles is fully indexed- Multiple authors --actually, a community of contributors- Articles are visible only on publication after review by editors- Articles and sections can have dead-line to limit visibility over time- A straightforward control panel, and a set of configuration panels- File upload to articles , sections or categories- Attach links to articles, sections or categories- A comprehensive set of UBB-like codes are available to beautify your posts- Integrated support of TinyMCE and of FCKEditor- Fully customizable skins- Easy integration of Google Maps- Add a comprehensive web interface to existing collections of files- Support audio-on demand and video-on demand- Automatic web slideshow for shared photos- RSS syndication- Easy installation- XML-RPC interface (implementing the Blogger API and metaWeblog API) 标签:YACS

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值