步骤一:安装PHP7.0
sudo apt-get install php
sudo apt-get install php7.0-mbstring
步骤二:安装composer
curl -sS http://packagist.cn/composer/installer | php
切换到全局安装文件夹
sudo mv composer.phar /usr/local/bin/composer
步骤三:安装nginx
sudo apt-get nginx
步骤四:修改php.ini
修改:cgi.fix_pathinfo=0
步骤五:修改nginx配置文件
server{
listen 80;
server_name cxj.test.com;
root /data/wwwroot;
index index.html index.php;
location ~ \.php$
{
try_files $uri =404;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param HTTPS on;
include fastcgi.conf;
}
location ~ .*\.(ico|gif|jpg|jpeg|png|bmp|swf|js|css)$
{
expires 30d;
}
location ^~ /src {
deny all;
}
location ~ .*\.(log|sh)$
{
root /data/wwwroot/log;
deny all;
}
}
步骤六:安装yii2
1、安装Composer Asset插件:
php composer.phar global require "fxp/composer-asset-plugin:^1.2.0"
2、安装基本的应用程序模板,运行下面的命令:
composer create-project yiisoft/yii2-app-basic basic 2.0.9
安装高级的应用程序模板,运行下面的命令:
composer create-project yiisoft/yii2-app-advanced advanced 2.0.9