如何使用composer安裝magento2
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 Marketplace (快速門)裡面來尋找 Access key 裡面的 Public key 就是 Username ,而 Private key 就是 Password 啦!這時我們複製過去即可完成設定。
在看到跑完整個安裝流程後,我們可以看到資料夾中多了很多檔案,就代表使用composer 安裝完成拉(檔案如下圖):
設定完網頁伺服器資料夾後,於瀏覽器內鍵入網址就可以看到安裝畫面如下圖:
如此簡單的就可以把 Magento 2安裝完成,是不是非常簡單呢?
想要學習更多Magento相關知識,請參考:Magento 教學導覽
Comments (2)
抱歉我照著教學做卻有問題~~可否幫助解決一下,謝謝。
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.
您好,我們文章僅提供免費的Magento2操作教學,如需要我們協助解決問題,請將您的問題及聯絡方式寄至[email protected],我們將由業務與您說明與報價,謝謝!