在搭建 web 服务器时,Nginx 是一款高性能的 web 服务器,而 PHP 是一种常用的 web 开发语言,当我们想把 Nginx 将 PHP 集成在一起使用时,就需要对它们进行安装和配置。本文将介绍在 Windows 环境下安装和配置 Nginx 和 PHP 的详细过程。

安装 Nginx

  1. 下载 Nginx

首先,我们需要在 Nginx 的官网(https://nginx.org/en/download.html)上下载最新的 Windows 版本,选择 32 位或 64 位的版本,再将其解压到一个自定义的目录。例如,可以将 Nginx 解压到 C:
ginx。

  1. 配置 Nginx

接着,我们需要在 Nginx 目录下创建一个 conf 目录,然后在 conf 目录下创建一个 nginx.conf 文件。在 nginx.conf 文件中,输入以下内容:

worker_processes  1;

error_log  logs/error.log;
pid        logs/nginx.pid;

events {
 worker_connections  1024;
}

http {
 include       mime.types;
 default_type  application/octet-stream;

 sendfile        on;
 keepalive_timeout  65;

 server {
   listen       80;
   server_name  localhost;
   root         html;
   index        index.php index.html index.htm;

   location / {
     try_files $uri $uri/ /index.php?$query_string;
   }

   error_page   500 502 503 504  /50x.html;
   location = /50x.html {
     root   html;
   }

   location ~ .php$ {
     fastcgi_pass   127.0.0.1:9000;
     fastcgi_index  index.php;
     fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
     include        fastcgi_params;
   }
 }
}
1、本站目前拥有近 1000+ 精品收费资源,现在加入VIP会员即可全部下载。
2、本资源部分来源其他付费资源平台或互联网收集,如有侵权请联系及时处理。
SEA模板网 » windows nginx安装 php

发表评论

加入本站VIP会员订阅计划,海量资源免费查看

目前为止共有 3654 位优秀的VIP会员加入! 立刻加入VIP会员