Magento本地迁移上线

Magento Alan 11年前 (2013-03-30) 4580次浏览 0个评论 扫描二维码

使用本地环境对Magento网站进行了相关配置(参见使用xampp安装Magento部分)并测试确认满足上线条件时,就需要将本地的数据库及文件迁移到所购买的空间上去,毕竟这才是我们开发网店的最终目的。

迁移步骤主要包含本地文件的迁移,数据库的迁移,相关文件的配置。

1.本地文件就是您所安装的文件夹(通常名称为Magento)内的所有内容,建议进行压缩后再上传,这样可以节约网络流量并缩短上传时间。当然如果采用压缩的方式上传在服务器端需进行解压缩处理。上传的位置为您所布署站点在空间中的根目录位置。

2.数据库的迁移直接去http://localhost/phpmyadmin找到对应的数据库,点击Export进行导出,不同的空间商支持不同格式文件的导入,通常使用的是.sql文件。导出后访问空间服务商提供或您自己设置的MySQL数据库管理后台点击Import进入导入。或者在ssh中用 mysql后,use 数据库名;source 所导入的数据库.sql。

3.修改LOCAL.XML(app\etc)文件中的数据库名称,用户名及密码。

4.将旧域名或IP更改为新域名,步骤如下:

修改magento数据库,core_config_data表中的path为web/unsecure/base_url和web/secure/base_url的内容,为你网站的新域名,注意域名后面的“/”。

在迁移中可能会遇到一些问题,常见问题如下:

1.如果phpmyadmin导入SQL的时候报错是因为magento的数据库使用了外键约束。

解决办法:

在导出的sql文件上加如下一行

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

2.访问magento提示Exception printing is disabled by default for security reasons.

Magento报错

解决方法

改变magento根目录下 /errors/local.xml.sample 为/errors/local.xml

改变magento根目录下/lib/Zend/Cache/Backend/File.php文件里面protected $_options = array( ‘cache_dir’ => NULL, ‘file_locking’ => true,为protected $_options = array( ‘cache_dir’ => ‘var/tmp/’, ‘file_locking’ => true

,然后在根目录下创建tmp文件夹.

3.出现SQLSTATE[HY000] [2002] Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)报错

解决办法:

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

4.发现应用的rewrite无效,可能是因为数据库中默认没用应用rewrite,进入数据库管理后台将core_config_data表中的path值为web/seo/use_rewrites和web/secure/use_in_frontend的Value值更为改1。

5.media目录下的所有图片无法正常显示。

解决办法:

修改MEDIA目录下的.HTACCESS文件的第一行,将其注释掉。

#Options All -Indexes

<IfModule mod_php5.c>

php_flag engine 0

</IfModule>

*或是将MEDIA目录下的.HTACCESS改名。(不推荐)

6.如果访问首页正常,但访问其它URL出现问题,可能是因为URL中带有/INDEX.PHP/而导致404访问失败

解决办法:

首先修改MAGENTO根目录下的.HTACCESS文件的REWRITE模块,保证以下两行在其中:

<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /

</IfModule>

然后,按如下方法让MAGENTO启用REWRITE功能:

go to “System >>  Configuration >>Web >> Search Engines Optimization”

Use Web Server Rewrites : YES

Go to “System >>  Configuration >>Web >>Secure”

Use secure URL Frontend: YES

或用是PHP MYADMIN修改如下数据值

<v:shape
id=”_x0000_i1026″ type=”#_x0000_t75″ alt=”sky3-15-2013 6-13-53 PM.png”
style=’width:347.25pt;height:4in’/><!–[if !vml]–><!–[endif]–>

7.如果想要修改的配置改变立即发生,最保险的办法是清除VAR/CACHE文件夹之后再CTRL+F5强制刷新浏览器页画。

8.将index.php跳转到根目录

## rewrite everything else to index.php

RewriteRule .* index.php [L]

在上面两行数据下加上
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.mydomain.com/$1 [R=301,L]
RewriteCond %{http_host} ^www.mydomain.com [NC]
RewriteRule ^(.*)$ http://www.mydomain.com/$1 [R=301,NC]
RewriteRule ^index.php/(.*) $1 [R=301,QSA,L]

9.无法成功登陆进入后台,修改根目录下的.htaccess,网上获取的示例文件如下:

RewriteEngine On

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f

RewriteRule ^.+.php$ /bogusfile

php5.ini

register_globals = off

allow_url_fopen = on
expose_php = Off

max_input_time = 60

variables_order = “EGPCS”

extension_dir = ./

upload_tmp_dir = /tmp

precision = 12

SMTP = relay-hosting.secureserver.net

url_rewriter.tags = “a=href,area=href,frame=src,input=src,form=,fieldset=”

;Only uncomment zend optimizer lines if your application requires Zend Optimizer support

;[Zend]

;zend_optimizer.optimization_level=15

;zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3

;zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3

;zend_extension=/usr/local/Zend/lib/Optimizer-3.3.3/ZendExtensionManager.so

;zend_extension_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3/ZendExtensionManager_TS.so

;– Be very careful to not to disable a function which might be needed!

;– Uncomment the following lines to increase the security of your PHP site.

;disable_functions = “highlight_file,ini_alter,ini_restore,openlog,passthru,

;phpinfo, exec, system, dl, fsockopen, set_time_limit,
;popen, proc_open, proc_nice,shell_exec,show_source,symlink”

;This file is for CGI/FastCGI installations.

;Try copying it to php5.ini, if it doesn’t work

;adjust memory limit

memory_limit = 64M

max_execution_time = 18000

;disable magic quotes for php request vars

magic_quotes_gpc = off

;disable automatic session start

;before autoload was initialized

flag session.auto_start = off

;enable resulting html compression

zlib.output_compression = on

;disable user agent verification to not break multiple image upload

suhosin.session.cryptua = off

;turn off compatibility with PHP4 when dealing with objects

zend.ze1_compatibility_mode = off

;PHP for some reason ignores this setting in system php.ini

;and disables mcrypt if this line is missing in local php.ini
extension=mcrypt.so

cgi.fix_pathinfo = 1

喜欢 (0)
[]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址