回首页

在Homestead/script 下新建里下面文件 server-yii.sh 内容为

#!/usr/bin/env bash
declare -A params=$5     # Create an associative array
paramsTXT=""
if [ -n "$5" ]; then
   for element in "${!params[@]}"
   do
      paramsTXT="${paramsTXT}
      fastcgi_param ${element} ${params[$element]};"
   done
fi
block="server {
    charset utf-8;
    client_max_body_size 128M;

    listen ${3:-80};
    listen ${4:-443} ssl http2;
    server_name $1;
    root \"$2\";

    index       index.php;

    access_log  /var/log/nginx/$1-access.log;
    error_log  /var/log/nginx/$1-error.log error;

    location / {
        # Redirect everything that isn't a real file to index.php
        try_files \$uri \$uri/ /index.php\$is_args\$args;
    }

    # uncomment to avoid processing of calls to non-existing static files by Yii
    #location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
    #    try_files $uri =404;
    #}
    #error_page 404 /404.html;

    # deny accessing php files for the /assets directory
    location ~ ^/assets/.*\.php$ {
        deny all;
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
        #fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass  unix:/var/run/php/php7.1-fpm.sock;
        try_files \$uri =404;
    }

    location ~* /\. {
        deny all;
    }
}
"
echo "$block" > "/etc/nginx/sites-available/$1"
ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"

然后 type 设为 yii,nginx就自动生成yii的配置文件咯

    - map: yii.work
      to: /home/vagrant/Code/basic/web
      type: yii

vagrant up --provision