Magento安装在Localhost上的两份副本 [英] Two Copies of Magento Installation on Localhost

查看:64
本文介绍了Magento安装在Localhost上的两份副本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是在我的站点/文件夹中安装两个版本的Magento.一个是我们正在使用的当前版本(1.12),另一个是升级版本(1.14).我需要这样做的原因有几个.

My goal is two have two versions of Magento installed in my Sites/ folder. One is the current version we are using (1.12), and the other is the upgraded version (1.14). There are several reasons why I need to do this.

另一位开发人员升级了Magento并发送了站点文件,这些文件已放置在Sites/magento2.dev中,并且在Sites/magento1.dev中也有可用的原始文件.

Another developer upgraded Magento and sent over the site files, which I put in Sites/magento2.dev, and I also have the working original in Sites/magento1.dev.

我创建了一个单独的数据库,从升级版本中导入了转储,并将其放在magento2的local.xml文件中:

I created a separate database, imported the dump from the upgraded version, and put this in the local.xml file for magento2:

<host><![CDATA[localhost]]></host>
<username><![CDATA[root]]></username>
<password><![CDATA[mypassword]]></password>
<dbname><![CDATA[mydatabase]]></dbname>
<active>1</active>

然后,我进入数据库并更改了我们三个网站的core_config_data基本URL,以模仿我在旧版本上设置的内容:

Then I went into the database and changed the core_config_data base urls for our three websites to mimic what I had set on the older version:

http://www.magento2.dev/
http://www.magento2-b.dev/
http://www.magento2-c.dev/

我更新了/etc/apache2/extra/httpd-vhosts.conf文件:

I updated my /etc/apache2/extra/httpd-vhosts.conf file:

# Virtual Hosts
# Note: You also need to edit the hosts file /private/etc/hosts
NameVirtualHost *:80
#magento1.dev / Magento 1.12
<VirtualHost *:80>
ServerAdmin myuser@mywebsite.com
DocumentRoot "/Users/myuser/Sites/magento1.dev"
<Directory "/Users/myuser/Sites/magento1.dev">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ServerName magento1.dev
ErrorLog "/private/var/log/apache2/magento1.dev-error_log"
CustomLog "/private/var/log/apache2/magento1.dev-access_log" common
</VirtualHost>

#magento-b.dev / Magento 1.12
<VirtualHost *:80>
ServerAdmin myuser@mywebsite.com
DocumentRoot "/Users/myuser/Sites/magento1.dev"
ServerName magento1-b.dev
ErrorLog "/private/var/log/apache2/magento1-b.dev-error_log"
CustomLog "/private/var/log/apache2/magento1-b.dev-access_log" common
</VirtualHost>

#magento-c.dev / Magento 1.12
<VirtualHost *:80>
ServerAdmin myuser@mywebsite.com
DocumentRoot "/Users/myuser/Sites/magento1.dev"
ServerName magento1-c.dev
ErrorLog "/private/var/log/apache2/magento1-c.dev-error_log"
CustomLog "/private/var/log/apache2/magento1-c.dev-access_log" common
</VirtualHost>

#magento2.dev / Magento 1.14
<VirtualHost *:80>
ServerAdmin myuser@mywebsite.com
DocumentRoot "/Users/myuser/Sites/magento2.dev"
ServerName magento2.dev
ErrorLog "/private/var/log/apache2/magento2.dev-error_log"
CustomLog "/private/var/log/apache2/magento2.dev-access_log" common
</VirtualHost>

#magento2-b.dev / Magento 1.14
<VirtualHost *:80>
ServerAdmin myuser@mywebsite.com
DocumentRoot "/Users/myuser/Sites/magento2.dev"
ServerName magento2-b.dev
ErrorLog "/private/var/log/apache2/magento2-b.dev-error_log"
CustomLog "/private/var/log/apache2/magento2-b.dev-access_log" common
</VirtualHost>

#magento2-c.dev / Magento 1.14
<VirtualHost *:80>
ServerAdmin myuser@mywebsite.com
DocumentRoot "/Users/myuser/Sites/magento2.dev"
ServerName magento2-c.dev
ErrorLog "/private/var/log/apache2/magento2-c.dev-error_log"
CustomLog "/private/var/log/apache2/magento2-c.dev-access_log" common
</VirtualHost>  

我更新了/private/etc/hosts文件:

I updated my /private/etc/hosts file:

127.0.0.1       localhost
127.0.0.1       www.magento1.dev
127.0.0.1       www.magento1-b.dev
127.0.0.1       www.magento1-c.dev
127.0.0.1       www.magento2.dev
127.0.0.1       www.magento2-b.dev
127.0.0.1       www.magento2-c.dev

我尝试了其他几次迭代(添加斜杠,http,www等),总是得到相同的结果.当我访问www.magento2.dev,www.magento2-b.dev或www.magento2-c.dev时,我得到的站点的旧版本(www.magento1.dev)的版本稍有不同(字体已损坏). ),但带有新的网址.登录到后端,我可以看到它是1.12,并且URL更改为旧版本.基本上,我似乎为主要商店网站的旧版本创建了三个新的本地域.

I have tried a few other iterations of this (adding trailing slashes, http, www, etc), always with the same result. When I go to www.magento2.dev, www.magento2-b.dev, or www.magento2-c.dev, I get a slightly different version (fonts broken) of my old version of the site (www.magento1.dev), but with the new URL. Logging into the backend, I can see that it is 1.12, and the URL changes to the older version. Basically it seems like I just made three new local domains for the old version of the primary store website.

我已经重新启动了apache和mysql大约一百万次.

I've restarted apache and mysql about a million times.

我还应该注意,如果我到达http://localhost/~myuser/magento2.dev,则会收到403通知.

I should also note that if I got to http://localhost/~myuser/magento2.dev, I get a 403 notice.

我在这里想念什么?

推荐答案

首先,将httpd.conf中的ServerName 与您在本地主机文件中添加的相应域相匹配.当您在浏览器中访问任何网址时,也请尝试实时查看日志.

First, match the ServerName in your httpd.conf with the corresponding domains you added in your local hosts file. Also try viewing the logs i realtime when you visit any of the urls in your browser.

$ cd /private/var/log/apache2/
$ tail -f magento1-b.dev-error_log

您还可以一次拖尾所有日志文件,以查看在浏览器中访问任何localhost主机文件域时哪个虚拟主机受到了攻击.

You can also tail all the log files at once to see which vhost gets a hit when visiting any of the localhost host file domains in your browser.

$ cd /private/var/log/apache2/
$ tail -f *.log

此外,通过在Magento根目录中创建一个简单的.php文件并使用浏览器访问它,来测试虚拟主机是否正常工作.例如,使用以下内容创建/Users/myuser/Sites/magento1.dev/info.php:

Also, test if the vhost's are working by creating a simple .php file in Magento root and visit it with your browser. For example, create /Users/myuser/Sites/magento1.dev/info.php with the following content:

<?php
echo gethostname() . "\n";
echo getcwd() . "\n";
?>

访问 http://www.magento1.dev/info.php 访问 http://www.magento2.dev/info.php

验证本地主机文件(Mac)

Verify local hosts file (Mac)

127.0.0.1       www.magento1.dev
127.0.0.1       www.magento1-b.dev
127.0.0.1       www.magento1-c.dev
127.0.0.1       www.magento2.dev
127.0.0.1       www.magento2-b.dev
127.0.0.1       www.magento2-c.dev

否则,请使用它作为最小的httpd.conf(具有匹配的ServerName.当前可在我的本地MAMP环境中使用.)

Otherwise, use this as a minimum httpd.conf (with matching ServerName. This currently works in my local MAMP environment.)

NameVirtualHost *

<VirtualHost *>
DocumentRoot "/Users/myuser/Sites/magento1.dev"
ServerName www.magento1.dev
ErrorLog "/Users/myuser/Sites/magento1.dev-error_log"
CustomLog "/Users/myuser/Sites/magento1.dev-access_log" common
</VirtualHost>

<VirtualHost *>
DocumentRoot "/Users/myuser/Sites/magento1.dev"
ServerName www.magento1-b.dev
ErrorLog "/Users/myuser/Sites/magento1-b.dev-error_log"
CustomLog "/Users/myuser/Sites/magento1-b.dev-access_log" common
</VirtualHost>

<VirtualHost *>
DocumentRoot "/Users/myuser/Sites/magento1.dev"
ServerName www.magento1-c.dev
ErrorLog "/Users/myuser/Sites/magento1-c.dev-error_log"
CustomLog "/Users/myuser/Sites/magento1-c.dev-access_log" common
</VirtualHost>


<VirtualHost *>
DocumentRoot "/Users/myuser/Sites/magento2.dev"
ServerName www.magento2.dev
ErrorLog "/Users/myuser/Sites/magento2.dev-error_log"
CustomLog "/Users/myuser/Sites/magento2.dev-access_log" common
</VirtualHost>

<VirtualHost *>
DocumentRoot "/Users/myuser/Sites/magento2.dev"
ServerName www.magento2-b.dev
ErrorLog "/Users/myuser/Sites/magento2-b.dev-error_log"
CustomLog "/Users/myuser/Sites/magento2-b.dev-access_log" common
</VirtualHost>

<VirtualHost *>
DocumentRoot "/Users/myuser/Sites/magento2.dev"
ServerName www.magento2-c.dev
ErrorLog "/Users/myuser/Sites/magento2-c.dev-error_log"
CustomLog "/Users/myuser/Sites/magento2-c.dev-access_log" common
</VirtualHost>

如果您有可用的虚拟主机,请检查index.php& Magento的每个副本中的.htaccess文件都适用于任何硬编码域或存储代码.

If you have working vhost's, then check the index.php & .htaccess files within each copy of Magento for any hard-coded domain or store code occurrences.

这篇关于Magento安装在Localhost上的两份副本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆