PHP酌摇、Mysql和Nginx的安裝請(qǐng)參照:
CentOS7快速搭建LNMP環(huán)境
安裝Composer
Laravel是使用composer來(lái)做包依賴(lài)管理的描焰,Laravel的安裝也同樣需要composer纸兔。所以我們搭建好了PHP、Mysql留攒、Nginx(Apache)之后跃脊,還需要安裝composer。
這里我只做composer的安裝介紹。
Composer網(wǎng)址
- composer下載
curl -sS https://getcomposer.org/installer | php
- composer移動(dòng)到系統(tǒng)$PATH可以搜索到的路徑下吹泡,這樣以后可以直接在命令行使用composer命令
mv composer.phar /usr/local/bin/composer
- 修改composer的執(zhí)行權(quán)限
chmod +x /usr/local/bin/composer
- 查看是否已經(jīng)安裝成功
composer -v
看到看到終端會(huì)輸出以下信息骤星,說(shuō)明已經(jīng)安裝成功了。
[root@lmc ~]# composer -v
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.4.2 2017-05-17 08:17:52
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
--profile Display timing and memory usage information
--no-plugins Whether to disable plugins.
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
about Short information about Composer.
archive Create an archive of this composer package.
browse Opens the package's repository URL or homepage in your browser.
clear-cache Clears composer's internal package cache.
clearcache Clears composer's internal package cache.
config Set config options.
create-project Create new project from a package into given directory.
depends Shows which packages cause the given package to be installed.
diagnose Diagnoses the system to identify common errors.
dump-autoload Dumps the autoloader.
dumpautoload Dumps the autoloader.
exec Execute a vendored binary/script.
global Allows running commands in the global composer dir ($COMPOSER_HOME).
help Displays help for a command
home Opens the package's repository URL or homepage in your browser.
info Show information about packages.
init Creates a basic composer.json file in current directory.
install Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.
licenses Show information about licenses of dependencies.
list Lists commands
outdated Shows a list of installed packages that have updates available, including their latest version.
prohibits Shows which packages prevent the given package from being installed.
remove Removes a package from the require or require-dev.
require Adds required packages to your composer.json and installs them.
run-script Run the scripts defined in composer.json.
search Search for packages.
self-update Updates composer.phar to the latest version.
selfupdate Updates composer.phar to the latest version.
show Show information about packages.
status Show a list of locally modified packages.
suggests Show package suggestions.
update Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.
validate Validates a composer.json and composer.lock.
why Shows which packages cause the given package to be installed.
why-not Shows which packages prevent the given package from being installed.
安裝Laravel
composer安裝之后我們就可以安裝Laravel了
- 安裝Laravel
composer global require "laravel/installer"
[root@lmc ~]# composer global require "laravel/installer"
Changed current directory to /root/.config/composer
Using version ^1.3 for laravel/installer
./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 (v3.3.0): Downloading (100%)
- Installing psr/log (1.0.2): Downloading (100%)
- Installing symfony/debug (v3.3.0): Downloading (100%)
- Installing symfony/polyfill-mbstring (v1.3.0): Downloading (100%)
- Installing symfony/console (v3.3.0): 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.2.3): Downloading (100%)
- Installing laravel/installer (v1.3.5): Downloading (100%)
symfony/console suggests installing symfony/event-dispatcher ()
symfony/console suggests installing symfony/filesystem ()
Writing lock file
Generating autoload files
[root@lmc ~]# laravel -v
-bash: laravel: command not found
安裝完成之后我們發(fā)現(xiàn)不能直接使用laravel命令
但是我們看到laravel其實(shí)已經(jīng)安裝完成了
[root@lmc ~]# ls .config/composer/vendor/bin/ -l
total 0
lrwxrwxrwx 1 root root 28 Jun 4 07:12 laravel -> ../laravel/installer/laravel
為了使用方便爆哑,我們將laravel命令放到系統(tǒng)的$PATH里面
vi ~/.bashrc
在最后加上laravel所在的路徑洞难,我的路徑是/root/.config/composer/vender/bin/
# .bashrc
# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
export PATH=/root/.config/composer/vendor/bin/:$PATH
為了生效,執(zhí)行下面命令
source ~/.bashrc
現(xiàn)在我們直接使用命令
laravel -v
看到下面的信息說(shuō)明我們可以直接使用laravel命令了
Laravel Installer 1.3.5
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.