安装php和composer
参考安装php和composer
安装nginx
修改php配置
# 解开下面的注释
;cgi.fix_pathinfo=1
配置nginx
修改nginx.conf
#user nobody;
worker_processes 1;
# 打开log
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
# 打开log
access_log logs/access.log;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
# 打开log
access_log logs/host.access.log;
location / {
# 设置网站的根目录(类似Apache的www目录)
# 这个路径自己定义就行,下面的是我自己的路径
root D:/work/www;
# 把index.php添加到默认首页,就是输入/时自动打开/index.php
index index.html index.htm index.php;
}
# 打开404页面(可以不动)
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
# 配置FastCGI,PHP 脚本请求全部转发到 FastCGI处理
location ~ \.php$ {
#
root D:/work/www;
# 设置监听端口
fastcgi_pass 127.0.0.1:9000;
# 设置nginx的默认首页文件(上面已经设置过了,可以删除)
fastcgi_index index.php;
# 设置脚本文件请求的路径
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 引入fastcgi的配置文件
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
}
先双击nginx.exe启动Nginx
然后打开cmd输入如下,启动php-cgi
.\php-cgi.exe -b 127.0.0.1:9000 -c .\php.ini
work下wwwroot下新建index.php
<?php
phpinfo();
然后访问localhost