Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant get localhost to show WampServer index and dynamic urls at same time

I have installed Wamp so I can run a few simple dynamic sites that I built. I want to be able to have three or four and learn how to do things at local level and then upload the improved files to the live site without having to rewrite sections due to different location/paths etc.

To get WampServer index page to show I go to http-vhosts.conf and add

<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "E:/wamp/www"
</VirtualHost>

I understand that I put my site directory labelled mysite.local into the E:wamp/www so the path becomes E:wamp/www/mysite.local. I then go to http-vhosts.conf and add

<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "E:/wamp/www/mysite.local"
</VirtualHost>

my host file has

127.0.0.1       localhost  
127.0.0.1       mysite.local

and my httfp.conf has

# Virtual hosts  
Include conf/extra/httpd-vhosts.conf

So my problem with all this done I get my WampServer index showing fine when I type localhost in the url, and mysite.local appears on that index page under "Your Projects" which is all good, but when I click on the mysite.local link from WampServer, the url changes to localhost/mysite.local not mysite.local, and then when I click a page link from localhost/mysite.local I get localhost/mysite.local/linkedpage as the url and a 404 error.

mysite.local as the url also brings up the WampServer index page

If I comment out ServerName localhost from http-vhosts.conf and restart apache. I get what I'm after when I try mysite.local as the url - mysite works and all the dynamic links work. but the WampServer index is then a 404 error.

All I want to be able to do is log in to WampServer and visit various sites from "Your Projects" list.

Please help a numpty

like image 363
Peter23 Avatar asked Mar 27 '13 12:03

Peter23


People also ask

Why localhost is not working in WAMP?

Right click on My Computer icon -> Properties Go to Device Manager Click on View menu and chooseShow hidden devices Now from the list choose Non-Plug and Play devices Double click HTTP -> go to Driver For Type choose Disabled Restart your computer After your computer boots up you should be able to start up WAMP server.

How do I know if WAMP server is working?

If you are not sure whether or not WAMP is running, look for the small green W icon in your toolbar. If it is red, WAMP services are stopped, green means everything is running while orange means some services are running.

How do I change my localhost domain to WAMP?

Update Windows Host fileStep 1: Go to C:\Windows\System32\drivers\etc and edit hosts file “as Administrator”. [ For that open, any text editor in administrator mode then navigate to hosts file.] Step 2: Add 127.0. 0.1 and custom domain at the end of file.


1 Answers

hosts file and httpd.conf look OK.

Some things to try ...

  • <VirtualHost *:80> for both virtual hosts.

  • Make sure DocumentRoot strings have a terminal /.

  • For the root virtual host, ServerName localhost:80.

  • To browse via the virtual hosts, always omit localhost/ from the url. The "Your Projects" links include localhost/ and access projects as paths from the root, not as independent sites, each with its own root (which is what virtual hosts gives you).

  • (WAMP 2) When everything else is fixed ... to bring the "Your Virtual Hosts" section of the root "index.php" page alive , follow these instructions. I just did this and have no regrets. Now I can click links to access my sites served as virtual hosts - yay! Exactly what I always wanted of the "Your Projects" links but didn't get.

BTW, the <VirtualHost>...</VirtualHost> directives are the things that tie each host name to a particular path in the server's file system, so subdirectories in "E:/wamp/www/" don't need the ".local" suffix. After removing ".local" from the dirs themselves, make corresponding changes to the DocumentRoot entries , eg DocumentRoot "E:/wamp/www/mysite/". But be sure to leave ".local" in the "ServerName" entries, eg. ServerName mysite.local, to match the entries in your "hosts" file.

like image 115
Beetroot-Beetroot Avatar answered Oct 02 '22 18:10

Beetroot-Beetroot