Windwos上PHP+MySQL+Nginx+GO快速组合例子
at 2022-12-04 15:44:42, by 鹏城奋青
一、基本需求
1、GO-1.18.2
2、PHP-8.1.12
3、Nginx-1.21.4
4、MySQL-8.0.27
二、应用组成
1、GO编写常驻内存的web服务处理性能关键业务,监听内部端口 127.0.0.1:8000。
2、PHP编写网站程序,PHP CGI程序监听127.0.0.1:9000。
3、MySQL做数据存储。
4、Nginx作为前端,反向代理到GO服务和PHP。
三、Nginx配置
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
error_page 500 502 503 504 /50x.html;
server {
listen 80;
server_name localhost;
root D:/workspace/tracer/server/web;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
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;
}
location /api {
proxy_pass http://127.0.0.1:8000/api;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-Port $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Cookie $http_cookie;
proxy_cookie_path /api /api;
client_max_body_size 200m;
}
}
}