安装magento 2 simple data

这个是有难度的,看了几个教程,尝试过很多次才搞定。

我们用的是composer安装

执行这个命令,自动下载数据。记得把括号内更换成你的目录

php <your Magento install dir>/bin/magento sampledata:deploy

上面的过程中会让你输入magento key的。记得别忘记了。

 

下载完成以后执行下面命令安装 ,记得把括号内更改成你的目录

php <your Magento install dir>/bin/magento setup:upgrade

上面执行完了以后,可能有一个小错误提示,Please re-run Magento compile command 这个是可以忽略的。

这个时候就完成了测试数据的安装,可以打开首页看看。如果能打开那就一切正常。


如果打不开,那就看下边的内容:

全部执行以后,返回看你的网站,发现网站打不开了,这个时候搜索过很多,都没找到原因。

后来发现,重新执行了下权限命令,网站可以访问了。

我的用系统

  • Ubuntu: chown -R :www-data .

由于好奇开启了 Enable Javascript Bundling,Merge JavaScript Files,Minify JavaScript Files

导致后台很多功能都无法打开,前台paypal无法跳转

解决办法:从数据库入手

打开这表core_config_data ,将以下三项数值改为0.就关闭了这三项。

dev/js/merge_files

dev/css/merge_css_files

参考:http://magento.stackexchange.com/questions/80765/how-do-i-disable-merged-css-and-js

Mode name Description
default Enables you to deploy the Magento application on a single server without changing any settings. However, default mode is not optimized for production.

To deploy the Magento application on more than one server or to optimize it for production, change to one of the other modes.

  • Static view file caching is enabled
  • Exceptions are not displayed to the user; instead, exceptions are written to log files.
  • Hides custom X-Magento-* HTTP request and response headers
developer Intended for development only, this mode:

  • Disables static view file caching
  • Provides verbose logging
  • Enables automatic code compilation
  • Enables enhanced debugging
  • Shows custom X-Magento-* HTTP request and response headers
  • Results in the slowest performance (because of the preceding)
production Intended for deployment on a production system. Exceptions are not displayed to the user, exceptions are written to logs only, and static view files are served from cache only. New or updated files are not written to the file system.

以下内容来自谷歌翻译
magento 2 默认模式

使您无需更改任何设置部署一台服务器上的应用程序的Magento。然而,默认模式不用于生产优化。

到多个服务器上部署Magento的应用程序或优化其生产,换另一种模式。

静态视图文件缓存启用
例外不显示给用户;相反,异常将被写入日志文件。
隐藏定制的X Magento-* HTTP请求和响应头

magento 2 开发模式

仅用于开发,这种模式:
禁用静态视图文件缓存
提供详细的日志记录
启用自动代码编译
启用增强的调试
显示自定义X-Magento-* HTTP请求和响应头
结果最慢的性能(因为前面的)

magento 2 产品模式

用于在生产系统上部署。异常不显示给用户,例外仅写入日志和静态视图的文件被从仅高速缓存提供服务。新的或更新的文件不会被写入文件系统。

magento 2 模式转换

查看状态

php magento deploy:mode:show

开启产品模式:

magento deploy:mode:set production

开启开发模式

magento deploy:mode:set developer

 

In Magento 1.0, the configuration file that contains database settings and other information is located here:
/app/etc/local.xml

In Magento 2.0, the configuration is in the same directory (/app/etc/) but has been renamed to env.php. The file path is:

magento 2 数据库配置文件位置/app/etc/env.php

In this file, a number of key things are set, including the database connection information:

‘host’ => ‘localhost’,
‘dbname’ => ‘magento2database’,
‘username’ => ‘some-sample-username’,
‘password’ => ‘Extremely-Complicated-Password-12345’,
‘model’ => ‘mysql4’,
‘engine’ => ‘innodb’,
‘initStatements’ => ‘SET NAMES utf8;’,
‘active’ => ‘1’,

View indexer status查看索引状态

This command enables you to view the status of all or selected indexers (for example, shows whether indexers need to be reindexed).

Command options:

到magento 2根目录,然后cd bin文件,然后执行以下代码,

php magento indexer:status [indexer]

where [indexer] is a space-separated list of indexers. Omit [indexer] to view status of all indexers.

To view the list of indexers, enter

magento indexer:info

A sample follows:

magento indexer:status

Sample result:

Category Products:                                 Reindex required
Product Categories:                                Reindex required
Product Price:                                     Reindex required
Product EAV:                                       Reindex required
Stock:                                             Reindex required
Catalog Rule Product:                              Reindex required
Catalog Product Rule:                              Reindex required
Catalog Search:                                    Reindex required

Reindexing is discussed in the next section.

Reindex 执行索引

This command enables you to reindex all or selected indexers one time only.

This command reindexes one time only. To keep indexers up-to-date, you must set up a cron job.

Command options:

magento indexer:reindex [indexer]

where [indexer] is a space-separated list of indexers. Omit [indexer] to reindex all indexers.

To view the list of indexers, enter

magento indexer:info

A sample follows:

magento indexer:reindex

Sample result:

Category Products index has been rebuilt successfully in <time>
Product Categories index has been rebuilt successfully in <time>
Product Price index has been rebuilt successfully in <time>
Product EAV index has been rebuilt successfully in <time>
Stock index has been rebuilt successfully in <time>
Catalog Rule Product index has been rebuilt successfully in <time>
Catalog Product Rule index has been rebuilt successfully in <time>
Catalog Search index has been rebuilt successfully in <time>

 

花了2天来研究这个问题,最终成功安装。参考了大量资料,软件比较新,可以查看的资料非常少。不停的google去查找资源。经过反复尝试,最终实验成功。

先后尝试过LNMP 最新1.3版 用php7,但是试过了很多次,都不成功。

Magneto is an open source e-commerce application owned by eBay. It operates using a LAMP stack on most Linux distributions. This guide will focus on how to setup Magento on Ubuntu 15.04 – but the steps here should work for other versions as well.

Please note that Magento is a very resource-heavy application. For a test server, PHP requires a minimum of 512MB of RAM, but you should use at least 1GB for a small store and 4GB for a medium to large store with hundreds of products.

This tutorial assumes that you are using a freshly created VPS with no installed packages.

Installing

LAMP Stack

First, ensure that the apt-get package library is up to date by running the command below. This will ensure that the latest version of the packages are installed.

$ apt-get update

After this has completed, it is time to install the LAMP components that powers Magento (Linux, Apache, MySQL, PHP). Run the following command with sudo to install all 3 packages in one go. Alternatively, you may install these packages separately using this tutorial.

$ sudo apt-get install lamp-server^

You will need to specify a password for the MySQL root user. Make sure this password is secure and note it down as it will be needed later.

Apache Setup

Before Magneto is installed, we need to configure Apache to properly redirect and rewrite the incoming traffic. Create a virtual host file for Apache using the following command. Here, we use the nano editor, however any text editor could be used.

$ sudo nano /etc/apache2/sites-available/magento.conf

Inside this file, copy and paste our setup options into the nano interface.

<VirtualHost *:80>
    DocumentRoot /var/www/public
    <Directory /var/www/public/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
    </Directory>
</VirtualHost>

It should look similar to the screenshot below.

Save and close the file using Control + O 然后回车一下 ,然后Control + X. Next, we have to tell Apache to use the new config file, and to ignore the default config file. Execute the following commands below (in order):

$ sudo a2ensite magento.conf

$ sudo a2dissite 000-default.conf

Then, reload Apache using the command.

$ sudo service apache2 reload

PHP Setup

PHP also needs to be configured to properly handle the Magento application. As it is an extremely resource heavy application, we need to increase the memory allocation given to PHP. In this case, I will allocate 512MB as this will only be running a test store, however most stores require 1-4GB of memory.

First, open the php.ini config file with a text editor.

$ sudo nano /etc/php5/apache2/php.ini

Find the line which declares the memory limit for PHP and change it to your desired number (in this case, 512MB).

memory_limit = 512M

Save and close the file using Control + O 记得每次都要回车一下and Control + X.

Magento also needs some additional PHP modules which can be installed using apt-get. Execute the following command.

$ sudo apt-get install php5-mcrypt php5-curl php5-gd libcurl3 php5-intl php5-xsl

Once the install finishes, run the following commands.

$ sudo a2enmod rewrite
$ sudo php5enmod mcrypt

Finally, restart Apache.

$ sudo service apache2 restart

MySQL Setup

Magento uses MySQL to store almost all the data associated with the site. We need to create a database for the application to use. Start the MySQL commandline using the command below, using the password from the LAMP setup earlier.

$ mysql -u root -p

Next, execute the command below to create the database.

CREATE DATABASE magento;

Leave the MySQL commandline using Control + C.

Installing Magento

Install composer with the following command:

$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

We need to generate a keypair to clone the Magento repo. Since this requires authentication, see the Magento developer documentation for the latest instructions.

Next, place these keys in the auth file for composer using the command below.

$ sudo nano /root/.composer/auth.json

Copy and paste the contents below into the file.下面要获得magento 官方的key,官方有教程。 然后更改下面的 对应的两个key。

{
"http-basic": {
      "repo.magento.com": {
         "username": "<your public key>",
         "password": "<your private key>"
      }
   }
}

CD to the web directory.

$ cd /var/www

Clone the Magento Github repo.

$ git clone -b 2.0 https://github.com/magento/magento2.git public

CD into the cloned folder.

$ cd public

Run composer install to update the dependencies.

 $ composer install

至此安装完成,在浏览器输入域名或者ip,加上 、setup执行在线安装,这个一步一步地操作就行了。

期间可能会遇到一些问题,拿着问题去google一下就可以搞定。

权限

根据你的系统,执行以下命令

Typical examples:

  • CentOS: chown -R :apache .
  • Ubuntu: chown -R :www-data .

记得后面有个点 要加上。

然后执行下面一段命令

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

安装magento 2 simple data

这个是有难度的,看了几个教程,尝试过很多次才搞定。

我们用的是composer安装

执行这个命令,自动下载数据。记得把括号内更换成你的目录

php <your Magento install dir>/bin/magento sampledata:deploy

上面的过程中会让你输入magento key的。记得别忘记了。

 

下载完成以后执行下面命令安装 ,记得把括号内更改成你的目录

php <your Magento install dir>/bin/magento setup:upgrade

上面执行完了以后,可能有一个小错误提示,Please re-run Magento compile command 这个是可以忽略的。

全部执行以后,返回看你的网站,发现网站打不开了,这个时候搜索过很多,都没找到原因。

后来发现,重新执行了下权限命令,网站可以访问了。

我的用系统

  • Ubuntu: chown -R :www-data .

 

后记:

不吃不喝研究了两天,痛苦的过程。先后使用了linode vultr等vps。


 

参考:https://www.vultr.com/docs/installing-magento-2-on-ubuntu

安装magento 2 测试数据参考 http://devdocs.magento.com/guides/v2.0/install-gde/install/sample-data-after-composer.html