Based on Laravel Development Blog Application Series--Set up LINUX/MAC Local development environment

Source: Internet
Author: User
Tags composer install install node

1. Differences between different Linux distributions

There are some nuances between different Linux distributions, especially the Package Manager: CentOS and Fedora use Yum as the package Manager, while Ubuntu uses apt, there is no official Package Manager on OS X except the App Store, but there is a Unofficial OS X Package Manager-- homebrew . Aside from appearances, the principles behind these *nix systems are consistent, including OS X.

Disclaimer: The Ubuntu 15.10 system is used by default in this section without special instructions.

2. Install PHP

PHP is usually pre-installed on the system and can be viewed from the terminal:

Laravel 5.1 requires PHP version 5.5.9 or above, if you have not installed PHP, or PHP version is less than 5.5.9, then you need to use the Package Manager to install or upgrade PHP:

sudo apt-get install php5
3. Install node. js

You also need to install node. js for later use of gulp.

In general, node. JS is already installed. You can check to npm See if node. js is installed on the system by checking the version:

If it is not installed, there are two ways to install it:

You can install using the system-provided package Manager (OS X can also be used homebrew to install):

sudo apt-get install nodejs sudo apt-get install nodejs-legacysudo apt-get install NPM

Or go to node. JS official Download the correct version that matches the system:

Global Installation Gulp

You can use the Node Package Manager (NPM) to install gulp globally:

sudo npm install-g Gulp

After the installation gulp is complete, check that the version verification was successfully installed:

Global installation Bower (optional)

Also use the Node Package Manager (NPM) to install bower globally:

sudo npm install-g Bower

After the installation is complete, review the bower version Verification for successful installation:

Note: The above is only the global installation of Gulp and bower, if you want to use in a specific project, but also need to use in the project npm install for local installation, which is mentioned later.

4, installation Composer

Composer is a package dependency manager for PHP. The following commands can be easily installed in the *nix system (as in OS X and Linux):

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

composer.phar After downloading, move it to the system path:

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

Then review the Composer version to make sure it is available:

Use the Install on OS X homebrew (optional):

~> Brew Update ~> brew tap Homebrew/dupes ~> Brew tap homebrew/php ~> Brew Install composer
5. Add SSH Key

If you have not yet added SSH Key to the machine, you can add it using the methods provided below.

First check if SSH Key already exists:

LS ~/.ssh

If you do not see  id_rsa   and  id_rsa.pub   need to be created with the following command (return with default value if prompted):

Ssh-keygen-t rsa-c "[Email protected]"

Be careful to replace them with [email protected] your e-mail address.

6. Add Vagrant box Homestead

Download the Vagrant box Laravel Homestead using the following command:

Vagrant Box Add Laravel/homestead

During execution, you will be asked to select the virtual machine you want to use and choose VirtualBox:

The next download process takes a long time, wait patiently, or go for a cup of coffee and do something else.

Successful installation will output the installation success information:

7, installation Homestead Global Installation Homestead

Once the download is complete, we can use Composer to install the Homestead globally:

Composer global require "laravel/homestead=~2.0"
add Homestead to System path

Composer install Homestead to the directory under the Composer installation directory vendor (Linux:/home/laravelacademy/.composer,os x:/users/ Laravelacademy/.composer).

For direct access at the terminal homestead, you need tohomesteadThe directory you are adding to the system path, you need to add this line of code to the ~/.BASHRC   file End and save, re-open the terminal to implement the  homestead   added to the system path:

Export path= "~/.composer/vendor/bin:vendor/bin: $PATH"
Verifying Homestead installation

Run the following command in the terminal to view the Homestead version to verify that it was successfully installed:

Initialize Homestead

Once the Homestead is installed and homestead added to the system path, the Homestead can be initialized:

Note: You only need to initialize the Homestead once, and you won't have to initialize it again.

8. Log in to the Homestead virtual machine

Before we start the Homestead, we need to create a directory in the user directory to hold the project code Code , and then use the homestead up command to start the Homestead virtual machine:

Problems that may occur: if you performhomestead upCommand has been downloadedlaravel/homesteadand is 0.3.3 or 0.3.0 version, need to be inComposer\vendor\laravel\homestead\scripts\homestead.rbThe 14th line of the file foundconfig.vm.box_version = settings["version"] ||= "<= 0.3.0", put<=0.3.0Change into>=0.4.0Can.

Now that the Homestead virtual machine is running, even if you close the current terminal window, Homestead is still running in the background, only the run homestead halt command will shut down the virtual machine.

Next you can homestead ssh log on to the virtual machine using a command:

9, installation Laravel

Finally, to install the Laravel installer, run the following command in the host terminal (note that it is not running in the Homestead virtual machine):

Composer global require "laravel/installer=~1.1"

Since we have previously added the Composer bin directory to the system path, the laravel command can be executed directly from any path in the terminal. After the installation is complete, review the version verification for successful installation:

So far, we have installed the Laravel development environment on the LINUX/MAC system, then we can formally start the development of Laravel application! Enjoy it!

Based on Laravel Development Blog Application Series--Set up LINUX/MAC Local development environment

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.