2.8.4.4.2. Transfer Yii 2 to hosting

Attention!

The information provided in this article is for informational purposes only. Transferring a project built on Yii 2 to a hosting environment is quite complex and involves certain nuances that only the project’s developer can anticipate.

To transfer a project on Yii 2, you first need to upload the files to the server. There are several ways to do this:

  • If you're using Git, you can clone the project by connecting to the hosting via SSH and running the following command:
    git clone http://github.com/example/example_site/
  • Upload project files to the server.

After uploading the files to the server connect via SSH and perform the following steps:

  1. Configure the database connection.
  2. Go to the directory containing the downloaded project by running the following command:
    cd ~/example.com/www/
  3. Update dependencies and all packages by running the following command:
    PATH=/usr/local/php70/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin
    composer update
  4. Run the following command:
    /usr/local/php70/bin/php yii migrate
  5. To set the project to production mode, you may need to replace the following lines in the index.php file:
    defined('YII_DEBUG') or define('YII_DEBUG', true);
    defined('YII_ENV') or define('YII_ENV', 'dev');

    To this:

    defined('YII_DEBUG') or define('YII_DEBUG', false);
    defined('YII_ENV') or define('YII_ENV', 'prod');
  6. Check the site operation.

After completing the steps described above, additional steps may be required to configure the project. In this case, please contact the project developer for further details.

Content