1.安装 Composer
通过 Composer 安装curl -sS https://getcomposer.org/installer | php mv composer.phar /usr/local/bin/composer
sudo vim /etc/php/7.2/cli/php.ini zlib.output_compression = ON
![](https://www.kancloud.cn/book/jayh/jayh/preview/images/screenshot_1536668389407.png)
2.安装yii2 高级版
安装yii2
composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application
报错:
![](https://www.kancloud.cn/book/jayh/jayh/preview/images/screenshot_1536669098587.png)
composer config repo.packagist composer https://packagist.phpcomposer.com
报错:
![](https://www.kancloud.cn/book/jayh/jayh/preview/images/screenshot_1536669243834.png)
composer config -g repo.packagist composer https://packagist.phpcomposer.com
再次安装yii2
composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application
更改网络连接方式,桥接方式
![](https://www.kancloud.cn/book/jayh/jayh/preview/images/screenshot_1536674034226.png)
安装php-mbstring
sudo apt-get install php-mbstring
报网络连接超时
![](https://www.kancloud.cn/book/jayh/jayh/preview/images/screenshot_1536712306105.png)
在浏览器打开安装包地址
不能访问,发现另外一个复制的虚拟机也打开了,怀疑是IP地址冲突,关掉另外一台虚拟机后,可以打开这个地址再次安装,报错:
composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application
执行:sudo apt-get install phpunitsudo apt-get install php7.2-xml
再次安装,安装成功
composer create-project --prefer-dist yiisoft/yii2-app-advanced yii-application
![](https://www.kancloud.cn/book/jayh/jayh/preview/images/screenshot_1536714478325.png)
![](https://www.kancloud.cn/book/jayh/jayh/preview/images/screenshot_1536714498593.png)
3.配置nginx
sudo vim /etc/nginx/sites-available/default
server { charset utf-8; client_max_body_size 128M; listen 80; ## listen for ipv4 #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 server_name frontend.test; root /home/jay/yii-application/frontend/web/; index index.php; access_log /home/jay/yii-application/log/frontend-access.log; error_log /home/jay/yii-application/log/frontend-error.log; 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/php5-fpm.sock; try_files $uri =404; } location ~* /\. { deny all; } } server { charset utf-8; client_max_body_size 128M; listen 80; ## listen for ipv4 #listen [::]:80 default_server ipv6only=on; ## listen for ipv6 server_name backend.test; root /home/jay/yii-application/backend/web/; index index.php; access_log /home/jay/yii-application/log/backend-access.log; error_log /home/jay/yii-application/log/backend-error.log; 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/php5-fpm.sock; try_files $uri =404; } location ~* /\. { deny all;