magento 2 安装教程 以及安装测试数据

 

花了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

 

原创文章,作者:卧龙涤生,如若转载,请注明出处:https://www.chuang-ke.com/1821

(0)
上一篇 2016年3月26日 下午8:03
下一篇 2016年4月11日 下午6:50

相关推荐

评论列表(33条)

  • 高仿奢侈品
    高仿奢侈品 2017年3月19日 下午1:06

    工厂直批 Givenchy(纪梵希)Christian Louboutin(红底鞋/CL/克里斯蒂娜·鲁布托)LOEWE(罗意威)Bottega Venetta(BV)PUMA(彪马)narrnanyuandan.tk

  • 丝袜美腿
    丝袜美腿 2017年3月19日 下午5:44

    快播丝袜 闻丝袜 内衣丝袜 男穿丝袜 丝袜高跟美女 http://www.meizi1.com

  • 原单正品
    原单正品 2017年3月20日 上午4:19

    ➉工厂直批IWC(万国)Tiffany & Co(蒂凡尼))阐幽(化妆品牌)威信 LoveMeJck

  • 新用户952774
    新用户952774 2017年4月10日 下午2:28

    好好看哎 假不假啊

  • 新用户952774
    新用户952774 2017年4月10日 下午2:28

    好好看哎 假不假啊

  • 新用户952774
    新用户952774 2017年4月10日 下午2:28

    好好看哎 假不假啊

  • 新用户952774
    新用户952774 2017年4月10日 下午2:28

    好好看哎 假不假啊

  • 新用户214039
    新用户214039 2017年4月19日 下午7:01

    是吗是吗是吗?

  • 新用户083747
    新用户083747 2017年4月21日 下午1:56

    放在台湾 那就是街头艺人

  • 新用户227738
    新用户227738 2017年4月22日 下午1:51

    不对鸣人的初吻是和佐助

  • 新用户313916
    新用户313916 2017年4月23日 下午1:54

    血色十字军指挥官雷诺莫格莱尼和大检察官怀特迈恩不得不说的故事

  • 新用户313916
    新用户313916 2017年4月23日 下午1:54

    血色十字军指挥官雷诺莫格莱尼和大检察官怀特迈恩不得不说的故事

  • 新用户313916
    新用户313916 2017年4月23日 下午1:54

    血色十字军指挥官雷诺莫格莱尼和大检察官怀特迈恩不得不说的故事

  • 新用户968138
    新用户968138 2017年4月24日 下午1:51

    投下N2爆雷

  • 新用户968138
    新用户968138 2017年4月24日 下午1:51

    投下N2爆雷

  • 新用户763447
    新用户763447 2017年4月26日 下午1:52

    这款塑料钱各种说三防,现在开始打脸了

  • 新用户955793
    新用户955793 2017年4月27日 下午1:48
  • 新用户955793
    新用户955793 2017年4月27日 下午1:48
  • 新用户955793
    新用户955793 2017年4月27日 下午1:48
  • 新用户542967
    新用户542967 2017年4月28日 下午1:49

    来洒我呀来呀

  • 新用户542967
    新用户542967 2017年4月28日 下午1:49

    来洒我呀来呀

  • 新用户542967
    新用户542967 2017年4月28日 下午1:49

    来洒我呀来呀

  • 新用户985407
    新用户985407 2017年4月29日 下午1:38

    ← ←贵圈真乱…

  • 新用户985407
    新用户985407 2017年4月29日 下午1:38

    ← ←贵圈真乱…

  • 新用户985407
    新用户985407 2017年4月29日 下午1:38

    ← ←贵圈真乱…

  • 新用户985407
    新用户985407 2017年4月29日 下午1:38

    ← ←贵圈真乱…

  • 新用户985407
    新用户985407 2017年4月29日 下午1:38

    ← ←贵圈真乱…

  • 新用户552501
    新用户552501 2017年5月4日 下午8:37

    Without $113

  • 新用户552501
    新用户552501 2017年5月4日 下午8:37

    Without $113

  • 新用户552501
    新用户552501 2017年5月4日 下午8:37

    Without $113

  • 新用户709774
    新用户709774 2017年5月9日 下午6:56

    其实他们不算老……

  • 新用户709774
    新用户709774 2017年5月9日 下午6:56

    其实他们不算老……

  • 新用户709774
    新用户709774 2017年5月9日 下午6:56

    其实他们不算老……

创客交流群