wxk:nginx:note
差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
| wxk:nginx:note [2021/02/02 18:41] – wxk | wxk:nginx:note [2024/11/22 08:46] (当前版本) – 外部编辑 127.0.0.1 | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| ======nginx使用笔记====== | ======nginx使用笔记====== | ||
| + | |||
| + | * 上传大小限制: | ||
| + | |||
| + | < | ||
| + | http{ | ||
| + | client_max_body_size 1024m; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | 若上传文件的大小超过这个值,会报错:client intended to send too large body | ||
| + | --- // | ||
| + | |||
| + | * 虚拟目录PHP配置 | ||
| + | <code nginx example.conf> | ||
| + | server { | ||
| + | listen 80; | ||
| + | |||
| + | root / | ||
| + | index index.php index.html index.htm; | ||
| + | server_name www.example.com; | ||
| + | |||
| + | location / { | ||
| + | try_files $uri $uri/ =404; | ||
| + | } | ||
| + | # 定义虚拟目录,最下层路径名不相同的话只能用alias,不能用root。 实际路径为alias指定路径。用root时,实际路径 | ||
| + | # 为root | ||
| + | location / | ||
| + | alias / | ||
| + | index index.html index.php; | ||
| + | } | ||
| + | |||
| + | # | ||
| + | location ~^/ | ||
| + | if ($fastcgi_script_name ~ / | ||
| + | set $valid_fastcgi_script_name $1; | ||
| + | } | ||
| + | fastcgi_param | ||
| + | | ||
| + | # 若用默认的fastcgi.conf | ||
| + | # 会去/ | ||
| + | # 虚拟目录配PHP支持,关键就是这个变量。 | ||
| + | | ||
| + | fastcgi_split_path_info ^(.+? | ||
| + | try_files $fastcgi_script_name =404; | ||
| + | set $path_info $fastcgi_path_info; | ||
| + | fastcgi_param PATH_INFO $path_info; | ||
| + | fastcgi_index index.php; | ||
| + | include fastcgi_params; | ||
| + | fastcgi_pass unix:/ | ||
| + | } | ||
| + | |||
| + | # pass PHP scripts to FastCGI server | ||
| + | # | ||
| + | location ~ \.php$ { | ||
| + | include snippets/ | ||
| + | |||
| + | # With php-fpm (or other unix sockets): | ||
| + | fastcgi_pass unix:/ | ||
| + | # With php-cgi (or other tcp sockets): | ||
| + | # | ||
| + | } | ||
| + | # pass PHP scripts to FastCGI server | ||
| + | # | ||
| + | location ~ \.php$ { | ||
| + | include fastcgi-php.conf; | ||
| + | fastcgi_pass unix:/ | ||
| + | } | ||
| + | |||
| + | access_log | ||
| + | error_log | ||
| + | } | ||
| + | </ | ||
wxk/nginx/note.1612320085.txt.gz · 最后更改: 2024/11/22 08:46 (外部编辑)
