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;
    }
}
相关文章
相关标签/搜索