Apache not loading right DocumentRoot - macos

Have got myself stuck and can't find where the problem is.
Here is what I have:
OS X El Capitan
$ apachectl -v
Server version: Apache/2.4.18 (Unix)
My /etc/hosts files:
127.0.0.1 first.loc
127.0.0.1 second.loc
/etc/apache2/extra/httpd-vhost.conf
<VirtualHost *:80>
DocumentRoot "/Users/me/projects/first"
ServerName first.loc
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/me/projects/second"
ServerName second.loc
</VirtualHost>
I have put 3 index.html files with their directories as the only text in them:
/Users/me/projects/index.html (1)
/Users/me/projects/first/index.html (2)
/Users/me/projects/second/index.html (3)
When I go to first.loc or second.loc it loads the projects/index.html.
When I go to first.loc/first it loads the second index.html, when I go to first.loc/second it loads the 3rd.
Why are the DocumentRoots not being processed correctly?
Solved and answered below: Web Sharing panel was stopping Apache being restarted fully so it wasn't actually reloading the config files. Turning that off and manually starting/stopping/restarting has resolved.

Ok it seems the problem has 'fixed' itself. The issue was not with Apache but with sudo apachectl restart not working properly.
I previously installed a Web Sharing panel to try out which was set to 'On'. With that set, it seems to stop all the apache processes from stopping so it never truly stops and restarts with the updated config files.
Have removed the silly panel and now starting and stopping manually and it's all working as it should!

Related

why does redirect http://...local to https://...local/dashboard/ automaticly at firefox

i just have install new "laravel 6" project and i edit env file to
APP_URL=http://instegram.local
and host file to
127.0.0.1 instegram.local
and httpd-vhosts.conf in xampp to
<VirtualHost *:80>
SSLEngine off
DocumentRoot "C:/xampp/htdocs/instegram/public"
ServerName instegram.local
</VirtualHost>
then i opened this on firefox
http://instegram.local
automatically it redirect me to
https://instegram.local/dashboard/
this problem on firefox only
*i restarted apache server
Step 1: First try opening project in other browser. If it still redirects then it's probably project or server configuration that causing the issue. If there are no redirects then move to next step.
Step 2: Try disabling extensions like HTTPS Everywhere and such. These services redirects to HTTPS automatically for better security but that's not desired during development.

Having trouble mapping Laravel public folder with a vhost on MAMP

I've got a Laravel project called "test" running on MAMP on my mac. I've uncommented the vhosts include line in httpd.conf and included this below in the vhosts file:
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/test/public"
ServerName testapp.dev
</VirtualHost>
When I go to "testapp.dev" in my browser it just says the old
testapp.dev’s server IP address could not be found.
DNS_PROBE_FINISHED_NXDOMAIN
I'm not sure if I've missed something or what. Thanks in advance for your help! :)
(This is a repost but more clear)
So I ditched MAMP and used valet. I had some problems with that just going to localhost which was some random background apache server which I stopped and then everything worked! :)
if you are using windows edit C:\windows\system32\drivers\etc\hosts and if you are using unix edit /etc/hosts file and add this row at the end of file:
127.0.0.1 testapp.dev

MAMP on OSX Yosemite - Virtual host name gives 404 error

I installed MAMP v3.2.1 on my new MacBook Pro running OSX Yosemite (10.10.3).
localhost is running as expected, I can browse http://localhost, no problem.
However, something is amiss with my named virtualhost - when i browse to the site I get a 404.
EDIT: I'm now seeing 'This webpage is not available - ERR_CONNECTION_TIMED_OUT' (in Chrome)
I've read and checked other threads on similar issues, but none of them has so far resolved my issue. I'm hoping somebody can help me, as I'm now totally stuck.
Here's what I've done and tried:
In /private/etc/hosts
127.0.0.1 mysitename.dev
::1 mysitename.dev
And in /Applications/MAMP/conf/Apache/httpd.config, uncommented to include the virtualhosts file in extra/httpd-vhosts.conf
And added the directive in the vhosts file like so:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot “/Users/myName/Sites/mysitename“
ServerName mysitename.dev
ServerAlias mysitename.dev
</VirtualHost>
I changed MAMP Apache settings to listen to port 80 (and checked httpd.config for the line Listen 80 (I think MAMP updates this?)
I've checked and double checked the paths to folders, checked for typos...even double checked that the index.html file exists.
When i look at the Apache log, I don't see anything untoward, although I probably wouldn't be able to tell if there was(!?)
I haven't explicitly 'turned off' the Mac's own Apache server, because I haven't turned it on (should I? But my localhost is working with MAMP, so...)
I'm a Mac-novice - you could say I'm having some teething problems! Any help or suggestions in the right direction would be much appreciated.
Thanks in advance.
P.S.
I just ping'd mysitename.dev and got
--- mysitename.dev ping statistics ---
132 packets transmitted, 132 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.039/0.096/0.294/0.042 ms
I got similar results from pinging localhost (no timeout messages), so I assume it's good, but I'm still lost...
I believe this is a quotation mark formatting issue. Look how quotation marks on your DocumentRoot are formatted differently from the DocumentRoot in the default example. To make sure the formatting is correct just copy the correct quotation mark character from the example DocumentRoot and paste it over the your DocumentRoot quotation marks. This issue can come up when text is copy-pasted from one place to another.
I was caught out by the formatting issue as stated above. The example I used was using “ around the document root instead of ".

XAMPP 1.7.4 on Windows 7 Defaults to Splash page

I set up XAMPP running apache and tried to set up the virtual host, but it wouldn't work, I keep getting routed to the XAMPP splash page. http://localhost/index.html says "It works!"
I uncommented the are where it said vhost_alias module, httpd-vhosts and rewrite_module.
I also added the following to my httpd-vhosts.conf & httpd.conf files:
<Directory "C:/Sites/test.dev-web">
Allow From All
AllowOverride FileInfo
Options +FollowSymLinks
</Directory>
<VirtualHost *:80>
ServerName "test.dev-web"
DocumentRoot "C:/Sites/test.dev-web"
</VirtualHost>
I also added this to my hosts file in my system32\drivers\etc:
127.0.0.1 test.dev
I also have 127.0.0.1 localhost in that file
However whenever I type in test.dev in chrome, it takes me to the xampp splash page (test.dev/xampp).
Running windows 7 and XAMPP 1.7.4
XAMPP says that apache is running on the control panel.
I shut off all programs that could be running port 80 (skype)
Any ideas on what's wrong?
Follow the step mentioned here -
http://foundationphp.com/tutorials/apache22_vhosts.php
Easy solution: Delete XAMPP's local test site (xampp/htdocs) and replace it with your own site.
The Correct solution: Set up proper virtual hosts. Set up multiple virtual hosts on windows
or the link that Vinay shared will give you a good guide.

Apache 2.2 localhost VirtualHosts problems

I am trying to setup my dev machine with virtual hosts so I can access my development projects with a simple url, like http:// project.dev/ rather that a whole http:// 127.0.0.1/dev/path/to/root/of/project/ type of url.
Now, I'm aware there are many tutorials and questions already answered about this, but after trying many of them, I feel like I'm running in circles here.
The problem is simple: after setting up my hosts file and my virtual hosts, any attempt to access a virtual hosts irremediably displays the content of my server DocumentRoot.
my hosts file:
127.0.0.1 localhost
127.0.0.1 mydomain.dev
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
my httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/pilot/Sites/
</Virtualhost>
<VirtualHost *:80>
ServerName mydomain.dev
DocumentRoot /Users/pilot/Sites/devel/vytamin/dev/
</VirtualHost>
I precise that the httpd-vhosts.conf file IS loaded in my httpd.conf and I do get a warning if I point the virtual host document root to a wrong folder.
I made a try setting the localhost virtual host to the following, without any success.
<VirtualHost *:80>
ServerName localhost
DocumentRoot /Users/pilot/Sites/devel
</Virtualhost>
The following URLS all display the DocumentRoot of my server defined in my httpd.conf file, and seem to ignore the DocumentRoot defined in my VirtualHosts.
http:// 127.0.0.1/
http:// localhost/
http:// mydomain.dev/
I'm running Apache2.2 on Mac OSX 10.5 Leopard, but not the one shipped with mac os. I compiled my own under /usr/local/apache2 and web sharing IS disabled
I can't see anything wrong with my set up so I hope the community will!
Thanks for your help!
Ok, I found the problem!
The configuration above is perfectly fine, it was just that my apache was not restarting properly.
Neither apache_ctl graceful or apache_ctl restart was terminating all httpd processes I have running, therefore failing to reload properly the changes in my configuration files.
Once I killed the remaining processes and really restarted apache, it worked...
Solved, but I feel dumb to have found that!
Now I have a daemon situation to solve!

Resources