windows nginx安装 php
在搭建 web 服务器时,Nginx 是一款高性能的 web 服务器,而 PHP 是一种常用的 web 开发语言,当我们想把 Nginx 将 PHP 集成在一起使用时,就需要对它们进行安装和配置。本文将介绍在 Windows 环境下安装和配置 Nginx 和 PHP 的详细过程。
安装 Nginx
- 下载 Nginx
首先,我们需要在 Nginx 的官网(https://nginx.org/en/download.html)上下载最新的 Windows 版本,选择 32 位或 64 位的版本,再将其解压到一个自定义的目录。例如,可以将 Nginx 解压到 C:
ginx。
- 配置 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;
}
}
}
Php