安裝PHP yii2框架(PHP7.0+mysql+nginx+Ubuntu16.04)
阿新 • • 發佈:2019-02-07
步驟一:安裝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