How to Run Yii2 Application on Hosting

How to deploy Yii2 Advanced application on a shared Hosting

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://username@gitlab.com/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.

How to install Yii2 framework - advanced template on shared hosting?

You can install it locally and run init to generate the missing files, like described here. After that just upload the application to the shared host through FTP.

Also, Yii2 Practical-A App might be useful to you.

I want to host yii application

Yii applications runs on any servers/hosts that support php.

In this case you need a server or host that support mysql too.

Its related to your website traffic that choice sharing hosting or VPS.

In your application have to exists a file named requirement.php that shows Yii requirements, of course in Yii2. For Yii1:

  1. Requirements ¶ After installing Yii, you may want to verify that your server satisfies Yii's requirements. You can do so by accessing
    the requirement checker script via the following URL in a Web browser:


http://hostname/path/to/yii/requirements/index.php Yii requires PHP
5.1, so the server must have PHP 5.1 or above installed and available to the web server. Yii has been tested with Apache HTTP server on
Windows and Linux. It may also run on other Web servers and platforms,
provided PHP 5.1 is supported.

However is better your host be on LAMP platform.



Related Topics



Leave a reply



Submit