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

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>

Related

Virtual Host not pointing properly

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

Root relative virtual host MAMP

I'm trying to set up a virtual host with MAMP for mac.
I'm doing this, because we need to have root relative urls for our project, but I just can't get the root relative links to work.
We are including a footer.php file on an index.php file like this:
<? include('/master/footer.php') ?>
But the / before master does not work, and this is what I need to fix.
Below is what I have done so far. Hope someone can help me out.
MAMP - httpd-vhosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/template/"
ServerName template.localhost
</VirtualHost>
MAMP - httpd-conf:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
My port is set to 80 on MAMP and I have restarted it :)

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 :)

Configuring two server simultaneously at apache local

I wanna configure two server simutaneoulsy at my apache. one is with name localhost n another is with name shadaab.
What I did was edited C:\xampp\apache\conf\httpd.conf and added these lines at last of files
NameVirtualHost localhost
<VirtualHost localhost>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
NameVirtualHost shadaab
<VirtualHost shadaab>
DocumentRoot "F:/projects/all/"
ServerName shadaab
</VirtualHost>
Restarted apache server. When I browse in url localhost its working fine but when I did for 'shadaab' it doesn't work.
Later on how mysql will be connected with shadaab server pelase help. What other changes do I need to do.
Your config is WAY off. I suggest reading some documentation.
Your config should look something like:
NameVirtualHost 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1:80>
DocumentRoot "F:/projects/all/"
ServerName shadaab
</VirtualHost>
Or replace 127.0.0.1 with * to make apache listen on all IP addresses, not just the loopback.
add
127.0.0.1 shadaab
in your host file
You will be able to connect to your mysql server via shadaab.
shadaab will point to 127.0.0.1