安装magento2和测试数据

22.32K 浏览M2安装设置

安装magento2和测试数据

安装流程图

How Magento installation works

 

 

环境

服务器环境

2.4.x版本:

https://devdocs.magento.com/guides/v2.4/install-gde/system-requirements.html

 

2.3.x版本:

https://devdocs.magento.com/guides/v2.3/install-gde/system-requirements-tech.html

 

2.2.x版本:

https://devdocs.magento.com/guides/v2.2/install-gde/system-requirements-tech.html

浏览器环境

https://devdocs.magento.com/guides/v2.2/install-gde/system-requirements_browsers.html

  • Internet Explorer 11 or later, Microsoft Edge, latest–1
  • Firefox latest, latest–1 (any operating system)
  • Chrome latest, latest–1 (any operating system)
  • Safari latest, latest–1 (Mac OS)
  • Safari Mobile for iPad 2, iPad Mini, iPad with Retina Display (iOS 7 or later), for desktop storefront
  • Safari Mobile for iPhone 4 or later; iOS 7 or later, for mobile storefront
  • Chrome for mobile latest–1 (Android 4 or later) for mobile storefront

前提条件

1, 已安装对应版本的php和mysql,以及magento2需要的php扩展库。

2, 已安装apache或者nginx

3, 已安装composer。

未安装的参考install_composer

4, 改php.ini配置文件

   memory_limit 设为1024M
   max_execution_time 设为1800

注意:2.4.x的必须要安装Elasticsearch以及https以及php7.4才能正常访问,并且只能通过命令行安装。

如果你不是专业人士,建议还是安装2.3.x比较好,2.4.x对服务器要求更高了,不建议小商家使用。

参考

https://www.kancloud.cn/zouhongzhao/magento2-in-action/628429

https://devdocs.magento.com/guides/v2.4/install-gde/install/cli/install-cli-install.html

 

 

安装

一,composer下载m2 (推荐)

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition

会提示输入用户名和密码。

这个用户名和密码需要到

https://marketplace.magento.com/customer/accessKeys/list/

去注册。

我的是:

Username: 351f04818e0e872f40eae452f594fe8d Password: caaa64937c8fcc78749feb2a9c91db94

如果下载的文件不全的话,就直接clone github 或者下载对应版本的zip后解压

git clone https://github.com/magento/magento2.git

注意:
如果命令行安装失败的话,可以直接git clone下载源码(最新版2.3.1)。(不推荐,仅供开发环境测试用,不建议在线上部署github版,以后升级很麻烦
国内镜像 速度很快

git clone https://gitee.com/zouhongzhao/magento2.git

 

二, 执行完后

1)安装依赖

composer install

 

2)导入测试数据(主要是联网下载图片和数据,可不导,因为非常慢)

php bin/magento sampledata:deploy

**如果有报错的话 等下面第3步安装完成之后再导入测试数据。

注意,这里也可以直接下载测试数据压缩包安装。

下载地址:

https://magento.com/tech-resources/download

3), 执行完后,在线安装网店

浏览器安装网店(域名后面加/setup):

比如http://test.com

访问:

http://test.com/setup

这里设置中文语言和时区
image /assets/images/1-3rOBgACEPOKhkgmp.png

按照提示安装完成。

4), 最后在更新下系统

1, 给文件权限

先创建个普通用户(比如我的是zou),用它来管理该项目。

如果你是nginx服务器(默认用户一般是www-data),

把zou加入web服务器组,也就是拥有www-data的权限

usermod -a -G www-data zou
find . -type f -exec chmod 644 {} ; && find . -type d -exec chmod 755 {} ; && find ./var -type d -exec chmod 777 {} ; && chmod 777 var/ -R && find ./pub/media -type d -exec chmod 777 {} ; && find ./pub/static -type d -exec chmod 777 {} ; && chmod 777 ./app/etc && chmod 644 ./app/etc/*.xml && chmod u+x bin/magento
chown zou:zou . -hR  (注意:这里的zou换成你的服务器用户名)

2,更新系统

php bin/magento setup:upgrade 
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy en_US -f
php bin/magento indexer:reindex 
php bin/magento cache:clean && php bin/magento cache:flush

如果提示权限问题的话,就切换到root来执行

sudo php bin/magento setup:upgrade 
sudo php bin/magento setup:di:compile 
sudo php bin/magento setup:static-content:deploy en_US -f

3,安装中文语言包

composer require mageplaza/magento-2-chinese-language-pack:dev-master 
php bin/magento setup:static-content:deploy en_US zh_Hans_CN -f 
php bin/magento cache:clean 
php bin/magento cache:flush

https://www.mageplaza.com/magento-2-chinese-language-pack.html

https://github.com/mageplaza/magento-2-chinese-language-pack

安装包配合命令行安装是装得最快最不容易出错的方式

安装包配合命令行安装是装得最快最不容易出错的方式

安装包配合命令行安装是装得最快最不容易出错的方式

 

资深phper可以直接在命令行里一键安装并配置magento2

见: https://devdocs.magento.com/guides/v2.2/install-gde/install/cli/install-cli-install.html

5),配置cron

m2发邮件都是通过cron定时发的,然后索引也是定时自动刷新的,如果是上线了的话必须得配置cron。

//bbs.mallol.cn/?thread-147.htm

疑难杂症

有任何疑难杂症,请猛戳官方安装指南,里面有你意想不到的答案。

演示网站

http://magento2.mallol.cn/

相关

Magento2 升级核心版本

参考

https://www.kancloud.cn/zouhongzhao/magento2-in-action/628429

最后于 2月前 被admin编辑 ,原因:

已回答
0

网名 安装后有这个警告 ,如何解决

警告忽略就行,不影响正常工作就不用管。

0
您正在查看4个回答中的1个,单击此处查看所有回答。