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.
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)
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.
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: