Error 404 on localhost with wampserver - php

I've been using wamp for 2 weeks at my work without any problem, but now I've some issues :
localhost/phpmyadmin is working well, but
localhost/ and 127.0.0.1 gives me a 404 error :
Not Found The requested URL / was not found on this server.
I already tested the port 80 and it's used by Apache.
I have virtual hosts that works well but I can't create a new one anymore, it won't work, I don't know why.
I've searched a lot on internet but all I can find is solution that just does not work for me so if you could help me, that would be fantastic.
EDIT : I just changed my httpd-vhosts.conf, I had a mistake in my new vhosts, so now they work well, but I still have an error 404 on localhost/.
EDIT : Thank you RiggsFolly for the help, I needed to had localhost in my httpd-vhosts.conf

Ok, this sounds like the browser is trying to use the IPV6 network but you have not entered the IPV6 loopback address into the hosts file
Amend your hosts file to be
127.0.0.1 localhost
127.0.0.1 other.dev
127.0.0.1 other2.dev
::1 localhost
::1 other.dev
::1 other2.dev
The ::1 is the IPV6 loopback address just as 127.0.0.1 is the IPV4 loopback address.
You say you have Virtual Hosts setup, did you also define one, the first one for localhost. Once a Virtual Host is defined the default in httpd.conf for localhost is ignored.
So add this to the top of httpd-vhosts.conf
<VirtualHost *:80>
ServerName localhost
DocumentRoot c:/wamp/www
<Directory "c:/wamp/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Change c: to whatever drive you installed WAMPServer onto.

Related

MAMP all virtual hosts point to htdocs folder

I've read through all the questions I could find but none of them have worked for me. I'm trying to set up a couple of virtual hosts on my MAMP apache install. Currently, typing localhost takes me to my htdocs as expected. However, typing mysite.dev should take me to another directory but it instead drops me off at htdocs.
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
127.0.0.1 mysite.dev
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
I've uncommented in httpd.conf
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
And I've set up my httpd-vhosts.conf a bunch of different ways with the same result. The current state is:
# Use name-based virtual hosting.
#
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin mysite.dev
DocumentRoot "/Applications/MAMP/htdocs/mysite/public"
ServerName mysite.dev
ServerAlias www.mysite.dev
ErrorLog "logs/mysite.dev"
CustomLog "logs/mysite.dev" common
</VirtualHost>
Any help would be greatly appreciated. Thanks!
You might miss some steps. First of all
run mamp with apache 80 and mysql 3306 port. this will automatically change the httpd.conf file with those port. close mamp
go to httpd.conf and go to line: 575 and uncomment this line from
# Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
to
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
If it is not line 575 search with the text and u will find the line.
Next in httpd-vhosts.conf, add your virtual urls/hosts. sample below
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/Project"
ServerName dev.project.com
ServerAlias www.dev.project.com
</VirtualHost>
dev.project.com is just sample and you can name it however you want. server alias is optional but better to keep it just likeserver name but with an extra "www." as it is shown above.
next add those to hosts file like
127.0.0.1 dev.project.com
better to add all possibilities like below
127.0.0.1 dev.project.com http://dev.project.com www.dev.project.com http://www.dev.project.com
save the hosts file and restart mamp. Cheers!!!
I THINK YOU GUYS MISSED STEP 2

Why I can't set a vhost for this PHP website on my XAMPP?

I am finding the following problem trying to create a vhost for a PHP website that I have into XAMPP.
So basically this is where is the index.php file of my website is deployed: C:\xampp\htdocs\MyProject-Panda
Then into the C:\xampp\apache\conf\extra\httpd-vhosts.conf** file I have declared 2 vhost:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/HotelRegistration/public"
ServerName laravel.dev
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/MyProject-Panda"
ServerName panda.dev
</VirtualHost>
(the first one works fine, the second one no).
Finally into the C:\Windows\System32\drivers\etc\hosts file I have:
127.0.0.1 localhost
127.0.0.1 laravel.dev
127.0.0.1 panda.dev
So I am enabling the panda.dev domain on my local machine.
The problem is that when I open the panda.dev domain into my browser it is automatically "rewrited" into http://www.panda.dev/ and it says that can't contact the server.
Why? What could be the problem? How can I try to solve this situation?
You should use .local for local sites. .dev must not be interpreted correctly by browsers, even if you have hosts record.
In this case I think problem is - you have some .htaceess in C:/xampp/htdocs/MyProject-Panda with redirect to WWW version. Windows hosts does not work for subdomains automaticly (as www.panda.dev is subdomain of panda.dev). You eighter has to remove this redirection or add 127.0.0.1 www.panda.dev record to your hosts file.

Error when setting up VirtualHost in Wamp - The ServerName has syntax error in file httpd-vhosts.conf

I am trying to move a live wordpress website to a local site on my computer so that I can make changes and try things out without messing up the live site. I am using WAMP on a Win7 PC.
I went through all the steps...installed WAMP and downloaded my Wordpress files and my database file, put the wordpress files in the D:/wamp/www/site-name folder, I created a new database in phpadmin with the same name as my downloaded datebase, and imported my database, then I updated the URLS inside the database from http://www.site-name.org to localhost/site-name using the sql queries, then I updated the database name, username and password in the wp-config.pho file to reflect what is being used on the localhost versus the live site, then because I was using apache 2.4.x, I went to create a virtual host for my wordpress site because the localhost option was suppressed in the httpd.config file...and from what I gathered, the newer version is made to use virtual host, so I was attempting to do that, instead of unsupressing the localhost option.
So, I went to the the c/windows.system32/drivers/etc/hosts file and added the following
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
::1 localhost
# site-name name resolution
127.0.0.1 site_name #local version of website
::1 site_name
( note I had already checked the httpd.config file, and this line was already active:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
Then, I went to the httpd-vhost.conf file and added in my new virtual host:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot D:/wamp/www
<Directory "D:/wamp/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
#
#
<VirtualHost *:80>
ServerName site_name
ServerAlias site_name
DocumentRoot D:/wamp/www/site_name
<Directory "D:/wamp/www/site_name">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
However, after saving that, and restarting WAMP services, I continue to get an error for Site_name under Virtual host, that says: The ServerName site_name has syntax error in file D:/wamp/bin/apache/apache2.4.23/conf/extra/httpd-vhosts.conf.
I have looked over the above code in the httpd-vhosts.conf for the site_name server, but can't find any syntax errors. The localhost virtual host works, and from what I can tell, the syntax for the site_name server is the same.
I tried running httpd.exe in the apache folder to see if it would give me more details on the syntax error, but I can't get it to run when double clicking on it, and I wasn't sure how to run it from the cmd prompt...I tried, but I kept getting some kind of socket error.
Thank you for the help.
Can someone please help be figure out what might be happening. What am I missing something?
You can't use underscore in host name.

Wordpress Multisite with localhost and 8090 port

Problem
Im trying to setup a local working sub domain Wordpress multisite on the port 8090.
Setup
MAMP Stack with SQL on port 3306, Apache on 8080.
Wordpress 4.4 installed on path: /Users/x/y/website/www/wordpress
Running PHP Webserver in IntelliJ on port 8090.
Error (when trying to install multisite network in the admin wordpress section)
Error: You cannot install a network of sites with your server address
You cannot use port numbers such as :8090.
Therefore I changed my apache2 httpd.config file.
httpd.config
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
and added virtual hosts
httpd-vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Users/x/Environment/mampstack-5.4.32-0/
apache2/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/x/y/website/www"
ServerName testproject.dev
<Directory "/Users/x/y/website/www">
AllowOverride All
</Directory>
</VirtualHost>
Then I changed the /etc/host.
/etc/host
127.0.0.1 localhost testproject.dev
# later on for mulisite sub domains
127.0.0.1 localhost.com
127.0.0.1 subdomain.localhost.com
I restarted the whole MAMP setup, flushed the cache for the htaccess file and restarted my php server. But I still got the same error and cant setup my multisite in Wordpress.
Question
What am I doing wrong?
You cannot create a network in the following cases:
"WordPress address (URL)" is different from "Site address (URL)".
"WordPress address (URL)" uses a port number other than ':80', ':443'.
Change your port to 80 for wordpress multisites is a simple solution.

OSX Mavericks - Set up Apache with subdomains

I have successfully set up a local server running PHP on my Mac, but I am having trouble setting up extra local sites as subdomains (i.e. site2.localhost)
Here's what I have so far:
hosts file:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
127.0.0.1 site2.localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
httpd-vhosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Users/user/Sites/site2"
ServerName site2.localhost
</VirtualHost>
and I've uncommented the following line in the httpd.conf file:
Include /private/etc/apache2/extra/httpd-vhosts.conf
I'm not sure what else I need to add or where I need to add it.
OK, seems as if I needed to look a little harder... It was in fact set up correctly, but for some reason when I typed site2.localhost into the browser it was defaulting to https.
By manually typing in http://site2.localhost it works fine.

Categories