GIT Centos 下安装 Magento 2

7天成为Magento系统架构师,现在开始学习Magento全栈开发!

《Magento2.X企业级开发实战》

本文会持续更新 请关注本文

作者 ajiang-tuzi 版本 0.2.2

Step 1: 验证你的系统要求

必要条件 如何检查
Apache 2.2 or 2.4 Ubuntu: apache2 -v
CentOS: httpd -v
PHP 5.5.x or 5.6.x php -v
MySQL 5.6.x mysql -u [root user name] -p

  • 升级数据库方法
  • 官网直接下载安装方法
  • git composer 安装 方法
  • 自搭环境方法
    使用我搭的LMPA S环境 运行网站 以Magento 为例
    安装环境
    系统:Centos
    我使用的环境包:lnmp1.2-full 由于这个环境是之前安装的 就不换了 但要升级数据库和php 版本
    推荐环境包:lnmp1.3-full 这个版本的话应该要节省 不少时间

    git composer 安装 方法

    Step 2: 准备安装
    1.安装 Composer
    2.从仓库中克隆一份到本地
    -1.在浏览器中打开 magento git 仓库
    -2.点击复制到剪贴板按钮 就像这样

    -3改变你服务器的 目录 到到web 服务器的目录 比如
    centos /home/wwwroot/
    -4 键入 git clone
    示范

    git clone [-b 2.0] https://github.com/magento/magento2.git
    [root@ajiang-tuzi mage2]# git clone -b 2.0 https://github.com/magento/magento2.git
    Initialized empty Git repository in /home/wwwroot/magento2/.git/
    remote: Counting objects: 931607, done.
    remote: Compressing objects: 100% (3434/3434), done.
    remote: Total 931607 (delta 2300), reused 0 (delta 0), pack-reused 927465
    Receiving objects: 100% (931607/931607), 246.30 MiB | 16.75 MiB/s, done.
    Resolving deltas: 100% (522229/522229), done.
    

    使用 -b 2.0 克隆2.0 的分支 这是默认选项

    Step 3:预安装
    我运气不错 刚开始安装就出现了这个 错误
    我的环境是 lnmp1.2-full 可能是版本太低
    如果 你使用的是 lnmp1.3-full 这个版本的话应该要节省 不少时间

    [root@ajiang-tuzi mage2]# 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-intl * is missing from your system. Install or enable PHP's intl extension.
      Problem 2
        - The requested PHP extension ext-xsl * is missing from your system. Install or enable PHP's xsl extension.
    

    安装 intl 扩展

    [root@ajiang-tuzi intl]# pwd
    /root/lnmp1.2-full/src/php-5.5.30/ext/intl
    [root@ajiang-tuzi intl]# phpize && ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
    

    嗯 运气不错 又来了个错误

    checking for location of ICU headers and libraries... not found
    configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install prefix and make sure icu-config works.
    //安装依赖库
    [root@ajiang-tuzi intl]# yum install libicu-devel -y
    

    安装 xsl 扩展 方法同上

    [root@ajiang-tuzi ext]# cd xsl
    [root@ajiang-tuzi xsl]# pwd
    /root/lnmp1.2-full/src/php-5.5.30/ext/xsl
    [root@ajiang-tuzi xsl]# yum install libxslt-devel -y
    [root@ajiang-tuzi xsl]# phpize && ./configure --with-php-config=/usr/local/php/bin/php-config 
    

    在 php.ini 中添加扩展

    vi /usr/local/phpnext/etc/php.ini
    // 请编辑 你自己的 php.ini 文件 
    //添加
    extension=xsl.so
    extension=intl.so
    //重启  
    /etc/init.d/php-fpm restart
    //检查  phpinfo 中是否有这扩展
    

    下面我们来开始正式安装 Magento 2
    回到 网站的目录
    执行

    root@ajiang-tuzi mage2]# composer install
    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
      - Installing magento/magento-composer-installer (0.1.5)
        Downloading: 100%         
    
      - Installing braintree/braintree_php (2.39.0)
        Downloading: 100%         
    
    
    //这个问题 请登录你的账户 获得开发key
    //或 检查下你的网络
    [ComposerDownloaderTransportException]                                                                              
      Invalid credentials for 'https://repo.magento.com/archives/magento/composer/magento-composer-1.0.2.0.zip', aborting.  
    
    

    输入你的 开发 key

     - Installing magento/composer (1.0.2)
        Authentication required (repo.magento.com):
           username: Public Key   
           password: Private Key
    

    这次 好运气继续 又来了个错误

    [SymfonyComponentProcessExceptionRuntimeException]                                   
      The Process class relies on proc_open, which is not available on your PHP installation
    

    解决方法
    进入php.ini文件,找到disable_function=,删除proc_open函数, 就行
    参考:
    Function proc_open is disabled. What to do?
    I see the “Warning: proc_open() has been disabled for security reasons” message on my site. What should I do? How can I fix this?
    Solution for the “proc_open disabled” issue
    In order to eliminate this error message you need to do ONE of the following things:
    Remove the proc_open string from the disable_functions at php.ini* file
    Ask your hosting provider to remove the string above if you don’t have an access to the php.ini* file
    Change hosting provider which allows the running of the proc_open function.

    //又 获得一个 错误 请自己检查php ini 配置文件  方法同上
     [ErrorException]                                          
      proc_get_status() has been disabled for security reasons
    

    最后一个 GIT

    Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+vultr.guest+2015-12-27+1723
    to retrieve a token. It will be stored in "/home/weicot/.composer/auth.json" for future use by Composer.
    Token (hidden):
    

    检查下安装

    [root@ajiang-tuzi mage2]# composer install
    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
    Nothing to install or update
    Generating autoload files
    

    composer 加载完成

    官网直接下载安装方法

    一个 简单的方法
    1.直接到官网下载 完整的压缩包到网站根目录
    2.解压到网站根目录
    3.用浏览器打开 你网站域名 在浏览器中安装
    4.如过 出现错 请按 Step 3:预安装 的方法排错
    设置权限
    cd 你的网站根目录
    官方的方法
    执行

    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
    

    当然 官方的方法 不一定管用 如过你有什么 文件 没有生成 或 丢失 你可以试试木瓜这个方法
    备注:他是用浏览器安装
    解压后在根目录下执行下面三个权限就OK了

    find . -type d -exec chmod 755 {} ; && find . -type f -exec chmod 644 {} ; 
    
                          
    find ./var -type d -exec chmod -R 777 {} ; && find ./pub/media -type d -exec chmod -R 777 {}  ; && find ./pub/static -type d -exec chmod -R 777 {} ; && find ./app/etc -type d -exec chmod -R 777 {} ;
    
    chmod 755 ./bin/magento
    

    备注:LINUX关于权限
    在linux终端先输入ll,可以看到如:
    -rwx-r–r– (一共10个参数) 表示文件所属组和用户的对应权限。
    第一个跟参数属于管理员,跟chmod无关,先不管.

    2-4参数:属于user
    5-7参数:属于group
    8-10参数:属于others
    

    接下来就简单了:
    r==>可读
    w==>可写
    x==>可执行
    r=4 w=2 x=1
    所以755代表 rwxr-xr-x

    777 代表 rwxr-rwx-rwx 所有用户都可读可写可执行。

    设置 max_execution_time

    //修改 php.ini
    max_execution_time=1800(根据您VPS的配置来,300-1800)
    

    到这步 你可以选择命令行安装 或者 使用浏览器安装
    添加 magento 命令行到 bin

    export PATH=$PATH:/home/wwwroot/weicot/Mage2/bin
    

    参考:
    magento2 命令行的使用 及用命令行开发以及刷索引等
    命令行安装 help

    [root@ajiang-tuzi bin]# magento help setup:config:set
    Usage:
     setup:config:set [--backend-frontname="..."] [--key="..."] [--session-save="..."] [--definition-format="..."] [--db-host="..."] [--db-name="..."] [--db-user="..."] [--db-engine="..."] [--db-password="..."] [--db-prefix="..."] [--db-model="..."] [--db-init-statements="..."] [-s|--skip-db-validation] [--http-cache-hosts="..."] [--magento-init-params="..."]
    
    Options:
     --backend-frontname       Backend frontname (will be autogenerated if missing)
     --key                     Encryption key
     --session-save            Session save handler (default: "files")
     --definition-format       Type of definitions used by Object Manager
     --db-host                 Database server host (default: "localhost")
     --db-name                 Database name (default: "magento2")
     --db-user                 Database server username (default: "root")
     --db-engine               Database server engine (default: "innodb")
     --db-password             Database server password (default: "")
     --db-prefix               Database table prefix (default: "")
     --db-model                Database type (default: "mysql4")
     --db-init-statements      Database  initial set of commands (default: "SET NAMES utf8;")
     --skip-db-validation (-s) If specified, then db connection validation will be skipped
     --http-cache-hosts        http Cache hosts
     --magento-init-params     Add to any command to customize Magento initialization parameters
                               For example: "MAGE_MODE=developer&MAGE_DIRS[base][path]=/var/www/example.com&MAGE_DIRS[cache][path]=/var/tmp/cache"
     --help (-h)               Display this help message
     --quiet (-q)              Do not output any message
     --verbose (-v|vv|vvv)     Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
     --version (-V)            Display this application version
     --ansi                    Force ANSI output
     --no-ansi                 Disable ANSI output
     --no-interaction (-n)     Do not ask any interactive question
    
    

    查看语言列表

    [root@ajiang-tuzi bin]# ./magento info:language:list
    +-------------------------------+------------+
    | Language                      | Code       |
    +-------------------------------+------------+
    | Afrikaans (South Africa)      | af_ZA      |
    | Albanian (Albania)            | sq_AL      |
    | Arabic (Algeria)              | ar_DZ      |
    | Arabic (Egypt)                | ar_EG      |
    | Arabic (Kuwait)               | ar_KW      |
    | Arabic (Morocco)              | ar_MA      |
    | Arabic (Saudi Arabia)         | ar_SA      |
    | Azerbaijani (Azerbaijan)      | az_Latn_AZ |
    | Basque (Spain)                | eu_ES      |
    | Belarusian (Belarus)          | be_BY      |
    | Bengali (Bangladesh)          | bn_BD      |
    | Bulgarian (Bulgaria)          | bg_BG      |
    | Catalan (Spain)               | ca_ES      |
    | Chinese (China)               | zh_Hans_CN |
    | Chinese (Hong Kong SAR China) | zh_Hant_HK |
    | Chinese (Taiwan)              | zh_Hant_TW |
    | Croatian (Croatia)            | hr_HR      |
    ............................
    

    安装命令示范

    magento setup:install --base-url=http://127.0.0.1/magento2/ 
    --db-host=localhost --db-name=magento --db-user=magento --db-password=magento 
    --admin-firstname=Magento --admin-lastname=User --admin-email=user@example.com 
    --admin-user=admin --admin-password=admin123 --language=en_US 
    --currency=USD --timezone=America/Chicago --use-rewrites=1
    

    我数据库版本有点低
    升级数据库

    Sorry, but we support MySQL version 5.6.0 or later.
    
    
                                   
      [InvalidArgumentException]   
      Parameter validation failed  
    
    

    你可以执行这个来升级你的数据库或php

    //LNMP 1.2升级Nginx、MySQL/MariaDB、PHP教程
    http://lnmp.org/faq/lnmp1-2-upgrade.html
    

    MySQL升级脚本
    虽然脚本会备份数据,但依然建议先自行备份!
    执行:./upgrade.sh mysql 需要先输入MySQL root密码进行验证,验证不通过将无法进行升级,验证通过后可以到

    http://dev.mysql.com/downloads/mysql/

    获取MySQL的版本号,输入后回车确认,如要启用Innodb,输入y,不确定的话也可以输入输入y 回车确认,再次回车确认即可开始升级。会在/root 目录下生成mysql_upgrade日期.log的日志文件,供出错时排查。
    升级失败
    如升级失败可将/usr/local/oldmysql日期的目录重命名为mysql,并将/etc/下的my.conf.bak.日期的配置文件重命名为my.cnf和/etc/init.d/下的mysql.bak.日期重命名为mysql即可恢复原mysql。(下面MySQL升级至MariaDB及升级MariaDB一样)
    升级数据库 5.5.X->5.6.16
    我使用这个版本 lnmp1.2-full 的更新数据库脚本时发现老是提示版本错误 于是更换了下源 成功下载

    http://dev.mysql.com/get/
    http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.16.tar.gz
    

    升级完 mysql 后记得效验下权限 以及配置 my.cnf

    chown -R mysql:mysql  文件名
    

    注意

    To disable InnoDB, use --innodb=OFF or --skip-innodb
    (新版mysql中已经被loose-skip-innodb取代)
    . In this case, 
    the server will not start if the default storage engine is set to InnoDB.
    这句话中用了 or 这个词
    

    一些其他错误

    Installing dependencies (including require-dev)
    Failed to decode response: zlib_decode(): data error
    Retrying with degraded mode, check https://getcomposer.org/doc/articles/troubleshooting.md#degraded-mode for more info
    

    然后 明天继续 如果本文有什么错误的话 或你有什么不懂的话 请在下面留言

    转载请注明:(●–●) Hello.My Weicot » GIT Centos 下安装 Magento 2

    文章来源于互联网:GIT Centos 下安装 Magento 2

    如无特殊说明或标注,任何个人或组织,复制、转载、采集本站内容请注明:
    本文来源于:【Magento中文网】,并添加本文地址链接。
    如未按上述操作复制或转载,本站有权追究法律责任。
    若本站内容侵犯了原著者的合法权益,可联系我们进行处理。