How to deploy the application on production server developed on other computer

Hi,

I want to deploy the yii2 application on my server.

I developed the application on my system centos 6.5.

I searched the guide and google about this topic but had no luck on finding the reference how to do this.

Is just copying the whole directory of application and database to server is the right way to deploy the application on server or can composer be used.

Is there any standard, best practice exist which one should follow while deploying the application or copying from one system to another in development or production version.

Looking forward

Thanks

Generally: no best practice. It’s hard to get one as the environments and configurations might be extremely different to one another.

This said, what you normally want to do in order to get your application up and running on a different server (regardless whether it’s production or not) is the following:

  • copy the code on the server

  • update dsn for the database and any other variable (YII_ENV and YII_DEV)

  • run composer update (sic)

  • run migrations

that’s it.

Thanks for reply

So we just need to copy and past the directories and have same environmnet on both machine.

I thought may be composer can be used to create the same environment on other server.

I can’t speak to use of composer for this (wouldn’t you need to create your own composer package…?) but here is what I do.

I use version control for my local dev and deployments. I have some code in my entry script that detects the environment (there are extensions for this) and loads the correct config based on environment. For example, different DB connections, different logging / debugging, etc.

I keep the whole project source tree including framework and vendors in source control. So for me, deploying is a matter of creating a working tree on the server. I don’t mess with migrations, its on my list to look at.

I copied all the directories and database from one computer to other.

The application is working fine but the yii default debug bar that is located at bottom of application in dev mode is disappeared.

Can Anyone help how to get debugging tool back.

Where to configure the settings.

I am using yii2 advance template on centos 6.5, PHP 5.6.3-1+deb.sury.org~trusty+1 mysql database.

From http://www.yiiframework.com/doc-2.0/guide-tool-debugger.html

By default, the debug module only works when browsing the website from localhost. If you want to use it on a remote (staging) server, add the parameter allowedIPs to the configuration to whitelist your IP:

‘bootstrap’ => [‘debug’],

‘modules’ => [

'debug' => [


    'class' => 'yii\debug\Module',


    'allowedIPs' => ['1.2.3.4', '127.0.0.1', '::1']


]

]