Two Copies of Magento Installation on Localhost - macos
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.
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.
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>
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/
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>
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
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.
I've restarted apache and mysql about a million times.
I should also note that if I got to http://localhost/~myuser/magento2.dev, I get a 403 notice.
What am I missing here?
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
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
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";
?>
Visit http://www.magento1.dev/info.php
Visit http://www.magento2.dev/info.php
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
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>
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.
Related
How to set up the Sites folder as a root for http://localhost macOS Big Sur
How can I set up the Apache to user my Sites folder as a default root for the http://localhost? I was using this tutorial to set up the localhost/~username but now I would like to use just localhost for that https://wpbeaches.com/install-apache-mysql-php-on-macos-11-big-sur-and-earlier-macos/ I've already changed the httpd-vhosts.conf <VirtualHost *:80> ServerAdmin webmaster#dummy-host2.example.com DocumentRoot "/Users/myusername/Sites/" ServerName dummy-host2.example.com ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common </VirtualHost> but still doesn't work.
something like this <VirtualHost 127.0.0.1:80> DocumentRoot "folder/subfolder" </VirtualHost>
Virtual Hosts with Laravel and Apache, cannot set ip to website name
I want to set the ip for my website to an alphabetized name (i.e. http://54.183.131.205 to http://www.rblog.com). Although I have configured my rblog.com.conf in /etc/apache2/sites-available, enabled it and reloaded my apache server, and then adding to my /etc/hosts file 54.183.131.205 www.rblog.com (a tab between the ip and website name), typing in www.rblog.com into my browser doesn't redirect me to my index.php file. However, note that when I type in the ip address in the browser it takes me to my index.php file (I believe this means my rblog.com.conf file is correct?). <VirtualHost *:80> ServerAdmin webmaster#rblog.com ServerName www.rblog.com ServerAlias www.rblog.com DocumentRoot /var/www/html/rblog/public <Directory /var/www/html/rblog/public> Options -Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted <FilesMatch \.php$> </FilesMatch> </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
<VirtualHost *:80> ServerAdmin webmaster#rblog.com ServerName rblog.com ServerAlias www.rblog.com DocumentRoot /var/www/html/rblog/public ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> We can use the a2ensite tool to enable each of our sites like this: sudo a2ensite example.com.conf sudo a2ensite test.com.conf When you are finished, you need to restart Apache to make these changes take effect: sudo service apache2 restart /etc/hosts file 54.183.131.205 rblog.com
How to configure apache2 vhosts for difference www director on mac 10.11
I want to configure vhost for difference from www as below configure but it not work it. <VirtualHost *:80> ServerAdmin com.dev DocumentRoot "Applications/AMPPS/www/com/public" ServerName com.dev ErrorLog "/private/var/log/apache2/com.dev-error_log" CustomLog "/private/var/log/apache2/com.dev-access_log" common </VirtualHost> This one I have try to another director but it still go to localhost only <VirtualHost *:80> ServerAdmin com.dev DocumentRoot "/usr/docs/web/com/public" ServerName com.dev ErrorLog "/private/var/log/apache2/com.dev-error_log" CustomLog "/private/var/log/apache2/com.dev-access_log" common </VirtualHost> Host 127.0.0.1 com.dev
403 Forbidden apache mac os
Help set up a virtual host. In the file /etc/apache2/httpd.conf I uncommented this line here: # Virtual hosts Include /private/etc/apache2/extra/httpd-vhosts.conf Next, the file is opened, and in the end ordered a new virtual host: <VirtualHost *:80> ServerName localhost DocumentRoot "/Library/WebServer/Documents/" </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster#localhost DocumentRoot "/Users/igor/sites/advanced" ServerName advanced ErrorLog "/private/var/log/apache2/lab.domain-error_log" CustomLog "/private/var/log/apache2/lab.domain-access_log" common <Directory "/Users/igor/sites/advanced/"> Options Indexes MultiViews AllowOverride All Allow from all Require all granted </Directory> </VirtualHost> Then added to the hosts 127.0.0.1 advanced. Restart Apache, but the browser displays a 403 error! What could it be?
Apache gives me 403 Access Forbidden when DocumentRoot points to two different drives
I am getting an 403 access forbidden when attempting to open a page under a vhost where the document root is sitting on a different drive than where apache is sitting. I installed using the apachefriends release. This is my httpd-vhosts.conf file: NameVirtualHost 127.0.0.1 <VirtualHost 127.0.0.1> ServerName foo.localhost DocumentRoot "C:/xampp/htdocs/foo/public" </VirtualHost> <VirtualHost 127.0.0.1> ServerName bar.localhost DocumentRoot "F:/bar/public" </VirtualHost> When opening bar.localhost in my browser, Apache is giving me 403 Access Forbidden. I tried setting lots of different access rights, even full rights to everyone, but nothing I tried helped. Edit: Thanks! For future reference, add 'Options indexes' within to show directory indexes.
You did not need Options Indexes FollowSymLinks MultiViews Includes ExecCGI AllowOverride All Order Allow,Deny Allow from all Require all granted the only thing what you need is... Require all granted ...inside the directory section. See Apache 2.4 upgrading side: http://httpd.apache.org/docs/2.4/upgrading.html
Somewhere, you need to tell Apache that people are allowed to see contents of this directory. <Directory "F:/bar/public"> Order Allow,Deny Allow from All # Any other directory-specific stuff </Directory> More info
For Apache 2.4.2: I was getting 403: Forbidden continuously when I was trying to access WAMP on my Windows 7 desktop from my iPhone on WiFi. On one blog, I found the solution - add Require all granted after Allow all in the <Directory> section. So this is how my <Directory> section looks like inside <VirtualHost> <Directory "C:/wamp/www"> Options Indexes FollowSymLinks MultiViews Includes ExecCGI AllowOverride All Order Allow,Deny Allow from all Require all granted </Directory>
I have fixed it with removing below code from C:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhosts.conf file <VirtualHost *:80> ServerAdmin webmaster#dummy-host.example.com DocumentRoot "c:/Apache24/docs/dummy-host.example.com" ServerName dummy-host.example.com ServerAlias www.dummy-host.example.com ErrorLog "logs/dummy-host.example.com-error.log" CustomLog "logs/dummy-host.example.com-access.log" common </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster#dummy-host2.example.com DocumentRoot "c:/Apache24/docs/dummy-host2.example.com" ServerName dummy-host2.example.com ErrorLog "logs/dummy-host2.example.com-error.log" CustomLog "logs/dummy-host2.example.com-access.log" common </VirtualHost> And added <VirtualHost *:80> ServerAdmin webmaster#localhost DocumentRoot "c:/wamp/www" ServerName localhost ErrorLog "logs/localhost-error.log" CustomLog "logs/localhost-access.log" common </VirtualHost> And it has worked like charm
Solved 403: Forbidden when visiting localhost. Using ports 80,443,3308 (the later to handle conflict with MySQL Server installation) Windows 10, XAMPP 7.4.1, Apache 2.4.x My web files are in a separate folder. httpd.conf - look for these lines and set it up where you have your files, mine is web folder. DocumentRoot "C:/web" <Directory "C:/web"> Changed these 2 lines. <VirtualHost *:80> ServerAdmin webmaster#localhost.com DocumentRoot "C:/web/project1" ServerName project1.localhost <Directory "C:/web/project1"> Order allow,deny allow from all </Directory> </VirtualHost> to this <VirtualHost *:80> ServerAdmin webmaster#localhost.com DocumentRoot "C:/web/project1" ServerName project1.localhost <Directory "C:/web/project1"> Require all granted </Directory> </VirtualHost> Add your details in your hosts file C:\Windows\System32\drivers\etc\hosts file 127.0.0.1 localhost 127.0.0.1 project1.localhost Stop start XAMPP, and click Apache admin (or localhost) and the wonderful XAMPP dashboard now displays! And visit your project at project1.localhost