文章彙整

如何使用composer安裝magento2

By Astral Web 12 months ago2 Comments
首頁  /  Magento  /  Magento-2  /  如何使用composer安裝magento2

Magento 2 (1)

Magento 其實支援多種安裝方式,除了一般常見的下載安裝包之外,因為在 Magnento 2 裡面導入了新的現代化 PHP 套件管理工具 Composer,使得我們也可以利用 Composer 來安裝 Magento。

 

執行環境:Ubuntu Linux 16.04

 

1.何謂 Composer ?

Composer 為現代化 PHP 程式的套件管理工具,僅需要 composer.json 定義檔來定義出我們需要安裝的套件,並且使用簡單的指令即可完成安裝,而 Composer 會自動協助我們計算出套件之間的相依性,這對開發人員來說,無疑的減輕的許多套件相容性的問題。Composer 的安裝方式請參考 官方文件

 

2.設定 composer.json

Composer 的套件載入需要事先寫入定義檔,一般來說會放在根目錄的資料夾,用json的檔案格式儲存,請參考 Github 連結

 

3.使用 composer 安裝 Magento 2

有了 composer.json 定義檔後,我們直接鍵入指令:

 

$sudo composer install

 

在執行的過程中,composer 會要求輸入 Magento Repositories 的 Username 及 Password 如下圖:

Magento 2 (4)

這時我們可以連結到 Magento Marketplace (快速門)裡面來尋找 Access key 裡面的 Public key 就是 Username ,而 Private key 就是 Password 啦!這時我們複製過去即可完成設定。

 

Magento 2 (3)

 

在看到跑完整個安裝流程後,我們可以看到資料夾中多了很多檔案,就代表使用composer 安裝完成拉(檔案如下圖):

Magento 2 (2)

 

設定完網頁伺服器資料夾後,於瀏覽器內鍵入網址就可以看到安裝畫面如下圖:

 

Magento 2 (1)

如此簡單的就可以把 Magento 2安裝完成,是不是非常簡單呢?

想要學習更多Magento相關知識,請參考:Magento 教學導覽

以上內容由Astralweb 歐斯瑞編寫製作

 000

推薦文章

Category:
  Magento-2

2 Comments

  • Chandler says:

    抱歉我照著教學做卻有問題~~可否幫助解決一下,謝謝。

    ec@ec:~/test$ sudo composer install
    [sudo] password for ec:
    Do not run Composer as root/super user! See https://getcomposer.org/root for details
    Loading composer repositories with package information
    Updating dependencies (including require-dev)
    Your requirements could not be resolved to an installable set of packages.

    Problem 1
    – Installation request for magento/product-community-edition 2.1.10 -> satisfiable by magento/product-community-edition[2.1.10].
    – magento/product-community-edition 2.1.10 requires ext-gd * -> the requested PHP extension gd is missing from your system.
    Problem 2
    – Installation request for phpunit/phpunit 4.1.0 -> satisfiable by phpunit/phpunit[4.1.0].
    – phpunit/phpunit 4.1.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    Problem 3
    – theseer/fdomdocument 1.6.6 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.6.5 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.6.4 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.6.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.6.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.6.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.6.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.5.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.4.3 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.4.2 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.4.1 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – theseer/fdomdocument 1.4.0 requires ext-dom * -> the requested PHP extension dom is missing from your system.
    – sebastian/phpcpd 2.0.0 requires theseer/fdomdocument ~1.4 -> satisfiable by theseer/fdomdocument[1.4.0, 1.4.1, 1.4.2, 1.4.3, 1.5.0, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6].
    – Installation request for sebastian/phpcpd 2.0.0 -> satisfiable by sebastian/phpcpd[2.0.0].

    To enable extensions, verify that they are enabled in your .ini files:
    – /etc/php/7.0/cli/php.ini
    – /etc/php/7.0/cli/conf.d/10-opcache.ini
    – /etc/php/7.0/cli/conf.d/10-pdo.ini
    – /etc/php/7.0/cli/conf.d/20-calendar.ini
    – /etc/php/7.0/cli/conf.d/20-ctype.ini
    – /etc/php/7.0/cli/conf.d/20-exif.ini
    – /etc/php/7.0/cli/conf.d/20-fileinfo.ini
    – /etc/php/7.0/cli/conf.d/20-ftp.ini
    – /etc/php/7.0/cli/conf.d/20-gettext.ini
    – /etc/php/7.0/cli/conf.d/20-iconv.ini
    – /etc/php/7.0/cli/conf.d/20-json.ini
    – /etc/php/7.0/cli/conf.d/20-mbstring.ini
    – /etc/php/7.0/cli/conf.d/20-phar.ini
    – /etc/php/7.0/cli/conf.d/20-posix.ini
    – /etc/php/7.0/cli/conf.d/20-readline.ini
    – /etc/php/7.0/cli/conf.d/20-shmop.ini
    – /etc/php/7.0/cli/conf.d/20-sockets.ini
    – /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
    – /etc/php/7.0/cli/conf.d/20-sysvsem.ini
    – /etc/php/7.0/cli/conf.d/20-sysvshm.ini
    – /etc/php/7.0/cli/conf.d/20-tokenizer.ini
    You can also run `php –ini` inside terminal to see which files are used by PHP in CLI mode.

    • Astral Web says:

      您好,我們文章僅提供免費的Magento2操作教學,如需要我們協助解決問題,請將您的問題及聯絡方式寄至info@astralwebinc.com,我們將由業務與您說明與報價,謝謝!

留下回應

你的電子郵件地址不會被公開.

取得獨家電子商務祕技

建立更好的策略靈感

跟上全球的網路趨勢

絕佳的電商解決方案

電子商務戰略全指南

每月發送電商戰略指南,只要填寫E-mail即可訂閱!

請到您的信箱確認,即可完成訂閱。