1. 安装composer.
  2. 进入nginx主目录 cd /Applications/MAMP/htdocs/
  3. 设置国内镜像,执行 composer config -g repo.packagist composer https://packagist.phpcomposer.com
  4. 下载laravel, composer global require "laravel/installer
  5. 新建laravel项目composer create-project laravel/laravel ldemo --prefer-dist。安装成功后,看到htdocs目录下有了新目录ldemo。需要看到vendor目录下有了autoload.php才算安装成功。如果看到有报错信息,例如
    - Installing paragonie/random_compat (v9.99.99): Downloading (failed)       
    The "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" file could not be downloaded: failed to open stream: Operation timed out
    Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
    Downloading (failed)       
    Downloading (failed)       
    Downloading (failed)    Failed to download paragonie/random_compat from dist: The "https://api.github.com/repos/paragonie/random_compat/zipball/84b4dfb120c6f9b4ff7b3685f9b8f1aa365a0c95" file could not be downloaded: failed to open stream: Operation timed out
    Now trying to download from source

那么需要重新下载random_compat.
执行 composer require paragonie/random_compat:2.*

  1. 生成key. php artisan key:generate
  2. 把项目主目录设到ldemo/public目录下,访问http://localhost/.