2014-09-25 105 views
0

我的目標是在我的網站/文件夾中安裝兩個版本的Magento。一個是我們正在使用的當前版本(1.12),另一個是升級版本(1.14)。爲什麼我需要這樣做有幾個原因。在本地主機上安裝Magento的兩份副本

另一位開發人員升級了Magento併發送了站點文件,我將其放在Sites/magento2.dev中,並且我還在Sites/magento1.dev中有原始版本。

我創建了一個單獨的數據庫,從升級版進口轉儲,並把這個在local.xml文件,爲magento2:

<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 [email protected] 
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 [email protected] 
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 [email protected] 
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 [email protected] 
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 [email protected] 
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 [email protected] 
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> 

我更新了我/私營/ 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通知。

我在這裏錯過了什麼?

回答

0

首先,將httpd.conf中的ServerName與您在本地hosts文件中添加的對應域匹配。當您訪問瀏覽器中的任何網址時,請嘗試實時查看日誌。

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

您也可以尾部一下子日誌文件,看哪個虛擬主機在瀏覽器中訪問任何本地主機的主機文件的域時得到一個打擊。

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

而且,測試,如果虛擬主機的被創造的Magento根簡單的PHP文件,並與您的瀏覽器訪問它的工作。例如,創建/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

檢查本地hosts文件(蘋果機)

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> 

如果你有工作的虛擬主機的,然後檢查的index.php的Magento的每個副本內& .htaccess文件的任何硬編碼的域名,店鋪代碼出現。

+0

非常好!知道如何像這樣監視日誌文件是非常有用的。原來它是httpd.conf文件;一旦我將''更改爲'',併爲每個條目添加了'www'前綴到'ServerName',它就起作用了。謝謝。 – 2014-09-26 14:06:46

+0

尾巴-f真棒。很高興工作! – LAMAGENTO 2014-09-26 16:17:27

相關問題