How to deploy Yii2 Advanced application on a shared Hosting

Yii2 advanced application with vendor folder its more than ~100 MB, so its very difficult to upload using FTP software.

  1. I need to update composer after uploading my application in a shared server.
  2. Unable to clone from git

Upvotes: 0

Views: 3225

Answers (2)

topher
topher

Reputation: 14860

I recently had a similar problem and was without ssh access. I however noticed that the bulk of the size and files was caused by the .git folders of my project and the vendors. My solution was to set my FTP client to ignore all files and folders starting with .git.

On Filezilla, for example, this can be done by going to View->Filename Filters and editing the CVS and SVN filter to ignore '.git*'.

Upvotes: 0

Steps for deploying yii2 advanced app on a shared hosting (note : You need to have ssh access to the server, if not: contact your hosting provider)

  1. Generating a SSH Key Pair : open terminal and type the following

    ssh-keygen -t dsa

    OR

    ssh-keygen -t rsa

  2. The out put will be similar to

Generating public/private dsa key pair. Enter file in which to save the key (~/.ssh/id_dsa): Press [Enter] key Enter passphrase (empty for no passphrase): Press [Enter] key Enter same passphrase again: Press [Enter] key Your identification has been saved in ~/.ssh/id_dsa Your public key has been saved in ~/.ssh/id_dsa.pub The key fingerprint is:

OR

Generating public/private dsa key pair. Enter file in which to save the key (~/.ssh/id_dsa): Press [Enter] key Enter passphrase (empty for no passphrase): Press [Enter] key Enter same passphrase again: Press [Enter] key Your identification has been saved in ~/.ssh/id_dsa Your public key has been saved in ~/.ssh/id_dsa.pub The key fingerprint is:

  1. Create a directory as .ssh (note the preceding dot) under /home// for your hosting package on the remote host. You will then have to create a file named authorized_keys inside this .ssh directory
  2. Copy the content of the local ~/.ssh/id_dsa.pub or ~/.ssh/id_rsa.pub file into the authorized_keys file
  3. For connecting your server, open terminal and enter following

    ssh -l user remote-server

Replace user with your cpanel username and remote-server with your remote server host name. Enter your cpanel password, terminal will login your remote server using ssh.

  1. Clone your application from git repository

    git clone https://[email protected]/username/repository.git public_html

  2. Go to public_html do the following

    curl -sS https://getcomposer.org/installer | php

    php composer.phar global require "fxp/composer-asset-plugin:1.0.0"

    php init

  3. Set environment as Production (recommended)

    php composer.phar update

This will download all dependencies and setup your app, don't forget to configure database in main configuration file.

Upvotes: 3

Related Questions