http://tutsnare.com/how-to-install-yii2-on-ubuntu/

How to install Yii2 on ubuntu using composer

Best way to install Yii Framework is using composer. Below we will see installation steps of a php framework yii2 on ubuntu. Let’s see How to install yii2 on ubuntu using composer. Before composer install we need some more packages installation. In this article (How to install Yii2 on ubuntu using composer) we will explore step by step all the commands to make yii2 installation easy and need to make yii2 install. You need to just run these commands step by step via terminal.

Requirement :-
PHP >= 5.4
Some of packages installed :- curl, openssl, mcrypt etc.

Below are the steps of installing yii2 on ubuntu using composer:- first we need to install latest update and upgrade of ubuntu server. so for this run below command at your terminal.

sudoapt-getupdatesudoapt-getupgrade

After update we need to install php, apche, mysql (if not already installed)

Install php mysql and apache

sudoapt-getinstallapache2sudoapt-getinstallphp5sudoapt-getinstallmysql-serversudoapt-getinstallphp5-mysql

Now we need to install some of require extension (json, curl, mcrypt etc.) to run and download yii2 framework. and then restart apache server to setup all extension. May be you don’t need to all extension but it’s sometimes require extension you need.

#installingjsonextensionsudoapt-getinstallphp5-json#installingunzipextensionsudoapt-getinstallunzip#installingcurlextensionsudoapt-getinstallcurl#installingopensslextensionsudoapt-getinstallopenssl#installingmcryptextensionsudoapt-getinstallphp5-mcrypt#enablemcryptextensionsudophp5enmodmcrypt#enablemodrewriteextensionsudoa2enmodrewrite#phpgdextensionsudoapt-getinstallphp5-gd#restartingapachesudoserviceapache2restart

After successfully configure all php setup and require extension we need to install composer to download yii2 from remote server. for this first command will be for download composer using curl then second one move composer to local user directory for make composer globally use.

#installingcomposercurl-sShttps://getcomposer.org/installer|php#movecomposergloballysudomvcomposer.phar/usr/local/bin/composer#checkcomposerworkingcomposer


Note :-


if you need,please modify chinese source ,or it will be slow,if there is a ladder,you can skip,like this:

composerconfig-grepositories.packagistcomposerhttp://packagist.phpcomposer.com

申请github token,其他项目也会用到,不然会看到

You'd better apply for a token GitHub, and other projects will be used, otherwise you will see:

Couldnotfetchhttps://api.github.com/repos/jquery/jquery,pleasecreateaGitHubOAuthtokentogoovertheAPIratelimitHeadtohttps://github.com/settings/tokens/new?scopes=repo&description=Composer+on+mrgeneral-linux+2015-09-05+1450toretrieveatoken.Itwillbestoredin"/home/chengxiaobai/.composer/auth.json"forfutureusebyComposer.Token(hidden)

If you watch that when you installing composer,you will creating a token like that:

sign up a github account,then add one emali.

create a token:

In the top right corner of any page, click your profile photo, then click Settings.

In the user settings sidebar, click Personal access tokens.

Click Generate new token.

Give your token a descriptive name.

Select the scopes you wish to grant to this token. The default scopes allow you to interact with public and private repositories, user data, and gists.

Click Generate token.

ce4249e2a0a817c22226bbc62e790ae3f6aaf5c4

Personal access tokens

Tokens you have generated that can be used to access the GitHub API.

Make sure to copy your new personal access token now. You won’t be able to see it again!

If you thave already installed composer and it’s a old version you can update composer via below command

#updatingcomposercomposerself-update

Now we have composer installed successfully on our ubuntu. and then we need to install yii2 on ubuntu. I am sharing steps below with terminal command run screen-shots that how to install yii2 on ubuntu.

Now need to install Composer asset plugin first using composer. Composer asset plugin allows managing bower and npm package dependencies.

#installComposerassetplugincomposerglobalrequire"fxp/composer-asset-plugin:1.0.0"

Now run below command to install yii2. First i am going switch to my preferred destination where i want to install yii2 so i am installing at /var/www/html/ directory.
Note:- During installation Composer may ask for your Github login credentials. This is normal because Composer needs to get enough API rate-limit to retrieve the dependent package information from Github.

更改composer 源(更改成https):

vim~/.composer/config.json

更改为:

#changingdircd/var/www/html/#installyii2composercreate-projectyiisoft/yii2-app-basicbasic

You can also give your location at installation time see Full command of yii2 installation is there “–prefer-dist” means location where you want to install yii.

composercreate-project--prefer-distyiisoft/yii2-app-basicbasic

Now check your preferred location you have a new directory named “basic” you can rename it. also you can rename basic to your-name at installation time like below.

composercreate-project--prefer-distyiisoft/yii2-app-basicNewName

Now you are done with how to install yii2 on ubuntu. and open url on http://localhost/basic/web/ and bam. Now you can enjoy a new php framework. you can get more about this on official site of yii framework and see what’s new features you are getting. you will really enjoy this php framework.

Note :- If you want to install the latest development version of Yii then you need to execute below command via terminal.