Windows | heredoc示例
Apr 16, 2025
以nginx
配置文件为例
$config = @'
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log;
sendfile on;
keepalive_timeout 65;
client_max_body_size 0;
server_tokens off;
gzip on;
server {
listen 80 reuseport;
location / {
root /www;
index index.html;
}
}
}
'@
$config | Set-Content -Path "C:\Users\root\Desktop\nginx\conf\nginx.conf" -Encoding ASCII