[html]
Capture Image:
Capture Audio:
Capture Video:
[/html]
[html]
Capture Image:
Capture Audio:
Capture Video:
[/html]
location.href=document.referrer
原文地址:http://httpd.apache.org/docs/2.2/vhosts/examples.html
This document attempts to answer the commonly-asked questions about setting up virtual hosts. These scenarios are those involving multiple web sites running on a single server, via name-based or IP-based virtual hosts.
Virtual_host
and mod_proxy together_default_
vhostsServerPath
directiveYour server has a single IP address, and multiple aliases (CNAMES) point to this machine in DNS. You want to run a web server for www.example.com
and www.example.org
on this machine.
Creating virtual host configurations on your Apache server does not magically cause DNS entries to be created for those host names. You must have the names in DNS, resolving to your IP address, or nobody else will be able to see your web site. You can put entries in your hosts
file for local testing, but that will work only from the machine with those hosts entries.
# Ensure that Apache listens on port 80
Listen 80
# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/example2
ServerName www.example.org
# Other directives here
</VirtualHost>
The asterisks match all addresses, so the main server serves no requests. Due to the fact that www.example.com
is first in the configuration file, it has the highest priority and can be seen as the default or primary server. That means that if a request is received that does not match one of the specified ServerName
directives, it will be served by this first VirtualHost
.
You can, if you wish, replace *
with the actual IP address of the system. In that case, the argument to VirtualHost
must match the argument toNameVirtualHost
:
NameVirtualHost 172.20.30.40
<VirtualHost 172.20.30.40>
# etc …
However, it is additionally useful to use *
on systems where the IP address is not predictable – for example if you have a dynamic IP address with your ISP, and you are using some variety of dynamic DNS solution. Since *
matches any IP address, this configuration would work without changes whenever your IP address changes.
The above configuration is what you will want to use in almost all name-based virtual hosting situations. The only thing that this configuration will not work for, in fact, is when you are serving different content based on differing IP addresses or ports.
Any of the techniques discussed here can be extended to any number of IP addresses.
The server has two IP addresses. On one (172.20.30.40
), we will serve the “main” server, server.domain.com
and on the other (172.20.30.50
), we will serve two or more virtual hosts.
Listen 80
# This is the “main” server running on 172.20.30.40
ServerName server.domain.com
DocumentRoot /www/mainserver
# This is the other address
NameVirtualHost 172.20.30.50
<VirtualHost 172.20.30.50>
DocumentRoot /www/example1
ServerName www.example.com
# Other directives here …
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example.org
# Other directives here …
</VirtualHost>
Any request to an address other than 172.20.30.50
will be served from the main server. A request to 172.20.30.50
with an unknown hostname, or no Host:
header, will be served from www.example.com
.
The server machine has two IP addresses (192.168.1.1
and 172.20.30.40
). The machine is sitting between an internal (intranet) network and an external (internet) network. Outside of the network, the name server.example.com
resolves to the external address (172.20.30.40
), but inside the network, that same name resolves to the internal address (192.168.1.1
).
The server can be made to respond to internal and external requests with the same content, with just one VirtualHost
section.
NameVirtualHost 192.168.1.1
NameVirtualHost 172.20.30.40
<VirtualHost 192.168.1.1 172.20.30.40>
DocumentRoot /www/server1
ServerName server.example.com
ServerAlias server
</VirtualHost>
Now requests from both networks will be served from the same VirtualHost
.
On the internal network, one can just use the name server
rather than the fully qualified host name server.example.com
.
Note also that, in the above example, you can replace the list of IP addresses with *
, which will cause the server to respond the same on all addresses.
You have multiple domains going to the same IP and also want to serve multiple ports. By defining the ports in the “NameVirtualHost” tag, you can allow this to work. If you try using <VirtualHost name:port> without the NameVirtualHost name:port or you try to use the Listen directive, your configuration will not work.
Listen 80
Listen 8080
NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080
<VirtualHost 172.20.30.40:80>
ServerName www.example.com
DocumentRoot /www/domain-80
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.com
DocumentRoot /www/domain-8080
</VirtualHost>
<VirtualHost 172.20.30.40:80>
ServerName www.example.org
DocumentRoot /www/otherdomain-80
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
ServerName www.example.org
DocumentRoot /www/otherdomain-8080
</VirtualHost>
The server has two IP addresses (172.20.30.40
and 172.20.30.50
) which resolve to the names www.example.com
and www.example.org
respectively.
Listen 80
<VirtualHost 172.20.30.40>
DocumentRoot /www/example1
ServerName www.example.com
</VirtualHost>
<VirtualHost 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example.org
</VirtualHost>
Requests for any address not specified in one of the <VirtualHost>
directives (such as localhost
, for example) will go to the main server, if there is one.
The server machine has two IP addresses (172.20.30.40
and 172.20.30.50
) which resolve to the names www.example.com
and www.example.org
respectively. In each case, we want to run hosts on ports 80 and 8080.
Listen 172.20.30.40:80
Listen 172.20.30.40:8080
Listen 172.20.30.50:80
Listen 172.20.30.50:8080
<VirtualHost 172.20.30.40:80>
DocumentRoot /www/example1-80
ServerName www.example.com
</VirtualHost>
<VirtualHost 172.20.30.40:8080>
DocumentRoot /www/example1-8080
ServerName www.example.com
</VirtualHost>
<VirtualHost 172.20.30.50:80>
DocumentRoot /www/example2-80
ServerName www.example.org
</VirtualHost>
<VirtualHost 172.20.30.50:8080>
DocumentRoot /www/example2-8080
ServerName www.example.org
</VirtualHost>
On some of my addresses, I want to do name-based virtual hosts, and on others, IP-based hosts.
Listen 80
NameVirtualHost 172.20.30.40
<VirtualHost 172.20.30.40>
DocumentRoot /www/example1
ServerName www.example.com
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/example2
ServerName www.example.org
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/example3
ServerName www.example3.net
</VirtualHost>
# IP-based
<VirtualHost 172.20.30.50>
DocumentRoot /www/example4
ServerName www.example4.edu
</VirtualHost>
<VirtualHost 172.20.30.60>
DocumentRoot /www/example5
ServerName www.example5.gov
</VirtualHost>
Virtual_host
and mod_proxy togetherThe following example allows a front-end machine to proxy a virtual host through to a server running on another machine. In the example, a virtual host of the same name is configured on a machine at 192.168.111.2
. The ProxyPreserveHost On
directive is used so that the desired hostname is passed through, in case we are proxying multiple hostnames to a single machine.
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://192.168.111.2/
ProxyPassReverse / http://192.168.111.2/
ServerName hostname.example.com
</VirtualHost>
_default_
vhosts_default_
vhosts for all portsCatching every request to any unspecified IP address and port, i.e., an address/port combination that is not used for any other virtual host.
<VirtualHost _default_:*>
DocumentRoot /www/default
</VirtualHost>
Using such a default vhost with a wildcard port effectively prevents any request going to the main server.
A default vhost never serves a request that was sent to an address/port that is used for name-based vhosts. If the request contained an unknown or no Host:
header it is always served from the primary name-based vhost (the vhost for that address/port appearing first in the configuration file).
You can use AliasMatch
or RewriteRule
to rewrite any request to a single information page (or script).
_default_
vhosts for different portsSame as setup 1, but the server listens on several ports and we want to use a second _default_
vhost for port 80.
<VirtualHost _default_:80>
DocumentRoot /www/default80
# ...
</VirtualHost>
<VirtualHost _default_:*>
DocumentRoot /www/default
# …
</VirtualHost>
The default vhost for port 80 (which must appear before any default vhost with a wildcard port) catches all requests that were sent to an unspecified IP address. The main server is never used to serve a request.
_default_
vhosts for one portWe want to have a default vhost for port 80, but no other default vhosts.
<VirtualHost _default_:80>
DocumentRoot /www/default
...
</VirtualHost>
A request to an unspecified address on port 80 is served from the default vhost. Any other request to an unspecified address and port is served from the main server.
The name-based vhost with the hostname www.example.org
(from our name-based example, setup 2) should get its own IP address. To avoid problems with name servers or proxies who cached the old IP address for the name-based vhost we want to provide both variants during a migration phase.
The solution is easy, because we can simply add the new IP address (172.20.30.50
) to the VirtualHost
directive.
Listen 80
ServerName www.example.com
DocumentRoot /www/example1
NameVirtualHost 172.20.30.40
<VirtualHost 172.20.30.40 172.20.30.50>
DocumentRoot /www/example2
ServerName www.example.org
# …
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/example3
ServerName www.example.net
ServerAlias *.example.net
# …
</VirtualHost>
The vhost can now be accessed through the new address (as an IP-based vhost) and through the old address (as a name-based vhost).
ServerPath
directiveWe have a server with two name-based vhosts. In order to match the correct virtual host a client must send the correct Host:
header. Old HTTP/1.0 clients do not send such a header and Apache has no clue what vhost the client tried to reach (and serves the request from the primary vhost). To provide as much backward compatibility as possible we create a primary vhost which returns a single page containing links with an URL prefix to the name-based virtual hosts.
NameVirtualHost 172.20.30.40
<VirtualHost 172.20.30.40>
# primary vhost
DocumentRoot /www/subdomain
RewriteEngine On
RewriteRule ^/.* /www/subdomain/index.html
# …
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/subdomain/sub1
ServerName www.sub1.domain.tld
ServerPath /sub1/
RewriteEngine On
RewriteRule ^(/sub1/.*) /www/subdomain$1
# …
</VirtualHost>
<VirtualHost 172.20.30.40>
DocumentRoot /www/subdomain/sub2
ServerName www.sub2.domain.tld
ServerPath /sub2/
RewriteEngine On
RewriteRule ^(/sub2/.*) /www/subdomain$1
# …
</VirtualHost>
Due to the ServerPath
directive a request to the URL http://www.sub1.domain.tld/sub1/
is always served from the sub1-vhost.
A request to the URL http://www.sub1.domain.tld/
is only served from the sub1-vhost if the client sent a correct Host:
header. If no Host:
header is sent the client gets the information page from the primary host.
Please note that there is one oddity: A request to http://www.sub2.domain.tld/sub1/
is also served from the sub1-vhost if the client sent no Host:
header.
The RewriteRule
directives are used to make sure that a client which sent a correct Host:
header can use both URL variants, i.e., with or without URL prefix.
Mac下的Apache环境配置了Vhosts后报错:You don’t have permission to access on this server.
检查Vhosts的目录(或上层目录,需要检查多层,一层一层向上检查)是否有Others的x权限
若没有,则通过命令chmod o+x xxxxx来添加上
找到httpd.conf文件中的下面一行,注释掉。
#AddDefaultCharset UTF-8
可能有两个原因,但是都出在php.ini中。
1. 检查配置文件中对上传文件大小的限制,上传的文件是否超过了此限制。
2. 检查配置文件中上传文件临时目录的设置,默认的是“C:\Windows\Temp”。可配置为“C:\temp”,并记得在C盘下建立一个temp文件夹。
php.ini
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir =”c:/temp”
强制当前标识值为 30
下例强制 jobs 表中的当前标识值为 30。
USE pubs
GO
DBCC CHECKIDENT (jobs, RESEED, 30)
GO
我个人以为学好C++,Java也就是举手之劳。但是C++的学习曲线相当的陡。不过,我觉得C++是最需要学好的语言了。参看两篇趣文”C++学习信心图” 和”21天学好C++”
C++和Java都不是能在短时间内能学好的,C++玩是的深,Java玩的是广,我建议两者选一个。我个人的学习经历是:
曾来信问我学习编程问题的朋友们,几乎都有一个疑问,就是诸如”学C++好还是JAVA好?还是VB容易入门好?还是C#新潮点好?”这样的语言选择问题。这个问题几乎存在于每个初学者身上。其实,我是这样理解这个问题的,”学习哪门语言并不重要,它们哪个都好!只要你能通过任何一门语言理解了编程的思想和概念,然后你就能一通百通了。”因为我自己切身的经历就是这样。我在学校时我只会VB和一点C++,在校期间几乎没怎么接触过Java,但我毕业后找的第一份工作却是Java的。我在学习Java的过程中并没有看过任何一本Java的书,只是参考一下别人的代码、例子,一下子自己也就能上手了。当然,现在在Java方面我只能算是一个菜鸟,但起码能胜任现在的工作了。相信高手们应该也有这样的感觉的吧,举一反三,一通百通。
C++开发环境的搭建主要分三个步骤:
第一、Visual Studio 6.0,这个就是VC++的编程软件。
第二、MSDN:其实就是一个帮助文档,里面有VC++编程中各种函数等用法的详细介绍,是VC++学习和实际VC++编程中必不可少的工具。
第三、Visual Assist X,也简称VA。由于Visual Studio 6.0自身的代码提示功能很弱,所以这个工具就是用来增强Visual Studio 6.0的代码提示功能的。
下面给出上述软件的下载地址。
Visual C++是一个功能强大的可视化软件开发工具。自1993年Microsoft公司推出Visual C++1.0后,随着其新版本的不断问世,Visual C++已成为专业程序员进行软件开发的首选工具。Visual C++6.0不仅是一个C++编译器,而且是一个基于Windows操作系统的可视化集成开发环境(integrated development environment,IDE)。Visual C++6.0由许多组件组成,包括编辑器、调试器以及程序向导AppWizard、类向导Class Wizard等开发工具。 这些组件通过一个名为Developer Studio的组件集成为和谐的开发环境。
MSDN Library是Microsoft当前提供的有关编程信息的最全面的资源,包含上千兆字节的开发人员所必须的信息,文档事例代码,技术文章等等,可提供全世界的开发者使用。它集中了最新信息,可以提高你的生产率,并帮助你将Microsoft最新的技术集成到自己的解决方案中。欢迎使用Visual Studio 6.0版的MSDN Library,全名是Microsoft Developet Network,是Microsoft公司为开发人员提供所需的工具,技术,培训,事件,以及其他一些技术资料的主要项目。在Visual Studio 6.0版MSDN Library中,MSDN Content Development组建了带有完整Helpdesk示例的版本,该示例应用程序共有二万四千行。它说明了如何建立一个灵活的分布式网络应用程序,并且包含了超过1.1GB的编程技术信息,其中包括示例代码,开发人员知识库,Visual Studio文档,SDK文档,技术文章,会议及技术讲座论文,以及技术规范等。下载页面:
http://www.verycd.com/topics/68210/或http://www.verycd.com/topics/35744/
CDKEY:111-1111111
下载地址:http://dl.dbank.com/c0ru2q9mwu
或查看本博客关于Visual Assist X的文章:http://blog.renrenstudy.com/cpp/vc-ide-visual-assist-x/
VS2008 注册方法:VS2008注册方法非常简单,在开始>设置>控制面版>添加或删除程序>卸载vs.net2008(名字不太记得了)>出现卸载界面>点击Next>输入上面CD-key ->出现成功画面即可完美将试用版升级成为正式版。
VS2008正式版序列号CDKEY:PYHYP-WXB3B-B2CCM-V9DX9-VDY8T
Visual Studio官方下载页面: http://msdn.microsoft.com/zh-cn/vstudio/bb984878
我也是跟着这个视频教程学习的,给大家尤其是C++学习的新手朋友说一下我学习这个视频教程时的一点经验和心得:
1、切记:一定不要只看不动手。学编程,就是要跟着敲代码,尤其是新手,代码一点不懂?没关系,敲着敲着就懂了。
2、这个视频的前三集是有关VC及MFC框架机制的问题,有些地方很晦涩,没必要因为不懂就丧失信心,完全可以先往后看,因为从第四集开始就开始学习很直观的东西,可以学完后面的东西之后再回过头来理解前三集的内容。
看完第一遍之后,一般都会感觉什么都听得差不多明白了,但真是马上去编程序又不知道从哪儿入手。我的建议是,从最简单的例子入手,比如一个简单的计算器程序,在哪里卡住了就去视频里找到相应的地方解决问题,或者就去百度一下。一旦一个例子完成了,再完成其他稍微难点的例子也不成问题了。
在有了一段时间的编程实践之后,如果感觉不知道该继续深入学习了,可以再重新重头看一遍这套视频。根据我的切身体会,你会再这个重新学习的过程中收获颇丰。我就是在重新看的时候,对操作系统有了新的理解。
实现思路:
添加Windows计划任务,每隔一分钟执行一次编写的程序。在该程序中,首先判断网络是否正常。若正常,则关闭程序;若不正常,则重新打开xClient程序,并触发其“触发认证”按钮及隐藏窗口,而后关闭本程序。
1、在VS2008中,创建控制台应用程序。
2、Program.cs
[csharp]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Diagnostics;
using System.Net.NetworkInformation;
using System.Threading;
namespace AlwaysOnline
{
class Program
{
[DllImport(“user32.dll”, EntryPoint = “FindWindow”, CharSet = CharSet.Auto)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport(“user32.dll”, EntryPoint = “FindWindowEx”, CharSet = CharSet.Auto)]
extern static IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport(“User32.dll”, EntryPoint = “SendMessage”)]
private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
static void Main(string[] args)
{
if (!isNetConnected()) connect();
}
///
private static void connect()
{
string path = “D:\\Program Files\\xClient\\xClient.exe”;
Process p = Process.Start(path);
if (p == null)
Console.WriteLine(“Warning:process may already exist”);
Console.WriteLine(“Finding main window handle”);
IntPtr mainWindows = FindMainWindowHandle(“xClient 802.1x 客户端”, 100, 25);
Console.WriteLine(“Handle to main window is ” + mainWindows);
//有名字控件句柄
Console.WriteLine(“Findding handle to button1”);
IntPtr butt = FindWindowEx(mainWindows, IntPtr.Zero, null, “触发认证”); // 找到按钮
IntPtr butt1 = FindWindowEx(mainWindows, IntPtr.Zero, null, “隐藏窗口”); // 找到按钮
if (butt == IntPtr.Zero)
throw new Exception(“Unable to find button1”);
else
Console.WriteLine(“Handle to button1 is ” + butt);
//SendMessage(mainWindows, 0X101, butt, null);
SendMessage(butt, 0x201, butt, null); // 左键按下
SendMessage(butt, 0x202, butt, null); // 左键弹起
SendMessage(butt1, 0x201, butt1, null); // 左键按下
SendMessage(butt1, 0x202, butt1, null); // 左键弹起
//没有名字或者重名控件
//Console.WriteLine(“Findding handle to listbox1”);
//IntPtr lb = FindWindowByIndex(mwh, 3);
//if (lb == IntPtr.Zero)
// throw new Exception(“Unable to find listbox1”);
//else
// Console.WriteLine(“Handle to listbox1 is ” + lb);
}
///
///
private static bool isNetConnected()
{
Ping p = new Ping();
PingReply pr1 = p.Send(“8.8.8.8”, 5000);
return pr1.Status == IPStatus.Success;
}
//通过索引查找相应控件句柄
static IntPtr FindWindowByIndex(IntPtr hwndParent, int index)
{
if (index == 0)
{
return hwndParent;
}
else
{
int ct = 0;
IntPtr result = IntPtr.Zero;
do
{
result = FindWindowEx(hwndParent, result, null, null);
if (result != IntPtr.Zero)
{
++ct;
}
} while (ct < index && result != IntPtr.Zero);
return result;
}
}
//获得待测程序主窗体句柄
private static IntPtr FindMainWindowHandle(string caption, int delay, int maxTries)
{
IntPtr mwh = IntPtr.Zero;
bool formFound = false;
int attempts = 0;
while (!formFound && attempts < maxTries)
{
if (mwh == IntPtr.Zero)
{
Console.WriteLine("Form not yet found");
Thread.Sleep(delay);
++attempts;
mwh = FindWindow(null, caption);
}
else
{
Console.WriteLine("Form has been found");
formFound = true;
}
}
if (mwh == IntPtr.Zero)
throw new Exception("Could not find main window");
else
return mwh;
}
}
}
[/csharp]
3、因为程序每分钟要触发一次,而控制台应用程序默认会显示黑色命令行窗口,因而为了在程序运行时不显示该窗口,参看本博客另外一篇文章《C# 控制台应用程序如何不弹出窗口》。
4、添加Windows计划任务
1) 将上一步生成的程序保存到某个位置,而后在控制面板中添加计划任务。
2) 在计划任务中,选择生成的程序,并选择“每天”执行,起始时间设置为“00:00”;
3) 创建该计划任务完成后,右键该任务选择属性,在高级选项中,做如下设置