mac 安装laravel

安装laravel之前先安装composer

  使用 curl 指令下载:

    curl -sS https://getcomposer.org/installer | php

  或是沒有安裝 curl ,也可以用 php 指令下载:

    php -r "readfile('https://getcomposer.org/installer');" | php 

  当你下载了 composer.phar 后,可以将它放在目录中,但每次当你建立新目录时,你必須再复制一个副本到新目录中,这样比较麻烦。所以最佳做法是将它放到 usr/local/bin 目录中中,成为全域指令。 
    mv composer.phar /usr/local/bin/composer 

  

  之后会在当前文件夹产生composer.phar把他放进 /usr/local/bin/composer

  在~/.bash_profile/usr/local/bin添加到环境变量

    vi ~/.bash_profile

    export PATH=/usr/local/bin:$PATH
 
  使用composer 安装 laravel

输入composer global require "laravel/installer=~1.1"命令查看

composer global require "laravel/installer=~1.1"

Changed current directory to /Users/yangyanqing/.composer

./composer.json has been created

Loading composer repositories with package information

Updating dependencies (including require-dev)

Package operations: 10 installs, 0 updates, 0 removals

  - Installing symfony/process (v4.1.1): Downloading (100%)         

  - Installing symfony/polyfill-ctype (v1.8.0): Downloading (100%)         

  - Installing symfony/filesystem (v4.1.1): Downloading (100%)         

  - Installing symfony/polyfill-mbstring (v1.8.0): Downloading (100%)         

  - Installing symfony/console (v4.1.1): Downloading (100%)         

  - Installing guzzlehttp/promises (v1.3.1): Downloading (100%)         

  - Installing psr/http-message (1.0.1): Downloading (100%)         

  - Installing guzzlehttp/psr7 (1.4.2): Downloading (100%)         

  - Installing guzzlehttp/guzzle (6.3.3): Downloading (100%)         

  - Installing laravel/installer (v1.5.0): Downloading (100%)         

symfony/console suggests installing psr/log-implementation (For using the console logger)

symfony/console suggests installing symfony/event-dispatcher ()

symfony/console suggests installing symfony/lock ()

guzzlehttp/guzzle suggests installing psr/log (Required for using the Log middleware)

Writing lock file

Generating autoload files

 

输入laravel命令查看 

laravel

Laravel Installer 1.5.0

 

Usage:

  command [options] [arguments]

 

Options:

  -h, --help            Display this help message

  -q, --quiet           Do not output any message

  -V, --version         Display this application version

      --ansi            Force ANSI output

      --no-ansi         Disable ANSI output

  -n, --no-interaction  Do not ask any interactive question

  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

 

Available commands:

  help  Displays help for a command

  list  Lists commands

  new   Create a new Laravel application.

1、进入到设置的根目录

cd /Users/username/wwwroot

2、此时可以使用 laravel new 命令建立一份全新安装的 Laravel 应用,

例如: laravel new blog 将会在当前目录下建立一个名为 blog 的目录,

此目录里面存放着全新安装的 Laravel 相关代码,

此方法跟其他方法不一样的地方在于会提前安装好所有相关代码,

不需要再通过 composer install 安装相关依赖,速度会快许多。

laravel new blog

或者

通过 Composer Create-Project,你一样可以通过 Composer 在命令行执行 create-project 来安装 Laravel:

composer create-project laravel/laravel --prefer-dist

3、打开浏览器: http://localhost/blog/publi

如果报错,需要给权限

chmod -R -777 blog

参考:

https://blog.csdn.net/u013664733/article/details/54343768 

 https://www.fujieace.com/laravel/mac-2.html
https://blog.csdn.net/biyongyao/article/details/76652677
 
 
原文地址:https://www.cnblogs.com/nyfz/p/9290315.html