bat 脚本
@echo off
set conf=D:\Developer\laradock\nginx\sites\%1.conf 设置变量,%1 为参数1
if exist %conf% (
echo exist!
exit
)
echo server { >> %conf%
echo= >> %conf%
echo listen 80; >> %conf%
echo listen [::]:80; >> %conf%
echo= >> %conf%
echo # For https >> %conf%
echo # listen 443 ssl; >> %conf%
echo # listen [::]:443 ssl ipv6only=on; >> %conf%
echo # ssl_certificate /etc/nginx/ssl/default.crt; >> %conf%
echo # ssl_certificate_key /etc/nginx/ssl/default.key; >> %conf%
echo= >> %conf%
echo server_name %1.test; >> %conf%
echo root /var/www/%1/public; >> %conf%
echo index index.php index.html index.htm; >> %conf%
echo= >> %conf%
echo location / { >> %conf%
echo try_files $uri $uri/ /index.php$is_args$args; >> %conf%
echo } >> %conf%
echo= >> %conf%
echo location ~ \.php$ { >> %conf%
echo try_files $uri /index.php =404; >> %conf%
echo fastcgi_pass php-upstream; >> %conf%
echo fastcgi_index index.php; >> %conf%
echo fastcgi_buffers 16 16k; >> %conf%
echo fastcgi_buffer_size 32k; >> %conf%
echo fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; >> %conf%
echo #fixes timeouts >> %conf%
echo fastcgi_read_timeout 600; >> %conf%
echo include fastcgi_params; >> %conf%
echo } >> %conf%
echo= >> %conf%
echo location ~ /\.ht { >> %conf%
echo deny all; >> %conf%
echo } >> %conf%
echo= >> %conf%
echo location /.well-known/acme-challenge/ { >> %conf%
echo root /var/www/letsencrypt/; >> %conf%
echo log_not_found off; >> %conf%
echo } >> %conf%
echo= >> %conf%
echo error_log /var/log/nginx/%1_error.log; >> %conf%
echo access_log /var/log/nginx/%1_access.log; >> %conf%
echo } >> %conf%
exit
设置环境变量
可以在任意位置使用 cmd
> add-laradock-nginx xxx 生成 xxx.conf 配置文件