安裝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
exportPATH=/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