多个 Magento 环境
我们有一个 Magento 商店设置,并且在版本控制下,我们希望设置一个使用相同代码但不同连接详细信息的暂存商店。例如,实时存储的实时详细信息和用于暂存的暂存数据库。
Magento 是否可以做到这一点,默认情况下似乎没有办法做到这一点?
We have a Magento store setup and under version control, we'd like to setup a staging store which uses the same code but different connection details. e.g. Live details for the live store and a staging database for staging.
Is this possible with Magento, there doesn't seem to be a way to do it by default?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
你可以这样做。
您需要关注etc文件夹中的local.xml并相应地设置数据库设置。
还要更改 core_config_data 表中的安全和非安全基本 url 字段值。
You can do this.
You need to focus on the local.xml in the etc folder and set the db settings accordingly.
Also change the secure and non secure base url field values in the core_config_data table.
不确定这是否可能。
您能否创建一个带有 IF 语句的 PHP 文件,然后该文件将回显环境的相关 XML。然后,您必须通过 .htaccess 将其作为 local.xml 进行访问。
完成此操作后,请确保外部世界无法访问它。
Not sure if this is possible.
Could you create a PHP file with an IF statement that would then echo out the relevant XML for an environment. You would then have to make this accessible as local.xml through .htaccess.
After this has been done ensure that it isn't available from the outside world.
使用 Magento 可以轻松复制商店以进行开发。
当您的代码处于版本控制中时,您只需执行以下步骤:
1) 创建备份数据库,将其导出为 SQL。
2) 对文件运行搜索和替换,将 yourwebsite.com 替换为 stage.yourwebsite.com
3)将新数据库导入MySQL。
4) 将文件从版本控制检出到临时站点文档根目录。
5)修改app/etc/local.xml - 将数据库设置更改为您的新数据库和用户名/密码。
6)清空 var/cache/ 和 var/session 文件夹(希望您从未将它们添加到版本控制系统中)。
工作完成了。 :-)
Duplicating the store for development is easy with Magento.
As you have your code in version control, you simply follow these steps:
1) Create a backup database, export it as SQL.
2) Run Search and replace on the file, replacing yourwebsite.com with stage.yourwebsite.com
3) import the new database into MySQL.
4) Checkout out files from version control to your staging site document root.
5) modify app/etc/local.xml - change the database settings to your new database and username / password.
6) empty var/cache/ and var/session folders (hopefully you never added them into your version control system).
Job done. :-)
请按照此处的说明进行操作
http://www.magentocommerce.com/wiki/groups/227/moving_magento_to_another_server
在您的计算机上设置 wamp 或 zend 服务器后,将您的生产环境移至本地计算机。
为此,您需要在登台计算机上运行某种本地服务器(不需要是服务器,也可以使用您的笔记本电脑)
进行登台设置:
登台站点后端的 baseurl 和 securebaseurl 设置,使用“localhost”并将临时环境托管在您自己的计算机上(您可以根据您的操作系统使用在您的计算机上运行的 zend 服务器或 wamp/lamp 来执行此操作,而不是将整个环境复制到您的临时计算机上)
Follow the instructions here
http://www.magentocommerce.com/wiki/groups/227/moving_magento_to_another_server
and move your production environment into a local machine, after setting up wamp or zend server on your machine.
to do that, you need to have some sort of local server running on your staging machine (doesnt need to be a server, may as well use your laptop)
for staging setup:
baseurl and securebaseurl settings in the back end of staging site, use "localhost" and keep the staging environment hosted on your own machine (you can do that using zend server or wamp/lamp running on your machine depending on your OS, than copy the whole thing over to your staging machine)
有很多方法,最简单且不需要额外扩展的方法之一是
->创建
并且不要版本控制 local.xml
并在每个环境中符号链接正确的文件,这样您可以在 svn 或 git 中保存所有连接信息,
There are many ways, one of the easiest that requires no additional extensions is
-> create
and do NOT version control local.xml
and symlink the right file at each environment this way you can keep all connection info in svn or git,
汤姆,
由于您正在使用版本控制,我建议您不要为登台和生产使用相同的文件。这通常是一个坏主意。理想情况下,您应该有不同的暂存和生产环境,两者都有自己的文件集和数据库。这样,您就不必担心现在遇到的障碍。
Tom,
Since you are using version control, I'd suggest you not have the same files for both staging and production. That's generally a bad idea. Ideally, you should have a different environment for staging and production, both having their own set of files, and their own database. This way, you don't have to worry about the hurdle you are experiencing now.
我不得不这样做很多次。我几乎使用此处列出的相同建议,但总结一下...
/app/etc/local.xml
在版本控制中,我保留这些文件,每个文件都有自己的数据库和缓存数据。这些是原始 local.xml 文件的修改副本:
- 应用程序/etc/生产.local.xml
- 应用程序/etc/staging.local.xml
- app/etc/my-dev.local.xml
安装时创建的local.xml 文件被删除。它被替换为每个环境中相应文件的软链接 local.xml:
管理不同数据库的注意事项:
然后我通常创建一个名为 /sql 的新根级目录,并在其中保存类似的脚本这些用于设置备用环境:
以MySQL管理员用户身份运行,仅设置数据库和用户。
创建数据库后,您可以转到原始安装并获取数据库的 mysqldump:
然后将其安装到您正在工作的任何环境:
然后您需要更改 core_config_data 中的主机名(可能还有其他一些参数) 。最基本的看起来像这样:
您需要检查 Magento 安装以查看路径列中带有 web/secure/base_url 和 web/unsecure/base_url 的条目的 config_id 是什么。这很简单,只需在数据库上执行这样的查询:
因此,为每个环境创建具有正确主机名的 *.setup.sql 文件,并在 mysql 中运行脚本,就像加载数据库一样:
祝你好运!
I have had to do this many times. I pretty much use the same suggestions listed here, but to summarize...
/app/etc/local.xml
In version control I keep these files, each with its own DB and caching data. These are modified copies of the original local.xml file:
- app/etc/production.local.xml
- app/etc/staging.local.xml
- app/etc/my-dev.local.xml
The local.xml file created by installation is deleted. It gets replaced with a softlink local.xml to the appropriate file in each environment:
Notes on managing different databases:
Then I usually create a new root-level directory called /sql and in there I keep scripts like these which are used to setup alternate environments:
createdb.sql gets run as a MySQL admin user and just sets up the database and the user.
Once you create the database you can go to your original installation and get a mysqldump of the the database:
then install it to whatever environment you are working in:
You then need to change the hostname (and possibly some other paramters as well) in core_config_data. The most basic looks like this:
You need to check your Magento installation to see what the config_id is for the entries with web/secure/base_url and web/unsecure/base_url in the path column. It's easy, jsut do a query like this on the database:
So create the *.setup.sql files with the correct hostnames for each environment and run the script in mysql just as you did to load the database:
Good luck!
Magento 暂存和生产
Magento staging and production
我专门为您编写了一份指南,解释使用 Magento 和 SVN 设置 staging/dev/live 环境的过程
http://www.sonassi.com/knowledge-base/staging-development-live-svn-with-magento/
I wrote a guide just for you to explain the process of setting up a staging/dev/live environment with Magento and SVN
http://www.sonassi.com/knowledge-base/staging-development-live-svn-with-magento/