i have two sample application in the same machine.
it is PHP.
i am in need to develope application that supports cross domain cookies.
so ,now i am trying to run two application in different port in apache server. so for that i changed the port number in httpd.conf.
like i added
Listen 8080
and i am not getting about the
VirtualHost *:80
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot /www/docs/dummy-host.example.com
ServerName dummy-host.example.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
Please let me know how to add that for my second port 8080.
i run my application from the browser as xxx.xx.x.xx/First/Cookies.
i tried as xxx.xx.x.xx:80/First/Cookies.----this is fine,
how can i try it for 8080 for my second application.
Please guide me.
This should be the bare minimum you need. Add other useful directives at will.
Listen 80
<VirtualHost *:80>
DocumentRoot /home/x/z/
... the usual stuff ...
</VirtualHost>
Listen 20117
<VirtualHost *:20117>
DocumentRoot /home/x/y/public_html
</VirtualHost>
<VirtualHost SERVERNAME:8080>
ServerAdmin webmaster#another-host.example.com
ServerName SERVERNAME:8080
DocumentRoot "/www/docs/another-host.example.com"
ErrorLog logs/another-host.example.com-error_log
CustomLog logs/another-host.example.com-access_log common
also add this line in httpd.conf file
Listen 8080
<Directory "/www/docs/another-host">
Options All
AllowOverride All
Order allow,deny
Allow from all
also add this
Related
Actually, I downloaded PHP7.2.7 safe thread from PHP's website(php.net) and I don't know if it is possible I can configure PHP to setup a virtualhost like we can do using XAMPP
You can try below configuration:
1) Entry in hosts file as below
127.0.0.1 example.com
2) Set virtual host in httpd-vhosts.conf as below
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/var/www/example/public_html"
ServerAlias quickstart.com
<Directory "/var/www/example/public_html">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
PHP has a built-in web server, but is has limited capability. It does not provide all the configuration options a complete web server does. It does not do VirtualHost.
If you need VirtualHost, you will have to include it as a module inside Apache (or other web server). The module will be global. If your pages in a VirtualHost do not need PHP, PHP remains dormant and does nothing.
PHP isn't a web server, you need to create a VirtualHost in Apache. If you're using Linux, open up httpd.conf or /etc/apache2/sites-enabled/000-default.conf
and enter the following lines.
<VirtualHost *:80>
ServerAdmin admin#example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Make sure to restart your web server/apache in order to these changes to work.
I am a complete novice when it comes to WAMP, apache etc.
I'm trying to get a site to run locally but so far not having any luck. I've got as far as installing WAMP and it seems to be going online fine, i.e. the green "W" icon is green. Features like phpmyadmin seems to be working. When I click "localhost" it opens the browsers and navigates to localhost as you'd expect, however, all I see is the directory listing.
So, I have virutal hosts set up as follows:
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/bts/BiteTheSun"
ServerName bts
ServerAlias bts
<Directory "c:/wamp/www/bts/BiteTheSun">
Require all granted
</Directory>
</VirtualHost>
and in my hosts file I have:
127.0.0.1 localhost
127.0.0.1 bts
::1 bts
::1 localhost
I've added some images just to be clear as to the issue - the top image shows what I think I should be seeing and the bottom shows what I actually see:
localhost screenshot issue
I've tried everything I can think of to no avail. It might also help to mention that in the log file [apache_error.log] I seem to get errors relating to permissions:
"AH01630: client denied by server configuration: C:/Apache24, referer: http://localhost/"
However, I've gone through the permissions set in the config files using examples from several sources and nothing seems amiss.
Has anyone any idea what is going on here? I have searched online high and low on this and on one else seems to have exactly this issue which makes me think it is me doing something very silly - I just need someone to point out how exactly! :)
Richard
Is there an index file in your www folder?
Typically, you want to place your individual projects within the www folder and point your virtual hosts to the www/your-project/ folder which should contain an index.php file (unless you have a custom set up where you are going to point your virtual host directly to a specific file).
Your Virtual Host definitions are incomplete.
Each VH should have its own <Directory>...</Directory> definitions so you can apply the access and other config information to that directory.
The parts you are missing are AllowOverride and Options.
The other thing to remember is that when you create a Virtual Host environment the host defined in the httpd.conf file is basically ignored and the VH's take presidence. This is why you need to redefine the localhost in the VH file.
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/bts/BiteTheSun"
ServerName bts
<Directory "c:/wamp/www/bts/BiteTheSun">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
Your AH01630: client denied by server configuration: C:/Apache24 error is likely because the default httpd-vhost.conf file comes with 2 example definitions as supplied by Apache. These should be completely deleted from the file. So if you left these in the httpd-vhost.conf file. Delete them completely from the file.
Example of the defs to remove. Note they use the c:/Apache24 directory which does not, and should not exist in a WAMPServer environmant!
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
I just started learning php and I am trying to host locally my own php website by using XAMPP.
I wanted to create virtual host with:
URL: myphpwebsite.local
Port: 8088
But when I attempted to access this website through the browser I got a:
Not Found
HTTP Error 404. The requested resource is not found.
Does anyone know what the problem is?
My httpd-vhosts.conf
NameVirtualHost 127.0.0.1:8088
<VirtualHost 127.0.0.1:8088>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost myphpwebsite.local>
DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
ServerName myphpwebsite.local
ErrorLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.error.log"
CustomLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.custom.log" combined
<Directory "C:/Microsoft/Workspace/myphpwebsite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And my C:\Windows\System32\drivers\etc\hosts file:
127.0.0.1 localhost
127.0.0.1 myphpwebsite.local
Any help would be appreciated!
make sure there's file/htaccess/index or whatever in directory you want to open, 404 may comes from that ;)
try using one below, eventually replace your port:
<VirtualHost *:80>
DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
ServerName myphpwebsite.local
</VirtualHost>
the question is your Apache running/serving on port 8088?
For example my xamp is running on 80 and 443...
xamp control panel is very handy, it has nice logs button that will open your log files to show you php and apache errors etc. check it out.
Try going with default port, if it works it means that you need to play with ports if you really want to.
just a quick tip, .com is shorter than .local and if you're using chrome and it works like mine then most of the time something.local will redirect you to google search (and I like my search there, you can switch it off ;))
I don't know if I am much help, but using WAMP, here are my settings. I am listening on port 80, I use 8080 for my tomcat server.
hosts file
127.0.0.1 local.mysite.com
httpd-vhosts.conf
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
....
<Directory "c:/wamp/www">
Options Indexes MultiViews FollowSymLinks
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</Directory>
<VirtualHost *:80>
ServerName localhost
DocumentRoot "c:/wamp/www"
</VirtualHost>
<Directory "c:/wamp/www/path/to/site/root">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<VirtualHost *:80>
ServerName local.mysite.com
DocumentRoot "c:/wamp/www/path/to/site/root"
ServerAdmin me#email.com
ProxyPreserveHost Off
RewriteEngine On
AllowEncodedSlashes NoDecode
#AllowEncodedSlashes On
ErrorLog "c:/wamp/www/path/to/logs/error.log"
CustomLog "c:/wamp/www/path/to/logs/access.log" common
</VirtualHost>
....
Then I can access my local site like this: http://local.mysite.com
Hope this helps...
The NameVirtualHost directive needs to match the value of VirtualHost exactly, and you need to specify the port in each instance. If you want to use port 8088 for myphpwebsite.local, you'd need to do:
NameVirtualHost 127.0.0.1:8088
<VirtualHost 127.0.0.1:8088>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1:8088>
DocumentRoot "C:/Microsoft/Workspace/myphpwebsite"
ServerName myphpwebsite.local
ErrorLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.error.log"
CustomLog "C:/Microsoft/Workspace/myphpwebsite/logs/myphpwebsite.local.custom.log" combined
<Directory "C:/Microsoft/Workspace/myphpwebsite">
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Notice the VirtualHost opening tags are identical; it's the ServerName value that actually tells Apache which domain this particular directive applies to. Restart your server after making the changes. Check out this page for more information: http://httpd.apache.org/docs/2.2/vhosts/name-based.html
Hope this helps!
Make sure that the port you are using is not being used by another service.
I am using a wamp version 2.5
My Apache is 2.4.9
PHP: 5.5.12
MySQL: 5.6.17
I have these configurations:
On my httpd.conf
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
On my G:\wamp\bin\apache\apache2.4.9\conf\extra\httpd-vhost.conf
# Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "g:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "g:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "g:/wamp/www"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "g:\wamp\www\mysite\public"
ServerName mysite.dev
</VirtualHost>
On my c:\Windows\System32\Drivers\etc\hosts
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost
127.0.0.1 mysite.dev
# ::1 localhost
I try to access my project using this URL: http://www.mysite.dev/ BUT I am getting a Server not found error I tried accessing it using www.mysite.dev , http://mysite.dev but still having a bad luck!
My virtual host was working before but i'm not sure why it wasn't working now. Some weird stuff going on.
I am not sure what's happening. Any ideas will be greatly appreciated!
Thanks!
First you need to remove the example dummy definitions from your vhost-httpd.conf file. They are there as examples only just to get you started with the syntax, and should not remain in an active conf/extra/httpd-vhosts.conf as they are pointing to non existant folders.
So remove these 2 definitions from the file:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "g:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "g:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
Second Apache 2.4.x is IPV4 ( 127.0.0.1 ) and IPV6 (::1) aware so your hosts file should look like this with definitions for both IPV4 and IPV6 versions for each site. The browser can arbitrarily use either so you need both but will probably use the IPV6 network in preference to the IPV4 if both are actually active on your PC.
127.0.0.1 localhost
::1 localhost
127.0.0.1 mysite.dev
::1 mysite.dev
Now on the 2 Virtual Hosts that actually exist on your system try this as the Virtual Host definition :
<VirtualHost *:80>
DocumentRoot "g:/wamp/www"
ServerName localhost
ServerAlias localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "G:/wamp/www">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "g:\wamp\www\mysite\public"
ServerName mysite.dev
ServerAlias www.mysite.dev
ErrorLog "logs/mysite-error.log"
CustomLog "logs/mysite-access.log" common
<Directory "G:/wamp/www/mysite/public">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
The <Directory>....</Directory> section within the <VirtualHost>....</VirtualHost> section tells Apache which IP Addresses it is allowed to accept connections from, so using the Apache 2.4 syntax Require local limits access so that only the PC running WAMPServer i.e. Apache can connect to any of these site.
Avoid mixing Apache 2.2 syntax and Apache 2.4 syntax together in the same definition. So dont use
Order Allow,Deny
Allow from all
and
Require all granted
in the same definition. You are using Apache 2.4 so use the Apache 2.4 syntax.
If you find you want to allow other PC's inside your local network to see you site i.e. work mate or the kids etc, you can add this syntax to one or more of your Virtual Host definition.
Allow just a single other PC into your site
Require local
Require ip 192.168.1.100
or 2 other PC's
Require local
Require ip 192.168.1.100, 192.168.1.101
Or to anyone on your local network just use the first 3 of the 4 quartiles of the ip address.
Require ip 192.168.1
Also avoid using the syntax that allows access from anywhere i.e.
Require all granted <--Apache 2.4 syntax
or
Order Allow,Deny <-- Apache 2.2 syntax
Allow from all
It may solve your issues in the short term, but is just waiting to catch you sometime later when you decide you want to show your site to a friend/client/boss. If you get to the stage of Port Forwarding you router so that the world is allowed into your network that would cause ALL OF YOUR SITES to become available to the world.
Better to change the ONE Virtual Host Definition for the ONE site you want people to see for testing/bragging from Require local to Require all granted and only allow that single site to be access from the internet.
Once you have made all these changes remember to restart Apache.
Also if you change the hosts file to make the chnages active you should either reboot or run these command from the command line of a command windows started ising the Runs as Administrator option.
net stop dnscache
net start dnscache
If you are using Windows 10 the above dns commands no longer work, you should do this instead.
ipconfig /flushdns
Due to Google acquiring .dev gTLD, having .dev development sites is no longer easily possible, best way to mitigate is to just rename your development domain into .local or something that you prefer.
What happens in the background is that the local DNS server redirects the browser to 127.0.53.53 (open cmd > nslookup yourdomain.dev) in order to inform end-users of .dev gTLD being acquired. Since the .dev domain in hosts file is set to 127.0.0.1 it shows connection refused.
You can change 127.0.0.1 to 127.0.53.53 in the hosts file and see that the browser error changes from ERR_CONNECTION_REFUSED to ERR_ICANN_NAME_COLLISION.
Following is working for me
<VirtualHost *:80>
DocumentRoot "G:\project\test.dev"
ServerAdmin test#gmail.com
ServerName test.dev
ErrorLog "logs/test.dev-error.log"
CustomLog "logs/test.dev-access.log" common
<Directory "G:\project\test.dev">
AllowOverride All
Options Indexes FollowSymLinks
Require local
</Directory>
</VirtualHost>
I fix the same problem by uncomment some lines in httpd.conf in Apache folder.
Uncomment lines below:
Include conf/extra/httpd-vhosts.conf
LoadModule vhost_alias_module modules/mod_vhost_alias.so
Save file and Restart your Apache and it will work.
Many thanks to this guy:
https://john-dugan.com/wamp-vhost-setup/
I am coming very late to this question, I did all what was mentioned by #RiggsFolly but one thing I changed made it to work instantly. I changed .dev to .test as .dev is reserved. hope this helps
Check out this modules uncommented in httpd.conf
proxy_module
proxy_http_module
try this on you apache httpd.config file:
<VirtualHost *:80>
ServerName mysite.dev
DocumentRoot "g:\wamp\www\mysite\public"
SetEnv APPLICATION_ENV "development"
<Directory "g:\wamp\www\mysite\public">
DirectoryIndex index.php
Options All Includes Indexes
Options All Indexes FollowSymLinks
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
restart your wamp server and put url like mysite.dev/ on you browser.
hope it will help you.
thank you.
I am trying to setup WordPress multi site on my ubuntu 10.04 laptop with apache2.
For normal WordPress installs in create an entry in the /etc/hosts file and create virtual hosts entry in /etc/apace2/sites-available directory and then soft link it to sites-enabled directory.
For sub domains, I added the server alias directive. But that is not doing anything. Do I have a syntax error. Please advice.
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName mysite.com
ServerAlias mysite.com *.mysite.com
DocumentRoot /home/myhome/Sites/public_html/mysite.com
#if using awstats
ScriptAlias /awstats/ /usr/lib/cgi-bin/
#we want specific log file for this server
CustomLog /var/log/apache2/example.com-access.log combined
</VirtualHost>
You must restart or reload Apache after making changes to your Apache configuration file. What does it tell you when you run:
sudo /etc/init.d/apache2 restart
Does it show you any error messages? That will tell you if you have a syntax error. For your reference, here is an example of using ServerAlias that I have on my own server. Note the difference between mine and yours. Maybe you should remove the initial mysite.com part and just leave *.mysite.com?
Let me know if that helps.
<VirtualHost *:80>
ServerAdmin jesse#domain.com
ServerAlias www.domain.com
DocumentRoot /var/www/vhosts/domain.com/httpdocs
ServerName domain.com
ErrorLog /var/log/domain.com-error_log
CustomLog /var/log/domain.com-access_log common
</VirtualHost>