Windows 系统配置nginx + php

 Windows  2018-12-21  admin  3051  4118

一、解压php安装包,配置php.ini文件

二、nginx的安装与配置

nginx.conf文件

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#    root           html;
#    fastcgi_pass   127.0.0.1:9000;
#    fastcgi_index  index.php;
#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
#    include        fastcgi_params;
#}

修改为

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           D:/phpStudy/nginx/html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            #fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

  root 网站的根目录,绝对地址,注意使用斜线/   不能使用反斜线

fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;

  

命令行输入

php-cgi.exe -b 127.0.0.1:9000

start nginx.exe


三、为了管理方便,编写启动 停止脚本

start.bat

@echo off
REM Windows 下无效
REM set PHP_FCGI_CHILDREN=5

REM 每个进程处理的最大请求数,或设置为 Windows 环境变量
set PHP_FCGI_MAX_REQUESTS=1000
 
echo Starting PHP FastCGI...
REM RunHiddenConsole D:/phpdev/php/php-cgi.exe -b 127.0.0.1:9000 -c D:/phpdev/php/php.ini
RunHiddenConsole php-cgi.exe -b 127.0.0.1:9000
 
echo Starting nginx...
REM RunHiddenConsole D:/phpdev/nginx/nginx.exe -p D:/phpdev/nginx
RunHiddenConsole nginx.exe

stop.bat

@echo off
echo Stopping nginx...  
taskkill /F /IM nginx.exe > nul
echo Stopping PHP FastCGI...
taskkill /F /IM php-cgi.exe > nul
exit

restart_nginx.bat

@echo off
REM 重启nginx
RunHiddenConsole nginx.exe -s reload


四、nginx 常用其它命令

start nginx

tasklist /fi "imagename eq nginx.exe"

nginx -s stop	fast shutdown
nginx -s quit	graceful shutdown
nginx -s reload	changing configuration, starting new worker processes with a new configuration, graceful shutdown of old worker processes
nginx -s reopen	re-opening log files



nginx.zip


如果文章对您有帮助,点击下方的广告,支持一下作者吧!

转载必须注明出处:

Windows 系统配置nginx + php —— code.cent123.com

相关推荐


Systemd Web 管理系统:简化服务管理

# Systemd Web Systemd Web 是一个 Systemd 的 Web UI 管理系统,通过直观的界面和易用的操作,让用户能够轻松地管理 Linux 系统和服务。该项目旨在简化 Systemd 的使用,使得无论是专业的系统管理员还是普通的用户,都能够方便地对系统进行操作。 ## [github地址] (https://github.com/topascend/systemd

linux 系统最简单的安装 go 开发环境步骤

1. 官网下载放在 /godev 目录https://golang.google.cn/dl/或wget https://dl.google.com/go/go1.22.2.linux-amd64.tar.gz或curl -O https://dl.google.com/go/go1.22.2.linux-386.tar.gz2. 解压tar -xvf go1.22.2.linux-amd64.t

laravel 自定义写入日志

laravel 自定义写入日志if(!function_exists('myLog')){ /** *生成自定义文件日志内容 *@param$data *@paramstring$title *@parambool$isClear *@returnvoid *@Author:cent123.com */ functionmyLog($data,string$tit

systemctl 使用

Systemd是Linux系统工具,用来启动守护进程,已成为大多数发行版的标准配置。而systemctl是Systemd的主命令,用于管理系统。其实我们大部分服务都有使用systemctl管理,比如MySQL、Nginx等等。常见配置如下:[Unit] #单元描述 Description=GFAPP #在什么服务启动之后再执行本程序 After=mysql.service [Serv