Localhost上Magento安装的两个副本

时间:2014-09-25 21:35:26

标签: macos magento localhost

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

另一位开发人员升级了Magento并发送了我放在Sites / magento2.dev中的站点文件,我还在Sites / magento1.dev中提供了原始文件。

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

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

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

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

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

# 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文件:

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)的版本略有不同(字体已损坏) ),但使用新的URL。登录到后端,我可以看到它是1.12,并且URL更改为旧版本。基本上,我似乎只为旧版本的主商店网站制作了三个新的本地域名。

我已经重启了apache和mysql大约一百万次。

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

我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

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

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

您还可以一次性查看所有日志文件,以便在访问浏览器中的任何localhost主机文件域时查看哪个vhost受到攻击。

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

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

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

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

验证本地主机文件(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环境。)

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>

如果您正在使用vhost,请检查index.php&amp; Magento每个副本中的.htaccess文件,用于任何硬编码域或商店代码出现。