Magento2 安装流程

更新日期: 2019-07-07 阅读次数: 18496 分类: magento

下载源代码

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

安装依赖

composer install

报错

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested PHP extension ext-gd * is missing from your system. Install or enable PHP's gd extension.
  Problem 2
    - The requested PHP extension ext-mcrypt * is missing from your system. Install or enable PHP's mcrypt extension.
  Problem 3
    - The requested PHP extension ext-intl * is missing from your system. Install or enable PHP's intl extension.

解决这个问题,Ubuntu 16.10 上只需要执行

sudo apt-get update	
sudo apt-get install php7.0-gd php7.0-mcrypt php7.0-intl

由于我这个系统并不是一个干净的环境,之前安装过 Laravel 5.x, 所以部分 php extension 已经满足。 若是干净的系统,应该允许

sudo apt-get update
sudo apt-get install php7.0-gd php7.0-mcrypt php7.0-curl php7.0-intl php7.0-xsl php7.0-mbstring php7.0-openssl php7.0-zip
sudo service apache2 restart

通过 web 安装向导初始化 magento2

首先配置 Nginx

server {
        listen 8091;

        root /home/zhongwei/work/magento2/;
        index index.php index.html index.htm;

        server_name localhost;

        location / {
                # try_files $uri $uri/ =404;
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        location ~ \.php$ {
		include snippets/fastcgi-php.conf;
		fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
}

reload nginx 配置.

打开 http://localhost:8091 , 被安装过程吓哭,直接把 firefox 搞成黑屏

A script on this page may be busy, or it may have stopped responding. You can stop the script now, open the script in the debugger, or let the script continue. Script: http://localhost:8091/setup/pub/angular/angular.min.js:151

换用 Chrome 尝试, 同样没有响应, 从网络请求来看

/setup/index.php/navigation 请求被 302, 之后就不断 pending 状态。

从 Nginx access.log 日志来看

"GET /setup/index.php/navigation HTTP/1.1" 302 5 "http://localhost:8091/setup/"

大量 /setup/index.php/navigation 请求被 302 跳转到 /setup 页面。没有头绪,Google 了一下,才发现 magento2 自带了 Nginx 配置文件。 位于根目录下的 nginx.conf.sample。

被这份 nginx 配置文件惊艳到了,写的非常专业。使用了官方的 nginx.conf.sample 文件之后,就能看着正常的 setup 页面了。

安装过程同样惊艳,用 angular 做的交互,确实体验非常好。有一处细节让我泪流满面

Magento Admin Address 对应的路径默认加上了随机字符串

admin_1oj4fu

非常赞,想的很周到。唯一让我胆寒的是,安装过程非常非常长,感觉新建了几万个表。。。

小等一会,安装完成。

初体验

首页空荡荡的。。。

在后台新建了一个商品,的确能搜索到,但是默认不会出现在首页。估计需要使用模板, 明天再研究一下。

解决 The requested PHP extension ext-gd * is missing from your system. Install or enable PHP's gd extension.

首先找到 php.ini 文件, 并编辑

find /etc -name php.ini
sudo vim /etc/php/7.0/fpm/php.ini

搜索 php_gd 会发现,只有 windows 的 dll 文件,而没有 linux 的配置

extension=php_gd2.dll

于是只能在 Ubuntu 上安装 gd2 extension

sudo apt-get update	
sudo apt-get install php7.0-gd

再次运行 composer install 会发现 ext-gd 已经安装成功。

关于作者 🌱

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式