Linux 搭建Laravel環(huán)境

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.
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末揭朝,一起剝皮案震驚了整個(gè)濱河市队贱,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌潭袱,老刑警劉巖柱嫌,帶你破解...
    沈念sama閱讀 206,968評(píng)論 6 482
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異屯换,居然都是意外死亡编丘,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,601評(píng)論 2 382
  • 文/潘曉璐 我一進(jìn)店門(mén)彤悔,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)嘉抓,“玉大人,你說(shuō)我怎么就攤上這事晕窑∫制” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 153,220評(píng)論 0 344
  • 文/不壞的土叔 我叫張陵杨赤,是天一觀的道長(zhǎng)敞斋。 經(jīng)常有香客問(wèn)我,道長(zhǎng)疾牲,這世上最難降的妖魔是什么植捎? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 55,416評(píng)論 1 279
  • 正文 為了忘掉前任,我火速辦了婚禮说敏,結(jié)果婚禮上鸥跟,老公的妹妹穿的比我還像新娘。我一直安慰自己盔沫,他們只是感情好医咨,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,425評(píng)論 5 374
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著架诞,像睡著了一般拟淮。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上谴忧,一...
    開(kāi)封第一講書(shū)人閱讀 49,144評(píng)論 1 285
  • 那天很泊,我揣著相機(jī)與錄音角虫,去河邊找鬼。 笑死委造,一個(gè)胖子當(dāng)著我的面吹牛戳鹅,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播昏兆,決...
    沈念sama閱讀 38,432評(píng)論 3 401
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼枫虏,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了爬虱?” 一聲冷哼從身側(cè)響起隶债,我...
    開(kāi)封第一講書(shū)人閱讀 37,088評(píng)論 0 261
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎跑筝,沒(méi)想到半個(gè)月后死讹,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 43,586評(píng)論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡曲梗,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,028評(píng)論 2 325
  • 正文 我和宋清朗相戀三年赞警,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片稀并。...
    茶點(diǎn)故事閱讀 38,137評(píng)論 1 334
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡仅颇,死狀恐怖单默,靈堂內(nèi)的尸體忽然破棺而出碘举,到底是詐尸還是另有隱情,我是刑警寧澤搁廓,帶...
    沈念sama閱讀 33,783評(píng)論 4 324
  • 正文 年R本政府宣布引颈,位于F島的核電站,受9級(jí)特大地震影響境蜕,放射性物質(zhì)發(fā)生泄漏蝙场。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,343評(píng)論 3 307
  • 文/蒙蒙 一粱年、第九天 我趴在偏房一處隱蔽的房頂上張望售滤。 院中可真熱鬧,春花似錦台诗、人聲如沸完箩。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 30,333評(píng)論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)弊知。三九已至,卻和暖如春粱快,著一層夾襖步出監(jiān)牢的瞬間秩彤,已是汗流浹背叔扼。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 31,559評(píng)論 1 262
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留漫雷,地道東北人瓜富。 一個(gè)月前我還...
    沈念sama閱讀 45,595評(píng)論 2 355
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像降盹,于是被迫代替她去往敵國(guó)和親食呻。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,901評(píng)論 2 345

推薦閱讀更多精彩內(nèi)容