nginx > (Windows) 配置nginx的PHP

在Windows上使用PHP-FastCGI | NGINX

开始-php-fcgi.bat

@ECHO OFF
ECHO Starting PHP FastCGI...
set PATH=C:\PHP;%PATH%
c:\bin\RunHiddenConsole.exe C:\PHP\php-cgi.exe -b 127.0.0.1:9123

根目录设为:c:/nginx/www。

location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9123;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}

服务化

我们将使用winsw来将其服务化,类似于nginx。

请从以下位置下载最新版本,并将其放置在C:\nginx的根目录下
版本列表 releases/com/sun/winsw/winsw

更改名称。名称可以是任何东西,但为了区分winsw的版本,已更名为winsw-2.1.2-php-fcgi。

请创建一个名为 winsw-2.1.2-php-fcgi.xml 的文件并按照以下方式进行配置。

<service>
  <id>php-fcgi</id>
  <name>php-fcgi</name>
  <description>php-fcgi</description>
  <logpath>c:\nginx\php-7.2.1-nts-log</logpath>
  <logmode>roll</logmode>
  <depend></depend>
  <executable>c:\nginx\start-php-fcgi.bat</executable>
  <startargument></startargument>
  <stopexecutable>c:\nginx\nginx.exe</stopexecutable>
  <stopargument>-s</stopargument>
  <stopargument>stop</stopargument>
</service>

以管理员权限打开命令提示符,输入以下命令。

C:\nginx\winsw-2.1.2-php-fcgi.exe install

如果能按照以下方式,那就可以。

C:\nginx\winsw-2.1.2-php-fcgi.exe install
2018-01-25 11:06:46,673 INFO  - Installing the service with id 'php-fcgi'

如果要删除服务请参考以下步骤。

C:\nginx\winsw-2.1.2-php-fcgi.exe uninstall

确认PHP。

创建c:/nginx/www/phpinfo.php文件,内容如下:

<?PHP
phpinfo();

只需一种选择,将以下内容用中文进行本地化翻译:
访问以下链接,若能够得到有关PHP的信息,则表示成功。