Yii2的安裝

Composer安裝

https://getcomposer.org/download/php

建立Yii2項目 

第一次composer前應執行:
composer global require "fxp/composer-asset-plugin:~1.0.0":1.0.0"
建立過程當中,可能會要求輸入github的token,須要按提示的網址,登陸到github去生成一個token,粘貼回來
建立:
composer create-project --prefer-dist yiisoft/yii2-app-basic app1

   

Web服務器配置

Apache
<VirtualHost *:80>
    ServerAdmin admin@zcg.com
    DocumentRoot D:\svn\website
    ServerName test.com
    ErrorLog logs/test-error_log
    CustomLog logs/test-access.log combined
</VirtualHost>
<Directory "D:\svn\website\basic\web">
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php
</Directory>

    訪問:http://test.com/basic/webgit

    說明:將DocumentRoot配置成公共的上級目錄的緣由,僅僅爲了測試多個不一樣的app方便(不一樣的app,只需配置Directory部分了)github

Nginx
server {
    charset utf-8;
    client_max_body_size 128M;

    listen 80;

    server_name localhost;
    root        /path/to/basic/web;
    index       index.php;

    access_log  /path/to/basic/log/access.log main;
    error_log   /path/to/basic/log/error.log;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include fastcgi.conf;
        fastcgi_pass   127.0.0.1:9000;
    }

    location ~ /\.(ht|svn|git) {
        deny all;
    }
}
相關文章
相關標籤/搜索