Ubuntu18.04通过Composer下载Magento2并安装程序

1.前提条件:

  • 安装了composer
  • lamp|lnmp 的 web环境已经搭建好
  • php 的扩展已经安装完成,如果不安装php的扩展,在下面使用composer, 程序会变得非常慢且报错,提及用户安装各种插件。为了避免这种情况,在安装完php之后,就把php的各种扩展安装起。

下面是如何安装php的扩展。(本地php以7.1为例)

sudo apt-get -y update
sudo add-apt-repository ppa:ondrej/php
sudo apt-get -y update
sudo apt-get install -y php7.1 libapache2-mod-php7.1 php7.1-common php7.1-gd php7.1-mysql php7.1-mcrypt php7.1-curl php7.1-intl php7.1-xsl php7.1-mbstring php7.1-zip php7.1-bcmath php7.1-iconv php7.1-soap

参考文档:
https://devdocs.magento.com/guides/v2.2/install-gde/prereq/php-ubuntu.html

sun@karat:/var/www/html/sun/magento2Store2$ composer  create-project --repository=https://repo.magento.com/ magento/project-commu                          nity-edition:2.2.7 mgt227
Installing magento/project-community-edition (2.2.7)
  - Installing magento/project-community-edition (2.2.7): Loading from cache
Created project in mgt227
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 298 installs, 0 updates, 0 removals
  - Installing magento/magento-composer-installer (0.1.13): Loading from cache
  - Installing vertex/sdk (1.1.0): Loading from cache
  - Installing magento/zendframework1 (1.13.1): Loading from cache
  - Installing psr/container (1.0.0): Loading from cache
  - Installing container-interop/container-interop (1.2.0): Loading from cache
  - Installing zendframework/zend-stdlib (2.7.7): Loading from cache
  - Installing zendframework/zend-hydrator (1.1.0): Loading from cache
  - Installing zendframework/zend-validator (2.11.1): Loading from cache
 ......
 ......
 .....
 
  - Installing pdepend/pdepend (2.5.2): Downloading (100%)
  - Installing phpmd/phpmd (2.6.0): Downloading (100%)
  - Installing symfony/stopwatch (v4.3.2): Downloading (100%)
  - Installing symfony/options-resolver (v4.3.2): Downloading (100%)
  - Installing friendsofphp/php-cs-fixer (v2.2.20): Downloading (100%)
  - Installing lusitanian/oauth (v0.8.11): Downloading (100%)
zendframework/zend-validator suggests installing zendframework/zend-i18n-resources (Translations of validator messages)
zendframework/zend-http suggests installing paragonie/certainty (For automated management of cacert.pem)
zendframework/zend-servicemanager suggests installing ocramius/proxy-manager (ProxyManager 0.5.* to handle lazy initialization of services)
zendframework/zend-filter suggests installing psr/http-factory-implementation (psr/http-factory-implementation, for creating file upload instances when consuming PSR-7 in file upload filters)
zendframework/zend-form suggests installing zendframework/zendservice-recaptcha (in order to use the ReCaptcha form element)
zendframework/zend-mvc suggests installing zendframework/zend-authentication (Zend\Authentication component for Identity plugin)
zendframework/zend-mvc suggests installing zendframework/zend-servicemanager-di (^1.0.1, if using zend-servicemanager v3 and requiring the zend-di integration)
zendframework/zend-math suggests installing ext-gmp (If using the gmp functionality)
zendframework/zend-math suggests installing ircmaxell/random-lib (Fallback random byte generator for Zend\Math\Rand if Mcrypt extensions is unavailable)
monolog/monolog suggests installing graylog2/gelf-php (Allow sending log messages to a GrayLog2 server)
monolog/monolog suggests installing sentry/sentry (Allow sending log messages to a Sentry server)
monolog/monolog suggests installing doctrine/couchdb (Allow sending log messages to a CouchDB server)
monolog/monolog suggests installing ruflin/elastica (Allow sending log messages to an Elastic Search server)
monolog/monolog suggests installing php-amqplib/php-amqplib (Allow sending log messages to an AMQP server using php-amqplib)
monolog/monolog suggests installing ext-amqp (Allow sending log messages to an AMQP server (1.0+ required))
monolog/monolog suggests installing ext-mongo (Allow sending log messages to a MongoDB server)
monolog/monolog suggests installing mongodb/mongodb (Allow sending log messages to a MongoDB server via PHP Driver)
monolog/monolog suggests installing aws/aws-sdk-php (Allow sending log messages to AWS services like DynamoDB)
monolog/monolog suggests installing rollbar/rollbar (Allow sending log messages to Rollbar)
monolog/monolog suggests installing php-console/php-console (Allow sending log messages to Google Chrome)
symfony/service-contracts suggests installing symfony/service-implementation
magento/framework suggests installing ext-imagick (Use Image Magick >=3.0.0 as an optional alternative image processing library)
magento/module-sales suggests installing magento/module-sales-sample-data (Sample Data version:100.2.*)
magento/module-catalog suggests installing magento/module-catalog-sample-data (Sample Data version:100.2.*)
magento/module-cms suggests installing magento/module-cms-sample-data (Sample Data version:100.2.*)
magento/module-customer suggests installing magento/module-customer-sample-data (Sample Data version:100.2.*)
magento/module-widget suggests installing magento/module-widget-sample-data (Sample Data version:100.2.*)
magento/module-theme suggests installing magento/module-theme-sample-data (Sample Data version:100.2.*)
magento/module-catalog-rule suggests installing magento/module-catalog-rule-sample-data (Sample Data version:100.2.*)
magento/module-sales-rule suggests installing magento/module-sales-rule-sample-data (Sample Data version:100.2.*)
magento/module-tax suggests installing magento/module-tax-sample-data (Sample Data version:100.2.*)
magento/module-msrp suggests installing magento/module-msrp-sample-data (Sample Data version:100.2.*)
magento/module-grouped-product suggests installing magento/module-grouped-product-sample-data (Sample Data version:100.2.*)
magento/module-downloadable suggests installing magento/module-downloadable-sample-data (Sample Data version:100.2.*)
magento/module-configurable-product suggests installing magento/module-configurable-sample-data (Sample Data version:100.2.*)
magento/module-configurable-product suggests installing magento/module-product-links-sample-data (Sample Data version:100.2.*)
zendframework/zend-session suggests installing mongodb/mongodb (If you want to use the MongoDB session save handler)
zendframework/zend-session suggests installing zendframework/zend-cache (Zend\Cache component)
paragonie/random_compat suggests installing ext-libsodium (Provides a modern crypto API that can be used to generate random bytes.)
zendframework/zend-captcha suggests installing zendframework/zend-i18n-resources (Translations of captcha messages)
zendframework/zend-captcha suggests installing zendframework/zendservice-recaptcha (ZendService\ReCaptcha component)
magento/module-wishlist suggests installing magento/module-wishlist-sample-data (Sample Data version:100.2.*)
magento/module-review suggests installing magento/module-review-sample-data (Sample Data version:100.2.*)
magento/module-bundle suggests installing magento/module-bundle-sample-data (Sample Data version:100.2.*)
vertex/module-tax suggests installing magento/module-gift-wrapping (Vertex Tax Links for Magento 2 also supports Magento's Gift Wrapping module)
vertex/module-tax suggests installing magento/module-gift-card-account (Vertex Tax Links for Magento 2 also supports Magento's Gift Card Account module)
vertex/module-tax suggests installing magento/module-reward (Vertex Tax Links for Magento 2 also supports Magento's Reward module)
ramsey/uuid suggests installing ircmaxell/random-lib (Provides RandomLib for use with the RandomLibAdapter)
ramsey/uuid suggests installing ext-libsodium (Provides the PECL libsodium extension for use with the SodiumRandomGenerator)
ramsey/uuid suggests installing ext-uuid (Provides the PECL UUID extension for use with the PeclUuidTimeGenerator and PeclUuidRandomGenerator)
ramsey/uuid suggests installing ramsey/uuid-doctrine (Allows the use of Ramsey\Uuid\Uuid as Doctrine field type.)
ramsey/uuid suggests installing ramsey/uuid-console (A console application for generating UUIDs with ramsey/uuid)
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
amzn/amazon-pay-module suggests installing magento/module-scalable-checkout (*)
amzn/amazon-pay-module suggests installing magento/module-scalable-oms (*)
magento/module-swatches suggests installing magento/module-swatches-sample-data (Sample Data version:100.2.*)
magento/module-sample-data suggests installing magento/sample-data-media (Sample Data version:100.2.*)
magento/module-offline-shipping suggests installing magento/module-offline-shipping-sample-data (Sample Data version:100.2.*)
phpseclib/phpseclib suggests installing ext-libsodium (SSH2/SFTP can make use of some algorithms provided by the libsodium-php extension.)
phpseclib/phpseclib suggests installing ext-gmp (Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.)
symfony/event-dispatcher suggests installing symfony/http-kernel
zendframework/zend-log suggests installing ext-mongo (mongo extension to use Mongo writer)
zendframework/zend-log suggests installing ext-mongodb (mongodb extension to use MongoDB writer)
zendframework/zend-log suggests installing zendframework/zend-mail (Zend\Mail component to use the email log writer)
zendframework/zend-json suggests installing zendframework/zendxml (To support Zend\Json\Json::fromXml() usage)
zendframework/zend-view suggests installing zendframework/zend-authentication (Zend\Authentication component)
zendframework/zend-view suggests installing zendframework/zend-feed (Zend\Feed component)
zendframework/zend-view suggests installing zendframework/zend-mvc-plugin-flashmessenger (zend-mvc-plugin-flashmessenger component, if you want to use the FlashMessenger view helper with zend-mvc versions 3 and up)
zendframework/zend-view suggests installing zendframework/zend-navigation (Zend\Navigation component)
zendframework/zend-view suggests installing zendframework/zend-paginator (Zend\Paginator component)
zendframework/zend-view suggests installing zendframework/zend-permissions-acl (Zend\Permissions\Acl component)
zendframework/zend-i18n suggests installing zendframework/zend-cache (Zend\Cache component)
zendframework/zend-i18n suggests installing zendframework/zend-i18n-resources (Translation resources)
jms/serializer suggests installing doctrine/cache (Required if you like to use cache functionality.)
consolidation/output-formatters suggests installing symfony/var-dumper (For using the var_dump formatter)
symfony/dependency-injection suggests installing symfony/expression-language (For using expressions in service container configuration)
symfony/dependency-injection suggests installing symfony/proxy-manager-bridge (Generate service proxies to lazy load them)
consolidation/robo suggests installing pear/archive_tar (Allows tar archives to be created and extracted in taskPack and taskExtract, respectively.)
consolidation/robo suggests installing henrikbjorn/lurker (For monitoring filesystem changes in taskWatch)
consolidation/robo suggests installing patchwork/jsqueeze (For minifying JS files in taskMinify)
consolidation/robo suggests installing natxet/CssMin (For minifying CSS files in taskMinify)
facebook/webdriver suggests installing ext-SimpleXML (For Firefox profile creation)
phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.5)
sebastian/global-state suggests installing ext-uopz (*)
phpunit/phpunit suggests installing phpunit/php-invoker (^1.1)
phpunit/phpunit suggests installing ext-xdebug (*)
codeception/codeception suggests installing aws/aws-sdk-php (For using AWS Auth in REST module and Queue module)
codeception/codeception suggests installing codeception/specify (BDD-style code blocks)
codeception/codeception suggests installing codeception/verify (BDD-style assertions)
codeception/codeception suggests installing codeception/phpbuiltinserver (Start and stop PHP built-in web server for your tests)
codeception/codeception suggests installing league/factory-muffin (For DataFactory module)
codeception/codeception suggests installing league/factory-muffin-faker (For Faker support in DataFactory module)
codeception/codeception suggests installing symfony/phpunit-bridge (For phpunit-bridge support)
codeception/codeception suggests installing stecman/symfony-console-completion (For BASH autocompletion)
friendsofphp/php-cs-fixer suggests installing php-cs-fixer/phpunit-constraint-isidenticalstring (For IsIdenticalString constraint.)
friendsofphp/php-cs-fixer suggests installing php-cs-fixer/phpunit-constraint-xmlmatchesxsd (For XmlMatchesXsd constraint.)
lusitanian/oauth suggests installing predis/predis (Allows using the Redis storage backend.)
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files

通过命令安装:

sun@karat:/var/www/html/sun/magento2Store2/mgt227$ bin/magento setup:install --base-url=http://120.78.178.239 --db-host=localhost --db-name=mgt227 --db-user=sun --db-password=sun.chengdu9! --backend-frontname=admin --admin-firstname=admin --admin-lastname=admin --admin-email=admin@admin.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=USD --timezone=America/Chicago --use-rewrites=1

安装完成之后,在浏览器中打开ip地址访问:

出现500 错误。

这个时候,你需要为站点设置权限,操作如下:

设置所有权:

sun@karat:/var/www/html/sun/magento2Store2$ sudo chown -R :www-data .

设置权限 :

find . -type d -exec chmod 770 {} + && find . -type f -exec chmod 660 {} + && chmod u+x bin/magento

如果必须输入命令sudo,请使用:

sudo find . -type d -exec chmod 770 {} + && sudo find . -type f -exec chmod 660 {} + && sudo chmod u+x bin/magento

Leave a comment

您的电子邮箱地址不会被公开。 必填项已用*标注