Windows 10, MAMP virtual host setup doesn't work - apache

I've went through all the posts I could find here, still couldn't get this to work:
I Have a Windows 10 + MAMP.
MAMP is set to folder C:/MAMP/htdocs as the root folder
I un-commented the Virtual host line on the httpd.conf:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Added :
<VirtualHost *:80>
DocumentRoot "C:/MAMP/htdocs/team/example"
ServerName dev.example.com
ServerAlias dev.examplecom
</VirtualHost>
into httpds-vhosts.conf to the extra folder (under conf)
added the following to my hosts file:
127.0.0.1 dev.example.com
I Can get to localhost,
But every time I try a domain, it gices me: Not Found (The requested URL / was not found on this server.)
I'm pretty sure I am missing something small, But will greatly appreciate a solution to this.
So far i tried changing the Path in the conf files.
Tried using relative paths rather than absolute.
Tried any idea I could find onlie,
Thanks, and a happy new year :)
Cheers.

Changing the line from Include conf/extra/httpd-vhosts.conf to Include C:/MAMP/conf/extra/httpd-vhosts.conf worked for me.
It seems that httpd.conf requires absolute paths

I didn't see you mention anything about SymLink, maybe that's what you're missing to make it work.
Find this line in that same C:\MAMP\conf\apache\httpd.conf file.
<Directory />
Options FollowSymLinks ExecCGI
AllowOverride none
Order deny,allow
Allow from all
</Directory>
Change AllowOverride from none to all
<Directory />
Options FollowSymLinks ExecCGI
AllowOverride all
Order deny,allow
Allow from all
</Directory>
Although I'm late to the party, hope that helps.
Also make sure to restart the servers on MAMP after making any changes! If you don't reset the server to apply the changes, nothing will work even though you know you've done everything right.

Not sure if this question is still relevant but I was having the exact same problem setting up my Virtual Host recently and I was receiving the: Not Found (The requested URL / was not found on this server.). The solution for me was to write it as the following:
<VirtualHost *:80>
DocumentRoot C:/MAMP/htdocs/team/example
ServerName dev.example.com
ServerAlias dev.examplecom
</VirtualHost>
Without the quotations around the DocumentRoot. Seems both simple and dumb but it worked for me. Make sure to restart the Mamp Servers again!

I don't have enough points to comment on James's answer, but this is another quirk of the Windows environment:
In the hosts file, Windows wants two lines for each virtual host:
127.0.0.1 dev.example.com
::1 dev.example.com

Related

Local website not working

I'm having a lot of trouble setting up a local website that I need to do some work on.
I have 2 local sites: "first_training" and "resus_skills"
The former, first_training, works. I have it set up that first_training.loc/ takes me to the local site. resus_skills is set up in the exact same way, but when I try to access resus_skills.loc/ all I get is:
Here are the details of my setup, as well as some screenshots of it:
/etc/apache2/sites-available/resus_skills.conf :
<VirtualHost *:80>
ServerName resus_skills.loc
ServerAlias www.resus_skills.loc
DocumentRoot "/var/www/resus_skills"
<Directory "/var/www/resus_skills">
Options Indexes FollowSymLinks MultiViews
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I made sure to enable it with sudo a2ensite resus_skills.conf and have confirmed that it's symlink is present in ``/etc/apache2/sites-enabled`
I've made sure my apache server is running:
and I've run apachectl -S to get this result:
I am able to reach first_training.loc/ with no issues, but cannot reach resus_skills.loc/.
I'm unsure how to troubleshoot this - the apache error.log isn't showing me anything.
Before anyone points out what an idiot I've been - I never updated the /etc/hosts file, which was the only missing step.

Apache - Hyphen in ServerName breaks VirtualHost

I can't get Apache's configuration to return the correct page, if there is a hyphen in the ServerName. I found a page here titled, "Dashes not allowed in virtual host entry?", but it was dealing with hyphens in the DocumentRoot, not with ServerName. In any case, it did not solve my problem, and I've been unable to find any other references to this problem.
I'm setting up multiple virtual hosts (VH) on a recently acquired Ubuntu 12.04 server, running Apache. Ubuntu's configuration for this is organized so that you have folders for sites-available and sites-enabled. A separate file, placed in sites-availabe is used for each individual VH. Enabling the VH is just a matter of making a symlink from the file in the sites-available folder to the sites-enabled folder, and restarting Apache.
I have several working VHs already. It's an easy recipe, since it's just a matter of copying a working file to a new filename, and changing a few variables.
All of my correctly-working entries do NOT have any hyphen in the ServerName, or ServerAlias. The one entry which does have a hyphen, does not work. Instead of returning the proper page, Apache returns the host's base page (which tells me DNS is fine).
I've tried enclosing ServerName and ServerAlias in quotes, with and without. No change.
Lots of domains use hyphens, I can't be the only one with this problem. Has anyone found a workaround? Here's my config:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName datacore-inc.com
ServerAlias www.datacore-inc.com
DocumentRoot /home/web/datacore/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/web/datacore/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
I had the same issue and thought the problem came from the hyphen character in the ServerName. But actually I had declared the VirtualHost twice. I've removed one of them and that resolved the problem.

Accessing virtual host from computer on same local network

I am trying to make a setup so that I can access my website on a virtual host in computer A from computer B. Both A and B are on the same network.
I am using xampp on Win 7.
So here is as the problem goes computer A(server) has a virtual host configuration as follows in the httpd-vhosts.conf file.
NameVirtualHost project:81
<VirtualHost project:81>
DocumentRoot "D:/work/website"
ServerName project:81
<Directory "D:/work/website">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
(using port 81 as port 80 has IIS running, dont know much about these things however)
this configuration works fine on the local machine(server). i.e project:81 in the address bar of the browser opens up the website as it should.
Now on computer B(client) I changed the hosts file to contain the IP of the server along with the name of the virtual host like:-
192.168.1.7 project
now when I enter project:81 on the client browser .. it takes me to the server but its not taking me to the virtual host directory, instead it takes to the default directory .. i.e in my case is
C:\xampp\htdocs
Now I am stuck and unable to make the client to point to the current destination.
So can anybody suggest what I am doing wrong here or something else I need to do in order to have access to the correct virtual host site from the client machine.
Thanks in advance for any help
Ok So Seto El Kahfi's reply to my very old question led me to do some more research and reading on Apache's website.
So what I got is this, my NameVirtualHost directive was improper.
So Instead of this,
NameVirtualHost project:81
<VirtualHost project:81>
DocumentRoot "D:/work/website"
ServerName project:81
<Directory "D:/work/website">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
What I had to do was this.
NameVirtualHost *:81
<VirtualHost *:81>
DocumentRoot "D:/work/website"
ServerName project
<Directory "D:/work/website">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Notice the ' * ' , I could have used an IP Address there too.(In this case my server's(machine A) local IP) both work. Now all I had to do is enter "project:81" on the client machine, and I get what my eyes wished to see.. :)
Few things I got from this.
1) How to use NameVirtualHost(or what it's purpose basically is.). Read More here
http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost
This one is also good http://www.thegeekstuff.com/2011/07/apache-virtual-host/
2)You can use this via command line:
httpd -D DUMP_VHOSTS
to know how your virtual hosts are setup(will also give you some warnings regarding precedence if something's wrong with your setup)
3)Other's gesture to help you makes you help yourself.. :) So keeping helping and rocking.
Have you try to include the port at your client host's file?
192.168.1.7:81 project

Only activate web sharing that I can use virtualhost with apache on Mac OS

I have configure httpd.conf and httpd-vhosts.conf, when I active the web sharing the virtualhost is useful, but when I close web sharing and start apache, the virtualhost doesn't work
Here is my virtualhost config
<VirtualHost *:80>
DocumentRoot "/Users/lch/Sites"
ServerName myhome.com
</VirtualHost>
<Directory "/User/lch/Sites">
Options None
Allow from all
</Directory>
And, here is error short-cut:
I am a newer for Mac OS, and I come from china.
Thank you for read my question.
Two things to check:
Is the include for httpd-vhosts.conf uncommented in httpd.conf? I believe it's commented out by default.
Have you added myhome.com to your hosts file? Make sure you've got the following entry in /etc/hosts: 127.0.0.1 myhome.com

Magento not accessible since tried to move to multi website setup. Apache issue?

I wish I had never seen this article:
http://www.magentocommerce.com/knowledge-base/entry/tutorial-multi-site-multi-domain-setup
I have Apache 2.2 installed on my XP machine and until a while ago I had a Magento site that I could test the development of a custom module on. I decided that I wanted to have multiple websites and multiple stores so that I could test that my modules configuration variables set at the different scopes (global, website, and store) were working as expected.
So I followed the instructions in the above Magento article. I created a website and gave it a name of “paulsplace.com”. I created a couple of Stores under that website. I then went to System/Configuration/General/Web and, with the scope set to paulsplace.com, I set the unsecured and secured URLs to http://paulsplace.com/ and https://paulsplace.com/ and hit Save Config - what a mistake!!
I got a 404 error. And now I can’t get to my magento front end or back end.
I tried a couple of things:
I added these lines to my hosts lookup file:
127.0.0.1 paulsplace.com
127.0.0.1 www.paulsplace.com
I then uncommented this line in my httpd,conf file:
Include conf/extra/httpd-hosts.conf
and added the following to the conf/extra/httpd-hosts.conf file:
<VirtualHost *:80>
ServerAdmin me#myemail.com
DocumentRoot "C:/Applications/Apache Software Foundation/Apache2.2/htdocs"
ServerName paulsplace.com
ErrorLog "logs/paulsplace.com-error.log"
CustomLog "logs/paulsplace.com-access.log" common
</VirtualHost>
and restarted Apache.
If I browse to “http://www.paulsplace.com” I now get a page that just says “It works!”. Same for “http://paulsplace.com” and “http://www.paulsplace.com/magento/index.php”.
I tried a few more things - I added this line to httpd.conf:
AccessFileName htaccess
(I did this because Windows Explorer didn’t let me create a file starting with a dot; I could do it from the command prompt, but I believe what I have done should be ok).
I changed AllowOverride to All from None:
<Directory />
Options FollowSymLinks
AllowOverride All
Order deny,allow
Deny from all
</Directory>
<Directory "C:/Applications/Apache Software Foundation/Apache2.2/htdocs">
AllowOverride All
</Directory>
and in C:\Applications\Apache Software Foundation\Apache2.2\htdocs\htaccess (a file that I created), I entered:
SetEnvIf Host www\.paulsplace\.com MAGE_RUN_CODE=pws1
SetEnvIf Host www\.paulsplace\.com MAGE_RUN_TYPE=website
SetEnvIf Host ^paulsplace\.com MAGE_RUN_CODE=pws1
SetEnvIf Host ^paulsplace\.com MAGE_RUN_TYPE=website
(pws was the value I used for the “Code” when creating my store).
Please tell me how I can put this right. I feel like I’m taking one step forward and three backward at the moment.
Any help really would be greatly appreciated.
<VirtualHost *:80>
ServerAdmin me#myemail.com
DocumentRoot "Change this to point at your magento install"
ServerName paulsplace.com
ErrorLog "logs/paulsplace.com-error.log"
CustomLog "logs/paulsplace.com-access.log" common
SetEnv MAGE_RUN_TYPE website
SetEnv MAGE_RUN_CODE pws1
</VirtualHost>
If changing anything in System Configuration borks your system, you can always clear out the bad values in the database directly, and clear your Magento cache. Do a
select * from core_config_data where value LIKE '%paulsplace.com%'
This will give you the two rows that were added when you clicked save. Remove the rows. Next, clear out all the files in
var/cache/*
to clear your cache. Then restore your Apache config to what it was before you started monkeying around. This should restore your site back to its previous state, and you can continue to experiment with things.