zoukankan      html  css  js  c++  java
  • magento换域名和服务器要怎么操作

      今天客户让ytkah帮忙把magento迁移到新服务器并换新域名,很多朋友可能在迁移过程中遇到了很多问题,下面就整理一下亲测可用的步骤吧。本文以magento 1.9.2.4为例,环境是lnmp,centos7.8,php版本为5.6,mysql为8.0.20,NGINX为1.17.10

      1、打包压缩原网站的文件和数据库

      2、在新服务器上创建站点,并添加NGINX规则

    location / {
            index index.html index.php; ## Allow a static html file to be shown first
            try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
    
    
            allow all;
        }
    
        ## These locations would be hidden by .htaccess normally
        location ^~ /app/                { deny all; }
        location ^~ /includes/           { deny all; }
        location ^~ /lib/                { deny all; }
        location ^~ /media/downloadable/ { deny all; }
        location ^~ /pkginfo/            { deny all; }
        location ^~ /tmp/                { deny all; }
        location ^~ /report/config.xml   { deny all; }
        location ^~ /var/                { deny all; }
        location ^~ /var/rw_google_base/                { allow all; }
        location ^~ /media/catalog/product/ { allow 116.6.89.107;}
        location ^~ /media/catalog/product/cache/ {allow all;}
    
        location /var/export/ { ## Allow admins only to view export folder
            auth_basic           "Restricted"; ## Message shown in login window
            auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
            autoindex            on;
        }
    
        location  /. { ## Disable .htaccess and other hidden files
            return 404;
        }
    
        location @handler { ## Magento uses a common front handler
            rewrite / /index.php;
        }
    
        location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
            rewrite ^(.*.php)/ $1 last;
        }
    
        rewrite ^/minify/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
        rewrite ^/skin/m/([0-9]+)(/.*.(js|css))$ /lib/minify/m.php?f=$2&d=$1 last;
    
        location /lib/minify/ {
            allow all;
        }
        location ~ .php$ { ## Execute PHP scripts
            if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
    
            expires        off; ## Do not cache dynamic content
            fastcgi_pass   unix:/tmp/php-cgi.sock;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
            fastcgi_param  MAGE_RUN_TYPE store;
            include        fastcgi_params; ## See /etc/nginx/fastcgi_params
        }
    

      

      3、上传网站文件到新服务器,并解压,将/var/session/,/var/cache/,/var/tmp/三个文件夹里面的文件都清除,并赋予他们可写权限,否则magento迁移服务器时提示Mage registry key "_resource_helper/core" already exists

      4、修改magento的配置文件,位置在app/etc/local.xml,注意修改CDATA里面的内容 主要是数据库连接数据库用户名 密码 数据库名称

    <host><![CDATA[localhost]]></host>
    <username><![CDATA[ytkah]]></username>
    <password><![CDATA[ytkah-pwd]]></password>
    <dbname><![CDATA[ytkah-db]]></dbname>
    <initStatements><![CDATA[SET NAMES utf8]]></initStatements>
    <model><![CDATA[mysql4]]></model>
    

      5、导入数据库,建议用命令导入( phpmyadmin导入经常提示错误或者无法导入,因为magento的数据库使用了外键约束,通过phpmyadmin导入的时候会报错,在导出的sql文件上加一行

    SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS,FOREIGN_KEY_CHECKS=0; )

      5.1进入数据库,

    mysql -u ytkah -p
    

      输入密码

      5.2显示所有数据库

     show databases;
    

      5.3选择数据库

    use ytkah数据库名;
    

      显示数据表

    show tables;
    

      5.4导入数据库

    source /home/ytkah.sql;
    

      6、修改域名

    update core_config_data set value='https://www.cnblogs.com/ytkah/' where path like '%secure/base_url';
    

    修改magento数据库,core_config_data表中的path为web/unsecure/base_url和web/secure/base_url的内容,为你网站的新域名,注意域名后面的“/”。更换网站完整域名+/ http://www.abc.com/

      7、记得退出数据库

    exit (回车)
    

      

      访问站点试试,再访问后台清理一下缓存,最后测试相关功能是不是正常

      到此,magento迁移服务器算正式完成了

  • 相关阅读:
    Java 写GBK 、utf8格式的文件 java
    NIOnio的美文分享一下,最近喜欢上了Nio希望能给大家扫扫盲
    maven入门和进阶 基础入门 希望帮助大家maven 教程
    log4j 基础
    FastDFS架构剖析(非常值得一看的架构分析和解读)
    FastDFS分布式文件系统问题总汇
    oracle 建表创建外键
    Mybatis下log4j日志输出不正常的解决办法 ,很实用哦 !!!!
    httpclient入门例子 demos
    Firebug http请求响应时间线
  • 原文地址:https://www.cnblogs.com/ytkah/p/13602795.html
Copyright © 2011-2022 走看看