Mac Osx Yosemite localhost document path errors - macos

Working in Yosemite's localhost for a few months now. Previously I went through a simple configuration tutorial where the URL would be localhost/~username/project/public. Never really bothered me since I was just messing around with some simple sites. I recently ran into a problem with Laravel and Angular and its been suggested that my URL having the public in it was causing my routes to fail.
So I edited /etc/apache2/extra/httpd-vhosts.conf with
<VirtualHost *:80>
DocumentRoot "/Users/jeffcairoli/Sites/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/jeffcairoli/Sites/time-tracker-2/public"
ServerName time-tracker-2.local
<directory "/Users/jeffcairoli/Sites/time-tracker-2/public/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</directory>
</VirtualHost>
In /etc/hosts I added:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 time-tracker-2.local
In /etc/apache2/http.conf I uncommented the virtual hosts and vhost loadmodule.
When I visit time-tracker-2.com I am directed right to apache's It works! page.
I cannot figure out what I need to change to actually get it to point into my projects public folder so my laravel routes will take over. If anyone has any pointers or a better way to get my urls working please let me know. This issue is starting to drive me nuts.
**Update After making the changes to the vhosts and hosts files that I added here, I now get a 403 Forbidden when i visit localhost or time-tracker-2.local. localhost/~jeffcairoli brings me to the listing of all my files in my sites folder. Im not too sure if I am looking at this wrong or something. I've always had an issue getting these to work. Haven't been able to get any of the typical 403 fixes to work there but I think that tells me that at least its recognized my changes since the urls are actually giving me a response.

Adding another VirtualHost before that for localhost to be the default should fix your problem. Just try adding the following before your time-tracker2.com entry.
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Users/jeffcairoli/Sites/"
ServerName localhost
</VirtualHost>

Related

MAMP virtual hosts keep sending me to 'Index of /'

I'm using Mac so I'm working with MAMP.
In /MAMP/conf/apache/httpd.config I did uncomment the second line:
#Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Then in /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf I made this:
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/User/xxxxx/Sites/mysite"
ServerName mysite
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/laravel-blog/public"
ServerName laravel-blog.dev
</VirtualHost>
And my etc/hosts looks like this:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 mysite
127.0.0.1 laravel-blog.dev
so when I go to mysite:8888/ this redirects me to a page called
'Index of /' with all the folders that I have in htdocs
but when I go to laravel-blog.dev:8888/ it says the page failed to open
so I changed it: instead of laravel-blog.dev , I just used laravel-blog, changed it also in my /etc/hosts and in httpd-vhosts.conf file
and now when I go to laravel-blog:8888/ it redirects me back to this "Index of /" page, even tho the DocumentRoot is set to /Applications/MAMP/htdocs/laravel-blog/public
I have searched for hours and tried a lot of things but still nothing seems to redirect me to the '/public' page of an application, only redirects me back to the 'Index' which is the htdocs.
Anyone an explanation for this? how i can get to '/public'?
And why laravel-blog.dev is not accepted but laravel-blog is?
what has that .dev to do with anything?
All of this is a bit above me, but I find when I am redirecting using MAMP (not sure about MAMP PRO) I have to call the file index.(extension) or it will show the index of the whole folder. When you call the file index.(extension), it will open that file.
Hope this helps,
Nat

Virtual Host is not working on XAMPP

I just tried creating a virtual host on my local machine but when I try visiting the URL on my browser, instead it connects to the internet. I have put off my internet and tried but it still doesn't route to my site folder. I don't know what I'm doing wrong.
BTW, I am using Apache 2.4
Here's my httpd-vhosts.conf code.
<directory C:/auth/public>
AllowOverride All
Require all granted
</directory>
<virtualhost *:80>
DocumentRoot "C:/auth/public"
ServerName auth.local
</virtualhost>
And here is my hosts code.
#127.0.0.1 localhost
127.0.0.1 auth.local
#::1 localhost`
What am I doing wrong here?

Keep XAMPP default page as developing website

I am preparing to create my portfolio site and this is something I always thought. I find XAMPP default admin page useful in some ways to me, but as I am developing website, I can't access it any more.
I want to know is there a way to keep XAMPP default page as I am developing other websites.
I know I can setup virtual hosts for several websites, but is it same for XAMPP? I have done virtual host one time as work. At, first it didn't work(what was CakePHP app), but later I have managed to make it work.
UPDATE:
So I found out this post about Hosting multiple local sites with XAMPP and have edited my Virtual Host config file like this:
<VirtualHost *:80>
ServerName localhost/xampp
DocumentRoot "C:/xampp/htdocs/xampp/"
</VirtualHost>
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs/"
</VirtualHost>
My windows host file:
127.0.0.1 localhost
127.0.0.1 localhost/xampp
For now, accessing both 127.0.0.1 and 127.0.0.1/xampp redirect me to XAMPP home page, which is in C:/xampp/htdocs/xampp/
When I access localhost, browser redirects me to index.php file(As 127.0.0.1 also should), which is for testing purposes in htdocs folder. However if I try to access localhost/xampp I get error in Chrome - "This webpage has a redirect loop".
I have no idea how to progress on from here.
I found out answer. THe issue was with my naming of xampp admin page domain, instead of using someting, which include localhost for xampp page, I had to use something else, as it will not conflict when using your own naming.
So my hosts file now:
127.0.0.1 localhost
127.0.0.1 xampp-admin
And Apache Virtual Host file:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/xampp/htdocs/"
</VirtualHost>
<VirtualHost *:80>
ServerName xampp-admin
DocumentRoot "C:/xampp/htdocs/xampp/"
<Directory "C:/xampp/htdocs/xampp/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
This part(below) didn't change anything, I added, because I saw it in examples, but I still have no idea, what it's useful to:
<Directory "C:/xampp/htdocs/xampp/">
Order allow,deny
Allow from all
</Directory>
Still, maybe someone can suggest me more conventional name for Xampp admin page?
All you need to is place this at the top of your httpd-vhost.conf before other virtual host configurations.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/dashboard/"
ServerName xampp.admin
<Directory "C:/xampp/htdocs/dashboard/">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Virtual Hosts not working XAMPP 1.8.3

Im trying to set up a virtual host using my local xampp stack but after following many tutorials i simply can't work out where im going wrong.
Here is what i added to my httpd-vhost.conf file:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
DocumentRoot E:\Programs\xampp\htdocs
</VirtualHost>
<VirtualHost *:80>
DocumentRoot E:\Programs\xampp\htdocs\CVCMS
ServerName cvcms.dev
<Directory "E:\Programs\xampp\htdocs\CVCMS">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And here is my hosts file
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 lmlicenses.wip4.adobe.com
127.0.0.1 lm.licenses.adobe.com
127.0.0.1 cvcms.dev
I have restarted apache after every change, i have made sure http.conf is linked to the httpd-vhosts file.
The issue is when i type in the domain cvcms.dev it shows the xampp splash page instead of the index.php in my cvcms folder.
Any ideas why?
Thanks
please remember to add the quotes to your virtual host document root path. At the same time what you need to to do enable them is to find httpd.conf , in this version it should be in your etc folder within your XAMPP's root folder.
Look out for :
# Virtual hosts
#Include etc/extra/httpd-vhosts.conf
Since '#' is a comment prefix, you have to uncomment "#Include etc/extra/httpd-vhosts.conf"
See if this works. Remember to restart your XAMPP's apache server to read the new settings you've just set. Cheers !
You can read more on this here.

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