Virtual Host not pointing properly - apache

I have installed Laravel at C:/Apache24/htdocs/lsapp.
It's working fine with localhost/lsapp/public URL.
What I want to do is instead of above URL I want to access it by mak.org on my local machine.
For that I did following changes
Edited C:/Apache24/conf/extra/httpd-vhosts.conf with below lines:
<VirtualHost *:80>
DocumentRoot "C:/Apache24/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/Apache24/htdocs/lsapp/public"
ServerName mak.org
</VirtualHost>
Edited C:/Windows/System32/drivers/etc/hosts with below lines:
127.0.0.1 localhost
127.0.0.1 mak.org
I restarted my apache server.
But when I hit mak.org in browser, instead of accessing "C:/Apache24/htdocs/lsapp/public" it is pointing to "C:/Apache24/htdocs".
I restarted my PC, enabled opcache.enable=0 in php.ini still not getting desired outcome.
Can anybody help me on this?
What or where am I missing?

The issue resolved by enabling below in httpd.conf file of Apache:
Include conf/extra/httpd-vhosts.conf

Related

Laravel Virtual host doesnt work

Iam trying to make virtual host for laravel 5.2 in apache server, but everytime i tried to access the virtual host it always shows "This site cant be reached", but i can access it through localhost:folder/public
I already setting the httpd-vhost
<VirtualHost *:80>
DocumentRoot "C:/xampp2/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp2/htdocs/belajarlaravel/public"
ServerName belajarlaravel.dev
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp2/htdocs/merchandise3-project/public"
ServerName merchandise.dev
</VirtualHost>
and my host
127.0.0.1 localhost
127.0.0.1 belajarlaravel.dev
127.0.0.1 merchandise.dev
I can access the localhost but for other host they still showing server not found and site cannot be reached. Can u give me some advice ? Thank You for your attention.
maybe the .dev ending is considered unsafe by Chrome, try .com

Why won't apache start again when I add a new nameserver in httpd-vhosts.conf file?

I am trying to change my localhost nameservers and I have added the following code to the C:\Windows\System32\drivers\etc\hosts file
127.0.0.1 testingdomainhello.com
127.0.0.1 www.testingdomainhello.com
and I have added the following code to the C:\xampp\apache\conf\extra\httpd-vhosts.conf file
<VirtualHost *:80>
ServerName www.testingdomainhello.com
ServerAlias testingdomainhello.com
DocumentRoot c:/xampp/htdocs/sites/directory
</VirtualHost *:80>
When I add the bit however and try to restart Apache in Xampp, it won't restart, and I'm assuming it's something to do with the port being blocked. How do I solve this so that Apache starts again?
Bingo that broke it when I used...
</VirtualHost *:80>
So just end your virtual hosts with the tag...
</VirtualHost>

Create a Virtual Host in Xamp Windows 10

Last night I have updated my windows 7 to windows 10.
The result is struggle trying to run my local apache server in windows 10 that is running on windows 7.I have tried uninstalling and installing another versions of xampp then I came up that I have to change the apache's default port just to make it run.
I changed httpd.conf
from Listen 80 to Listen 1234
AND
ServerName localhost:80 to ServerName localhost:1234
and in xampp control panel Config->Service and Port Settings. I also change the Main Port
Now I can access phpmyadmin using localhost:1234/phpmyadmin.
And now my problem is creating Virtual host
so I added in my host(C:\Windows\System32\drivers\etc\hosts) file
127.0.0.1 sample.local
127.0.0.1 anothersample.local
And my vhost (D:\xampp\apache\conf\extra\httpd-vhosts.conf) file
<VirtualHost *:1234>
DocumentRoot "D:/xampp/htdocs/sample"
ServerName sample.local
</VirtualHost>
<VirtualHost *:1234>
DocumentRoot "D:/xampp/htdocs/anothersample"
ServerName anothersample.local
</VirtualHost>
I did make sure the vhost file above was include
I already restarted my apache but seems like my vhost is not working .Can anyone point out what i missed?
Thank you #ShamSUP AND #maytham-ɯɐɥıλɐɯ I was able to solve my problem by uninstalling the xampp.
Then following the instructions here
I will just list the steps I have done here.
Windows+R and type appwiz.cpl and use Turn Windows features on or off and install the IIS Manager Console by expanding
Internet Information Services->Web Management Tools->then checking IIS Management Console
Windows+R and type InetMgr.exe and enter, then expand Site Right Click it then click Edit Bindings
Change the http port from 80 to 8080
After that I then install the XAMPP and configure the Virtual host
host(C:\Windows\System32\drivers\etc\hosts) file
127.0.0.1 sample.local
127.0.0.1 anothersample.local
vhost (D:\xampp\apache\conf\extra\httpd-vhosts.conf) file
<VirtualHost *:80>
DocumentRoot "D:\xampp\htdocs\sample"
ServerName sample.local
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/anothersample"
ServerName anothersample.local
</VirtualHost>
And by default in windows virtual host is uncommented
After restarting apache and mysql.The Virtual host is running now.I hope this may help someone in the future.
E:\xampp\apache\conf\extra\httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs/dev2017/schools"
ServerName dev.schools
<Directory "E:/xampp/htdocs/dev2017/schools">
</Directory>
</VirtualHost>
C:\Windows\System32\drivers\etc\hosts
127.0.0.1 dev.schools
NOTE: Restart Xampp Server.
Type URL: http://dev.schools
Maybe my issue is different.
Above answer not worked for me Windows 10, XAMPP portable 5.6.30
My XAMPP works on port 80 but when I set virtual host then its localhost also go to virtual host folder. So http://localhost also shows the content of http://mydrupal
I simply added this to /apache/conf/extra/httpd-vhosts.conf file as well.
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs"
ServerName localhost
<Directory D:/xampp/htdocs>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Above code was not required on Windows 7.
For virtual host - mydrupal
<VirtualHost *:80>
DocumentRoot "D:/vhosts/drupal"
ServerName mydrupal
<Directory D:/vhosts>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Hope this helps.

Virtual hosts not working on MAMP

I am running into virtual hosts setup issues on MAMP. Here is my vhosts config
NameVirtualHost *
<VirtualHost *>
ServerName dev.local.com
DocumentRoot “/Applications/MAMP/htdocs/local”
</VirtualHost>
<VirtualHost *>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
Here is my hosts file
127.0.0.1 localhost
127.0.0.1 dev.local.com
now when visiting localhost and dev.local.com both are pointing to index of local directory. I tried various config setting in vhosts file but none is working. I am on MacBook Pro 10.10
When I first test virtual host (example.dev) I added two slightly different index.php files its directry and to localhost directory (/htdocs). My virtual host would redirect to locahost, I would know because the index.php would be the one in /htdocs. Similar to what user6166 said, I changed the code below to match the 8888 and it worked! I test example.dev:8888 and it works.
NameVirtualHost *:8888
<VirtualHost *:8888>
ServerName dev.local.com
DocumentRoot /Applications/MAMP/htdocs/local
ServerAlias dev.local.com
</VirtualHost>
<VirtualHost *:8888>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
Then to remove 8888 change above back to 80 and MAMP preferences to:
Apache Port:80
Nginx Port:8888
mySQL Port:3306
Then inside httpd.conf change below to 80:
Listen 8888
ServerName localhost:8888
Hope that helps someone, it definely fixed my problem!
I didn't find any of the answers useful, so if other suggestions don't work for you:
Consider that the virtual hosts need to be correctly enabled/included by uncommenting
Include conf/extra/httpd-vhosts.conf in C:\MAMP\conf\apache\httpd.conf and NOT in C:\MAMP\bin\apache\conf or C:\MAMP\bin\apache\conf\original .
There're multiple locations that have MAMP configuration, make sure to uncomment that line in the correctly located file.
Changed the hosts file like this -
NameVirtualHost *:80
<VirtualHost *:80>
ServerName dev.local.com
DocumentRoot /Applications/MAMP/htdocs/local
ServerAlias dev.local.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
Enable virtual host in the right httpd.conf
Open MAMP > File > Edit template > Apache > httpd.conf
edit or add:
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
edit mamp httpd.conf
I had a similar issue with MAMP Pro 5 (after updating from version 4). One of my custom host with aliases was returning a 404 NOT FOUND error.
After a LONG troubleshoot, make sure to add the domain in the alias list.
MAMP 4
host:
test.co
alias:
sub.test.co
Becomes in MAMP 5:
host:
test.co
alias:
sub.test.co
test.co
Hope they'll get that fixed and that it helps someone!
Try to configure MAMP ports by this way:
MAMP
Preferences
Ports
Apache port: 80
Nginx port: 8888
I've had the same port values and after configurating it started working.
Open the main Apache configuration file, httpd.conf, which is located at
Applications/MAMP/conf/apache/httpd.conf
and Remove the hash (pound) sign from the beginning of the line that begins with Include:
Virtual Hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
I'm not an apache expert. But I had the same problem. I think my DNS doesn't resolve my URL.
When I ping exampl.dev everything looks fine, but when I enter example.dev in the browser I get an error. I always have to add http:// in front of the url.

Apache Virtual Host IP Works but not ServerName

I am using Wamp.
My Apache Server is running on port 90.
I Tried adding a virtual host by doing the following steps:
1)Removed the comment from the line Include conf/extra/httpd-vhosts.conf line in my Apache httpd.conf file.
2)I Added the following code to my C:\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf
<VirtualHost *:90>
ServerAdmin admin#laravel.dev
DocumentRoot "c:/wamp/www/laravel/public"
ServerName laravel.dev
ServerAlias www.laravel.dev
ErrorLog "logs/laravel.dev.log"
CustomLog "logs/dummy-laravel.dev.log" common
</VirtualHost>
<VirtualHost *:90>
DocumentRoot "c:/wamp/www/"
</VirtualHost>
3)I made changes to my windows hosts file.This is the content of my hosts file
127.0.0.1:90 localhost
127.0.0.1:90 laravel.dev
127.0.0.1:90 www.laravel.dev
Now localhost:90 will Redirect to my C:/wamp/www and 127.0.0.1:90 will Redirect to my C:/wamp/www/laravel/public but both laravel.dev and www.laravel.dev are not working
I get the message Oops! Google Chrome could not find laravel.dev in my chrome.
Any help would be appreciated :)