YII2 Linux Installation Tutorials

Source: Internet
Author: User
Tags mcrypt yii

Original link: Yii Chinese web (yii-china.com) [document]

Install extensions

The best way to install Yii is to install it using composer, so we need to install composer, but in order to install composer, we need to install a lot of expansion packs about composer and Yii2, don't worry, the following tutorial will teach you all the steps. Most of our work is done on Linux terminals, and I'll give you all the commands you need to copy these commands and run them on your terminal.

Let's start now by connecting the tools to your Linux terminal (such as putty, etc.) and then installing the composer to install the two expansion packs, which you can ignore if installed

1. Installing the Curl Extension

sudo apt-get Install Curl

2. Installing the PHP5-CLI Extension

sudo apt-get install php5-cli

Here you will be asked to confirm if you want to install, enter Yes to go to execute

3. Installing Php5-mysql

sudo apt-get install Php5-mysql

4. Installing Php5-mcrypt

sudo apt-get install Php5-mcrypt

and enable it with the following command

sudo php5enmod mcrypt

5. Install PHP5-GD (in order to display a picture of the verification code)

sudo apt-get install PHP5-GD

The above 5 expansion packs only need to be installed once, if the original installation does not need to repeat the installation, the installation of YII2 in the future does not need to re-install the above 5 expansion packs.

Installing composer

Now we can prepare to install composer, and let it have global access, home we need to download composer, copy the following command and execute

Curl-ss Https://getcomposer.org/installer | Php

Then execute the following command to make it globally accessible

sudo mv Composer.phar/usr/local/bin/composer

Status quo every time you use composer, you can run it in the form of a composer command.

Installing YII2

After installing composer, run the following command to install the composer Asset plugin:

Composer global require "fxp/composer-asset-plugin:~1.1.1"

You may be asked to enter GitHub's account password at the time of installation, enter it, and if you do not have an account, go to GitHub and register for one, completely free of charge.

Then we are ready to start installing YII2 's Basic and Advanced editions. Enter your root directory, if you are using LAMPP you can run the following command

cd/opt/lampp/htdocs/

Run the following command to install the basic version:

Composer Create-project--prefer-dist Yiisoft/yii2-app-basic

Then you can see us through composer to download the basic version of Yii2, after the download is complete you can rename the download file, take a name you like to

Now if you run LAMPP, you can access the basic version of YII2 with a simple link

Localhost/basic/web

Now let's install the advanced version, it may be more complicated to install the advanced version, but don't worry, let's move on to our root directory and execute the following command

Composer Create-project--prefer-dist yiisoft/yii2-app-advanced advanced

This time we need to insert a command that renames yii2-app-advanced as advanced into our Operations command.

After the download is complete, we need to initialize the project and create the database by running the Database Migration command

CD Advanced

Execute the following command

PHP Init

You need to choose the environment (0-DEV environment or 1-production environment), here will again let you confirm whether to generate the initialization file, enter Yes, press ENTER to continue

Now you can create an app for your project, you can use a lot of tools you like, such as "PhpMyAdmin", give the database a name and then add the corresponding database information in the configuration file.

VI common/confg/main-local.php

Modify the relevant database configuration information, I believe everyone will change, here will not repeat, do not look at the Windows installation tutorial

Then execute the Database Migration command to build the database, or use the tool to manually run SQL to generate the data table. such as NAVICAT, etc.

./yii Migrate

Finally, you can access it through a simple link:

Localhost/advanced/frontend/web

Or

Localhost/advanced/backend/web

Note: If there is a problem in the installation process, it is recommended to see whether the read and write permissions of some files are not open, recommended to check the chmod and chown these two commands to resolve

YII2 Linux Installation Tutorials

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.