为了节省字数达到突出,标题有点抽象。
原标题:我在 Win11 上用 Nginx Server 尝试部署了一个 MediaWiki,打开 index.php 时默认下载,而非打开主页,希望可以给出一些 nginx.conf 的修改建议。
事情大概就是像原标题一样的。具体的,我现在已经下载了 Nginx Server, PHP, MySQL 和 OpenSSH Server。
我的 nginx.exe 在文件夹 nginx-1.24.0 内,index.php 在 nginx-1.24.0/html/w 内。
我使用了命令 php-cgi.exe -b 127.0.0.1:9000 启动 PHP 的 CGI 模式并监听,并且确保使用 nginx -s reload 刷新了一下。
这是我现在的 nginx.conf 文件:
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 1206;
server_name localhost;
root /html/w;
index index.php;
location / {
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?title=$1&$args;
}
location /rest.php {
try_files $uri $uri/ /rest.php?$args;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000; # PHP-FPM 的地址和端口
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
希望可以指出哪里出了问题,若能提供修改的或者已经有的更好方案,本人实在感激不尽。