Skip to content

Instantly share code, notes, and snippets.

@zhEdward
Last active May 24, 2021 10:54
Show Gist options
  • Save zhEdward/d5423daa0a1e538d4b1cfa797476e430 to your computer and use it in GitHub Desktop.
Save zhEdward/d5423daa0a1e538d4b1cfa797476e430 to your computer and use it in GitHub Desktop.
运行PHP项目
% php -v
PHP 7.3.11 (cli) (built: Jun 5 2020 23:50:40) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies
% apachectl -v
Server version: Apache/2.4.41 (Unix)
Server built: Jun 5 2020 23:42:06
# macOS自带运行环境,直接运行即可,使用 ctrl+c 结束
sudo php -S localhost:80 -t /you/php/project/folder

安装Apache ,注意必须下载对应操作系统和 VC版本

安装php 注意选择 thread safe 和机器环境

配置环境变量(e.g.)

D:\software\Apache24\bin
D:\software\php-7.3.x
D:\software\php-7.3.x\ext

修改/config/httpd.conf文件中 ServerRoot "c:/Apache24" 为实际存放路劲,注:路径最后没有“\”

首次,Apache装入windows后台服务,通过cmd中 services.msc把Apache24改为自启动(省去每次开机都要 start一遍) httpd.exe -k install

启动Apache,使用start,后续修改过php文件,用restart即可 httpd.exe -k [restart|start]

通过浏览器 localhost:80 判断是否运行成功 备注:若80端口被占用,使用netstat -aon|findstr "80"查看占用情况,关闭相关软件,或者打开Apache目录下 /config/httpd.conf找到 Listen 80 一行,修改监听端口在restart

移除Apache服务

httpd.exe -k stop
httpd.exe -k uninstall
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment