Ubuntu nginx部署yii2

1.安装composer

 

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

2.把代码上传到git上

 

3. 安装php,mysql-server,nginx, phpmyadmin

还要修改nginx的配置sudo nano /etc/nginx/sites-available/default

 location ~* \.(jpg|jpeg|png|gif|ico|js|woff|woff2|ttf)$ {
            root /var/www/yii_trade/backend/web;
            access_log off;
            expires max;
        }

        location ~* \.(js|css)$ {
            root /var/www/yii_trade/backend/web;
            expires 1y;
            log_not_found off;
        }


location ~ \.php$ {
        #       include snippets/fastcgi-php.conf;
        #
        #       # With php7.0-cgi alone:
                #fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                # With php7.0-fpm:
                fastcgi_pass unix:/run/php/php7.0-fpm.sock;
                fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_na$
                include        fastcgi_params;
        }
location /phpmyadmin {
    alias /usr/share/phpmyadmin;
    index index.php;


}
location /yiiblog {
index index.php;
}

4. 在yii项目根目录下执行composer install

 

5. 还要初始化下 ./init –env=Production –overwrite=y

http://www.waitingfy.com/archives/3585

3585

Leave a Reply

Name and Email Address are required fields.
Your email will not be published or shared with third parties.