MAMP Virtual Hosts not working properly, loading 'It Works!' page - apache

I had an issue last night where MAMP just refused to connect to the Apache server(unsure whether this has something to do with my issue). I decided to uninstall and reinstall. I was able to connect once again, however, when I added my virtual host to the httpd-vhosts.conf file in my MAMP folder, and navigate to it I get brought to a 'It works!' page. (I also realised I get this page by typing localhost even without running MAMP?)
Below are some of my files
httpd.conf(in MAMP)
//Uncommented line below
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
httpd.conf(in MAMP)
NameVirtualHost *:80
<VirtualHost *:80>
ServerName portfolio
DocumentRoot '/Applications/MAMP/htdocs/portfolio'
</VirtualHost>
<VirtualHost *:80>
DocumentRoot '/Applications/MAMP/htdocs'
ServerName localhost
</VirtualHost>
/private/etc/hosts
##
# Host Database
# localhost is used to configure the lookback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 portfolio
This is a copy paste of what I had before which worked 100%, unsure what happened between MAMP stopping working, the uninstall and reinstall. Is there an issue with apache somehow overwriting something? Really out of my depth here with this issue. Is there somewhere else I should be looking to debug this?
For reference, localhost:8888 & localhost:8888/portfolio work as expected, localhost/ & portfolio/ don't, brings me to the 'It works!' page. Before this issue I was able to do 'localhost/phpmyadmin' to bring me to phpmyadmin and 'localhost/portfolio' to bring me to that directory, but neither of those work either. I've been wracking me brain for hours over this, watching tutorials and reading other answers but to no avail.
Anyone have any idea why this is occuring? Any help would be greatly appreciated.

So I eventually figured it out if anyone else has the same issue. I had forgotten previously that I had my localhost running on port 80. However when I tried that before my apache server wouldn't start on MAMP, the reason being was due to port 80 being used by /private/etc/apache2, so I used the answer to this question
https://superuser.com/questions/986775/how-can-i-remove-apache2-that-i-have-installed-in-mac-os-x
to remove apache. (Alternatively I guess you could just change the port number it listens to in the httpd.conf files?) I then changed my MAMP to listen to port 80 and this fixed my problem. Hope this helps anyone else with same issue

Related

Cant Run http://localhost instead of http://localhost:8012

I try configure my localhost XAMPP on like these step How to change XAMPP apache server port?
But when i try restarted my apache and try open http://localhost instead of http://localhost:8012. It said HTTP Error 404. The requested resource is not found.
My suggestion problem :
on file http-ssl.conf i cant found line ServerName localhost:443
Maybe that my problem cant instead http://localhost instead of http://localhost:8012?? Or did i missing something, if i try open http://localhost:8012 is working.
My XAMMP version is 3.2.2 and my apache is Apache2.4, windows 7. And idk i'm using IIS or not because is not my own computer but is my computer office.
Just in case, the full answer does not answer the question. Only some parts do.
If I understand your question, you want to run your website on http://localhost. I just want to clarify that the normal localhost runs on port 80 i.e. http://localhost:80.
So, port 80 and just the localhost aren't different, so please don't get confused. You should not worry about httpd-ssl.conf, you shouldn't have to change it. The configuration is in the main conf: httpd.conf. And, I don't think the link you've given in your question is similar.
Can you access localhost using https://localhost
After all, I think, you want to change your port from 8012 to 80 (http default).
Please follow the following steps to change the port.
1) Click on Config after opening XAMPP
2) Click on Service And Port Settings
3) Change the port to 80 from your current port
If it still has the same error, do this:
Take a backup of httpd.conf before doing the following.
1) Edit your httpd.conf, change the following.
Listen 8012
To:
Listen 80
If still not working, go ahead and add the following at the end:
<VirtualHost *:80>
ServerAdmin your#email.com
DocumentRoot "C:\path\to\website"
</VirtualHost>
Thanks.
Edit:
The only way you could do this is by running your XAMPP server on a different IP like 127.0.0.2
So, try the following:
Edit httpd.conf and say:
<VirtualHost 127.0.0.2:80>
ServerAdmin your#email.com
DocumentRoot "path to htdocs"
</VirtualHost>
Go to the C:\Windows\System32\drivers\etc
Edit hosts file:
For some time, please add something like this.
127.0.0.2 localhostt
Also
You could also change the port of the application that is running on port 80
Open up the CMD
Run the following command:
netstat -aon | findstr "80"<br>
And get the info of something like:
TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 11560<br>
Get the info of the last number i.e is in this post is 11560
Run the following after that
tasklist | findstr "11560"<br>
Replace 11560 to the number that you got running the previous command
And you will know what app is running in the port
My Last Guess:
The new way I found out is by doing this:
Change the listen directive to:
Listen 127.0.0.2:80
Go to the C:\Windows\System32\drivers\etc
Edit hosts file:
Try this:
127.0.0.2 localhost
OR
For some time, please add something like this.
127.0.0.2 localhostt
Hope it works.

Virtual hosts for MAMP 4.1.1 on MAC 10.12.6 not working

I know this has been asked hundreds of times and I made sure I read all of them, but still I cannot get this working. So as the title suggests, I cannot get a vhost running from MAMP/OSX. Here's a list of things I tried so far:
Created configuration in /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot /Applications/MAMP/htdocs
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/abcd/public"
ServerName abcd.dev
ServerAlias www.abcd.dev
</VirtualHost>
Removed comment from the line
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
in the file /Applications/MAMP/conf/apache/httpd.conf
Finally this is how my /etc/hosts file looks
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 abcd.dev
Restarted MAMP and here are the test results:
http://localhost/ - Shows Index of and then /abcd
http://127.0.0.1/ - Shows Index of and then /abcd
abcd.dev - Unable to connect, Firefox was unable to connect to the server abcd.dev
Surprisingly
ping abcd.dev - Returns response 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.053 ms
ping 127.0.0.1 and ping localhost also returns same response.
I had docker running on my computer, I thought that was messing it up, so I stopped in completely, but the problem continues.
Any help is appreciated.
you have specified "www." prefix in your vhosts file, but tried to access is through abcd.dev (without the www.)
abcd.dev is now officially a public domain. So basically my browser is trying to locate the site "out there".
Instead let's use something like abcd.local or abcd.loc
Hope this helps someone stuck in .dev labyrinth.

Enabling virtual hosts in Apache makes every host forbidden (403)

I am on Windows 8 and just now installed Wamp 2.5 (Apache 2.4.9) at C:/wamp to test my code locally. I have my source code repository at D:/workpace/project1 which I manage using GIT (GIT is one of the reasons I don't want to disturb its location).
After Installing Wamp, I just went on to enable virtual hosts by uncommenting the following line in httpd.conf.
#Include conf/extra/httpd-vhosts.conf
Then I headed to conf/extra/httpd-vhosts.conf created its backup and created the virtual host.
<VirtualHost *:80>
ServerAdmin admin#example.com
DocumentRoot "D:/workspace/project1/"
ServerName project1
ServerAlias p1
ErrorLog "logs/project1(local)-error.log"
CustomLog "logs/project1(local)-access.log" common
<Directory "D:/workspace/project1/">
Require all granted
</Directory>
</VirtualHost>
Also edited the hosts file and added the necessary lines.
127.0.0.1 project1
127.0.0.1 p1
The problem is that I get 403 Forbidden error not just when I access project1/ and p1/, but also when I access localhost/.
When I disable httpd-vhosts.conf in httpd.conf by commenting out,
Include conf/extra/httpd-vhosts.conf
I am able to access localhost/ but as expected, project1/ and p1/ too resolve to localhost/.
Surprisingly, when I re-enable httpd-vhosts.conf in httpd.conf and restore the backup of original(unchanged) httpd-vhosts.conf, I still get 403 (Forbidden) even on localhost/. But again when I disable httpd-vhosts.conf, localhost/ comes to normal.
It is furthermore surprising to note that If I change DocumentRoot to a dummy folder within c:/wamp/www, the story is the same. So this is not just happening when DocumentRoot is outside c:/wamp/www.
I feel that I have something extra to enable because there is no chance I have messed up anything as this is a fresh installation and I have made no changes except the ones above.
What may be the reason Apache is not getting along with virtual hosts?
There are a few things that you have not taken into account.
When you create Virtual Hosts Apache ignores the host defined in httpd.conf so you also need to create a Virtual Host for localhost. This explains why you cannot get to localhost when you have activated Virtual Hosts.
Apache is IPV4 and IPV6 aware, so when you create your domain names in the HOSTS file you need to do so for both the IPV4 and IPV6 stacks. So you would need to have a HOSTS file like this :-
#IPV4 Stack
127.0.0.1 localhost
127.0.0.1 project1
#IPV6 Stack
::1 localhost
::1 project1
The browser makes some arbitrary decision on whether to use the IPV4 stack or the IPV6 stack. Wish I understood why and for what reason it makes this decision better, but basically when you enter a domainname, the browser, or the networking stack, picks IPv4 or IPv6 for your first contact to a domain and then sticks to that decision, but it could use either.
Here is a post that should help you create Virtual Hosts

Apache server in port number 80

Though the question asked seems to be very ridiculous but I am practically facing this and left with no option but to ask it.
In httpd.conf file whenever I give port no other than 80 it works fine but if I give port no 80 after some time or may be from beginning it stops working means I am not able to get the desired web page though
when I try netstat -ano it shows that apache server is running on port no 80.
previously IIS7 was working on port no 80.I stoped the process.
Locate your apache config and search for:
Listen 80
change 80 to your desired port
Next you may want to change the vHost setting. Find whereever your vhost settings are located (mostly conf/extra/httpd-vhosts.conf) and locate something like this:
<VirtualHost *:80>
ServerAdmin mail#domain.tld
DocumentRoot "path/to/my/document/root"
ServerName subdomain.domain.tld
ErrorLog "path/to/my/error/log/domain.error.log"
CustomLog "path/to/my/access/log/domain.access.log" common
</VirtualHost>
change the 80 here again to your desired port. Restart your apache.
If youre working on unix:
service apache22 start
service apache22 stop
(commands for apache 2.2)
on windows:
net stop apache2.2
net start apache2.2
(commands for apache 2.2)
Greetings
(make sure your firewall doesnt block your desired port and its not used by another programm. For additional help you should always check your error logs.

XAMPP apache server not using the ports I desire, not certain why

So, I've been setting up this HTTP server for a school project that has to be able to maintain multiple domains through virtual hosts. Using XAMPP I have my server set up, I thought I'd done it properly but perhaps not.
I had heaps of issues with not being able to listen to a port, to solve this I used (in httpd.conf under apache/conf/)
Listen 0.0.0.0:8080
ServerName localhost:8080
If I used 80/81/8080/321/any combination that did not have the prefix 0.0.0.0 it told me the port could not be listened or whatever (sorry, a little rusty with my syntax).
I set up my first virtual host up like so (under apache/conf/extra/httpd-vhosts.conf):
NameVirtualHost *:8080
<VirtualHost *:8080>
DocumentRoot "H:/xampp2/xampp/htdocs"
ServerName localhost:8080
<Directory "H:/xampp2/xampp/htdocs">
Option Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I thought this seemed all good and well and I don't believe I've modified anything else. To me, I would expect that this means my Apache server would use port 8080 for the server? However, when I start Apache in XAMPP it states quite clearly
Apache started [Port 80]
Why would this be port 80?
In conjunction, localhost:8080 doesn't navigate me to the documents, but localhost:80 or localhost do. I presume that this just means it's still on port 80. I've tried resetting my computer and XAMPP.
If you need any more information, please let me know. I tried following guides such as this one: http://ailoo.net/2008/07/set-up-multiple-virtual-hosts-on-xampp-for-windows/
Cheers.
Oh, I also edited my Windows HOSTS file; it looks like so:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
127.0.0.1 localhost:8080
Edit: New error... Now getting this when I init, doesn't seem to be affecting it though:
ERROR: Status Check Failure [3]
This program must be run from your XAMPP root directory.
It is being run from teh root directory as far as I can tell.
Ok Im not advanced in this area either. However after much playing around with XAMPP and following a few different guides I got mine working.
The Host under drivers seems abit weird. I declared mine as:
127.0.0.1:8080 test.localhost.com
127.0.0.1:8080 test2.localhost.com
Back up you Xampp, then extract a clean install to C: - Just because that Status check failure sounds like bad news.
!Remember to run setup_xampp.bat from the xampp directory and install the apache service!
Then under you httpd.conf add:
ServerRoot C:\xampp\apache
Listen 7070
Listen 8080
Listen 9090
Apache might not like that at first but meh.
The ServerRoot may already be declared above the Listen spot so just double check.
After that head to C:\xampp\apache\conf\extra.
Edit the httpd-vhosts.conf.
Under the section Name-based virtual hosting add:
NameVirtualHost *:7070
NameVirtualHost *:8080
NameVirtualHost *:9090
There will be a couple of examples of virtual hosts below that. Add:
<VirtualHost *:7070>
DocumentRoot "C:/xampp/www/YOURWEBSITEDIR1"
ServerName test.localhost.com
<Directory "C://xampp/www/YOURWEBSITEDIR1">
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:9090>
DocumentRoot "C:/xampp/www/YOURWEBSITEDIR2"
ServerName test2.localhost.com
<Directory "C://xampp/www/YOURWEBSITEDIR2">
Allow from all
</Directory>
</VirtualHost>
Not the double slash in the Directory tag. Now ensure there is an index.html under each of those directories. Restart the apache (Stop, start).
I cant navigate to the test.localhost.com URLs, probably due to the fact they are terribly wrong in the HOSTs config. Though I can connect to 127.0.0.1:7070, 127.0.0.1:9090 and access the webpages from there.
Also 127.0.0.1:8080 connects me to the xampp welcome panel that localhost used to connect you too.
Hope this helps and good luck!
I'm pretty sure that saying 'listening on port 80' is hard-coded into XAMPP, regardless of the port you use. Thus, your code should work fine.
In my .conf file, it just says "listen 80" instead of Listen 0.0.0.0:8080
Cheers.