vhost showing default wamp page - php

I am using wamp to build my web application. So I had one vhost at mydomain.com but now I have changed my domain to dev.mydomain.com . For this changes to reflect I have edited etc\hosts file's entry from 127.0.0.1 mydomain.comto 127.0.0.1 dev.mydomain.com and in apache configuration file httpd-vhosts.conf -
<VirtualHost *:80>
DocumentRoot "D:/Software/Installed/wamp/www/myapp/public"
ServerName dev.mydomain.com
<Directory "D:/Software/Installed/wamp/www/myapp">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require local
</Directory>
When I open url dev.mydomain.com, I see the default wamp config page.
I have gone through many tutorials to find out what mistakes have been done but could find none. It would be helpful if someone throws some light on that. Thanks.

Why is your Directory different than DocumentRoot ??
I think you need to match those and restart your wamp and you are good to go.
Also, you must have index file in directory to see domain running properly.

Related

Can't access laravel page in vhost setup

I have a problem with the set up of laravel using a vhost. I have a different projects using vhost and it has no problem but when I try to set up this with Laravel I can't access it in my web browser. It just redirect to google page and searching for my vhost url.
So far here's what I did.
I included my vhost entry in httpd-vhosts.conf file
<VirtualHost *:80>
ServerName dev.laravel_validation.local
ServerAlias dev.laravel_validation.local
DocumentRoot "C:/Users/Web4/Desktop/laravel/laravel_validation/public"
<Directory "C:/Users/Web4/Desktop/laravel/laravel_validation/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
I include the name in Windows hosts file
127.0.0.1 dev.laravel_validation.local
Then restart Wampserver. And I access the URL dev.laravel_validation.local to my browser but it doesn't display the Laravel's welcome page.
I don't know where did I go wrong. Can you help me with this?

WAMP httpd.config redirect

I'm using wamp on localhost at c:\wamp\www\.
The project located under: c:\wamp\www\MyProj\public (root).
In file1.php (located in root) I have a link to some fake url (/services/.....).
I'm trying to redirect that url to other file service_router.php (in the same direction as file1.php).
I'm doing that in httpd.config:
<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot c:\wamp\www\
<Directory "c:\wamp\www\">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/MyProj/public/services/*
RewriteRule . /MyProj/public/service_router.php
</VirtualHost>
But my WAMP refuses to restart.
What's wrong with my configurations?
Can I make a few suggestions.
If you want to use Virtual Hosts, and I consider that a very good idea. You need first to make sure that localhost still works and secondly it is a good idea to move you actual projects out of the \wamp\ folder structure.
So this would be a good starting point for your first ( of many ) VHOSTS
First create a new folder structure somewhere on any of your drives for example
C:\websites\project1\www
Now copy your project to the www folder.
Now setup the vhosts
# must be first VHOST so the that localhost and the wamp menu page still work
# Also makes this the default site so any randon hacks on your ip address
# will come here and hopefully be rejected because it only 'Allows' access
# from this machine ( see Allow Deny )
<VirtualHost *:80>
DocumentRoot "D:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/websites/project1/www"
ServerName project1.dev
ServerAlias www.dqsc.old
Options Indexes FollowSymLinks Includes ExecCGI
<Directory "C:/websites/project1/www">
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Unless you actually want to make this site available to the World can I suggest that you dont use Allow from all.
Try using or the second Allow line if you want to see your site from any machine on your internal network, just use the first 3 of the 4 quartiles of your ip address and it will allow access from any ip starting with those 3 quartiles.
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
Allow from 192.168.0
Now you need to amend your HOSTS file so that windows knows about your new domain name.
Edit c:\windows\system32\drivers\etc\hosts and add the new site name project1.dev like so, you will have to launch your editor 'Run as Administrator' as this file is protected by windows :-
127.0.0.1 project1.dev
Now restart the "DNS Client" service to refresh the windows dns cache so it see's your new domain name. Start a command window, again "Run as Administrator".
net stop "DNS Client"
net start "DNS Client"
You should now be able to enter http://project1.dev in a browser and it will find you new site.
Finally, once you test that your site is working, put the url rewrite coding in a .htaccess file in the root of your new project.
C:\websites\www\project1\.htaccess

How to setup virtual host using Wamp Server properly? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 months ago.
Improve this question
I need your help here in creating a virtual host in wampserver. In office I can create a virtual hosts but when I try to create in my laptop it doesn't work. I still can't figure out what's wrong. Here's what I did.
I copy the wordpress file in this folder. This will be the path of my project
E:\Subversion\chelle.wpblog.local
I edit the host file
C:\Windows\System32\drivers\etc\hosts
I added it to the end of file
127.0.0.1 chelle.wpblog.local
Next is I enable the virtual host in Apache
C:\wamp\bin\apache\Apache2.4.4\conf\httpd.conf
I uncomment this
Include conf/extra/httpd-vhosts.conf
Next is I setup the virtual host in WAMP
C:\wamp\bin\apache\Apache2.4.4\conf\extra\httpd-vhosts.conf
I add this at the bottom
<VirtualHost *:80>
ServerName chelle.wpblog.local
ServerAlias chelle.wpblog.local
DocumentRoot "E:/Subversion/chelle.wpblog.local/"
<Directory "E:/Subversion/chelle.wpblog.local/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
Last is restart wampserver and open the chelle.wpblog.local in the browser. And it doesn't display. It display only google search results.
I was installing the zend framework on my local wamp using apache server.
First go and decide what will be your domain name for the local url.
Ex->www.test_zend_tutorial.com
then go and open the file located at "C:\WINDOWS\system32\drivers\etc"
hosts
write
127.0.0.1 (use one tab space) www.test_zend_tutorial.com
then go to the folder located at
D:\wamp\bin\apache\Apache2.2.17 (whatever is your version) \conf\
and open the file
httpd.conf
and search for text
Include conf/extra/httpd-vhosts.conf
and uncomment it by removing the # tag from the start of the line.Save the file and close it.
Now go to another folder located at
D:\wamp\bin\apache\Apache2.2.17\conf\extra
and open the file
httpd-vhosts.conf
and paste the code below at the last in this file
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot "D:\wamp\www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerName www.test_zend_tutorial.com
DocumentRoot "D:\wamp\www\(your project folder name)\public"
SetEnv APPLICATION_ENV "development"
<directory "D:\wamp\www\(your project folder name)\public">
DirectoryIndex index.php
AllowOverride all
Order Allow,Deny
Allow from all
</directory>
</VirtualHost>
and restart the wamp, now write the www.test_zend_tutorial.com in the browser and you will see the things working.
If when you use the new domain in the browser it goes to a google search or something like that then the change to your hosts file has not been recognised.
You have to either reboot after changing the hosts file or more simply run these 2 commands from a command windows ( as administrator )
net stop dnscache
net start dnscache
This will refresh windows DNS cache and pick up your hosts file changes.
It is also a good idea to ping your new domain to check it is being seen, use
ping chelle.wpblog.local
If it reports 127.0.0.1 as the ip address and 4 send and 4 receieved packet then the domain is now known to Windows, if it reports some other ip address the hosts file change has not succeeded.
Also it is a good idea when creating VHOSTS to also create one for localhost or the wamp home page will not work.
You also have old Apache 2.2 syntax (Order allow,deny allow from all) you could try using the Apache 2.4 syntax, see below
So try this
## must be first so the the wamp menu page loads
<VirtualHost *:80>
ServerAdmin webmaster#mail.net
DocumentRoot "D:/wamp/www"
ServerName localhost
<Directory "D:/wamp/www">
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#mail.net
ServerName chelle.wpblog.local
ServerAlias www.chelle.wpblog.local
DocumentRoot "E:/Subversion/chelle.wpblog.local"
<Directory "E:/Subversion/chelle.wpblog.local">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
In WampServer 3.0.4 you do not need to run through all those setting up.
Go to local host and under Tools area for "Add a Vertual Host" in the first time it will say turn on "Vertual Host sub menu" in wamp server settings.
To get there right click on wamp icon > go to wamp server settings > and click on Vertual Host sub menu. Then re-fresh the page and follow the setup process, you just need to provide the server name and path. It will do all the works for you.
Simple as that
Method 1:
in hosts file
127.0.0.1 mysite
::1 mysite
in C:\wamp64\bin\apache\apache2.4.23\conf\extra\httpd-vosts.conf file add your virtual host as follows
<VirtualHost *:80>
ServerName mysite
DocumentRoot "<path_to_your_local_site>"
<Directory "<path_to_your_local_site>">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Make sure vhost configuration is enable in httpd.conf file is enabled as follows
C:\wamp64\bin\apache\apache2.4.23\conf\httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
After you have changed configuration as above, restart all service in wamp and load website as follows
http://mysite
your local site should open.
Method 2:
In latest versions of wamp, you can do this configuration via webpage.
Open localhost in your browser. You would see wamp welcome page.
Down below under Tools, there is option to add virtual host. click on the link which would take you to add virtual host page.
In Name of the host, enter your site name eg: mysite
Under Complete absolute path of the VirtualHost folder, enter the path of your site.
Save the config and restart all services. you should be able to open mysite with the link http://mysite
As pointed in another answer, in newer versions of wam
The answers above are overcomplicating the problem somewhat, and in fact the question is including extra information that's misleading the responders.
The clues lie in step 2 and the symptoms described in 5. The hosts file is set up but when the request is made to "blah.local", google responds. Apache is not involved.
The first step to diagnosis would be pinging blah.local and seeing that it maps correctly to 127.0.0.1. I have never (in many years as a developer) found it necessary to restart local DNS on either Windows or Linux/Mac so I would expect this to work out of the box. But if it doesn't, of course restart DNS and see that it does.
However, late versions of Chrome at least do not recognize the TLD '.local' and so when you put the URL back in the browser, it's passed on to Google as a search term. There may be a setting in your browser to tell it to handle the unsanctioned TLD, but your simplest solution would be to use a TLD that's sanctioned by W3C like '.com'.
In short, if your hosts file reads something like
127.0.0.1 local.chelle.wpblog.com
rather than
127.0.0.1 chelle.wpblog.local
everything should work.
Create the folder for your local website
Go to localhost (browser)
Click Add a Virtual Host button
Add the name of the virtual host
Add the complete absolute path
Restart DNS

Django/mod_wsgi and PHP as Virtual Hosts on same Apache Server using MAMP

UPDATE: My original question is below, but the code I posted with the question has been edited to the final working solution.
I am trying to run multiple sites on my MAMP development server. Some of the sites are wordpress sites that live in the htdocs in MAMP and some of the sites are django apps that live in a folder titled djangoprojects.
I have been trying to implement the solutions from these stack questions:
multiple django sites with apache & mod_wsgi
How do I run Django and PHP together on one Apache server?
but I have not been successful. I was able to run the django site on apache with the code you see in the first VirtualHost brackets (from the daemon process line onward) but then none of the php sites could be visited.
Help is greatly appreciated. I am new with this and I can't work out the errors.
Here is the code from my httpd.conf:
UPDATE: The code below works. Both the Django App and the PHP applications exist on the localhost server. The PHP related VirtualHost stuff was copied from further up in the MAMP httpd.conf file.
<VirtualHost *:80>
ServerName localhost:80
UseCanonicalName Off
DocumentRoot "/Applications/MAMP/htdocs"
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
<Directory "/Applications/MAMP/htdocs">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess site1 display-name=%{GROUP}
WSGIProcessGroup site1
Alias /media/ /Users/sequoia/djangoprojects/dynamics/media/
<Directory /Users/sequoia/djangoprojects/dynamics/media>
Options ExecCGI
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias /dynamics /Users/sequoia/djangoprojects/dynamics/apache/django.wsgi
<Directory /Users/sequoia/djangoprojects/dynamics/apache>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
A couple of problems to start with:
ServerName is mean to specify the host name not a URL path.
You should never set DocumentRoot to be where your Django site source code is.

Confused with Zend Server Configuration

I have installed Zend server and developed a sample application, and iam surprised when my application url could not open in the browser...
This is my url, related to my zend application:
http://localhost/app_name/public/controller/action/parameter
I got an error like: "The requested URL /app_name/public/controller/action/parameter was not found on this server".
When i read the quickstart guide from here, i learnt that i had to define a VirtualHost directive inside my httpd.conf file of Apache directory.
But to my surprise, i found the following lines already existing in my httpd.conf file:
DocumentRoot "C:\zend\Apache2/htdocs"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
Could not understand what to do...
First of all , your document root was wrong.You are using forward and backward slash at the same time and accessing the localhost will take you to the htdocs not the virtual host.
Please follow these steps to create a virtual host or check your setting with these
Create a virtual hosts
<VirtualHost *:80>
ServerName cert.local
DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cert/public"
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cert/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Register with your operating system (for windows)
Go to c:\WINDOWS\system32\drivers\etc and add the following line
127.0.0.1 cert.local
Restart the apache server and in order to access the virtual host go to http://cert.local/
If you want to access the htdocs and zend at the same time then you have to create another virtual host pointing to the htdocs.
Here is some basic about Virtual hosting
http://httpd.apache.org/docs/2.2/vhosts/
Hope this will help..:)
Got it... In the VirtualHost definition mentioned in the quickstart guide in the above link, the DocumentRoot and Directory were configured to the quickstart application, and if the document root was mentioned only till "htdocs" by default (not till application name/public), the zend format url doesn't work.
As i have many zend applications in my htdocs, i had to make the paths of DocumentRoot and Directory till "htdocs" itself, as it will vary in future for each application. So i added the following lines in my httpd.conf file, to make my app url work. Now i can run any zend application without modifying the httpd.conf file.
(and i also had to tell to the client to add these lines in his httpd.conf file for testing the application :)
<VirtualHost *:80>
<Directory C:\zend\Apache2\htdocs\>
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
Hope it helps someone.

Categories