网络学习之Apache http server get start
2014-02-26 15:28
246 查看
http://httpd.apache.org/docs/trunk/getting-started.html
If you're completely new to the Apache HTTP Server, or even to running a website at all, you might not know where to start, or what questions to ask. This document walks you through the basics.
Clients, Servers, and URLs
Hostnames and DNS
Configuration Files and Directives
Web Site Content
Log Files and Troubleshooting
What Else Do I Need To Know?
Comments
Client--->URLs---->Server
Server--->Response--->Client
URLs:
a) a protocol (e.g.
b) a servername (e.g.
c) a URL-path (e.g.
1) a file (like
2) a handler (like server-status)
3) some kind of program file (like
Site Content section.
d) possibly a query string (e.g.
response:
a) a status code
b) optionally, a response body.
Client--->DNS--->Server
DNS: serverName--->IP address
What's virtual hosts?
More than one hostname may point to the same IP address, and more than one IP address can be attached to the same physical server. Thus, you can run more than one web site on the same physical server, using a feature called virtual
hosts.
How to local testing?
If you are testing a server that is not Internet-accessible, you can put host names in your hosts file in order to do local resolution. For example, you might want to put a record in your hosts file to map a request for
your local system, for testing purposes. This entry would look like:
A hosts file will probably be located at
You can read more about the hosts file at Wikipedia.org/wiki/Hosts_(file), and more about DNS at Wikipedia.org/wiki/Domain_Name_System.
The Apache HTTP Server is configured via simple text files. These files may be located any of a variety of places, depending on how exactly you installed the server. Common locations for these files may be found in
the httpd wiki. If you installed httpd from source, the default location of the configuration files is
is usually called
The configuration is frequently broken into multiple smaller files, for ease of management. These files are loaded via the
The names or locations of these sub-files are not magical, and may vary greatly from one installation to another. Arrange and subdivide these files as makes the most sense to you. If the file arrangement you have by default doesn't make sense
to you, feel free to rearrange it.
The server is configured by placing configuration directives in these configuration files. A directive
is a keyword followed by one or more arguments that set its value.
The question of "Where should I put that directive?" is generally answered by considering where you want a directive to be effective. If it is a global setting, it should appear in the configuration file, outside of any
or other section. If it is to apply only to a particular directory, then it should go inside a
referring to that directory, and so on. See the Configuration Sections document for further discussion of
these sections.
In addition to the main configuration files, certain directives may go in
are primarily for people who do not have access to the main server configuration file(s). You can read more about
Web site content can take many different forms, but may be broadly divided into static and dynamic content.
Static content is things like HTML files, image files, CSS files, and other files that reside in the filesystem. The
specifies where in your filesystem you should place these files. This directive is either set globally, or per virtual host. Look in your configuration file(s) to determine how this is set for your server.
Typically, a document called
set to
be served to the client.
Dynamic content is anything that is generated at request time, and may change from one request to another.
There are numerous ways that dynamic content may be generated. Various handlersare available to generate
content. CGI programs may be written to generate content for your site.
Third-party modules like mod_php may be used to write code that does a variety of things. Many third-party applications, written using a variety of languages and tools, are available for download and installation on your Apache HTTP Server. Support of these
third-party things is beyond the scope of this documentation, and you should find their documentation or other support forums to answer your questions about them.
As an Apache HTTP Server administrator, your most valuable assets are the log files, and, in particular, the error log. Troubleshooting any problem without the error log is like driving with your eyes closed.
The location of the error log is defined by the
which may be set globally, or per virtual host. Entries in the error log tell you what went wrong, and when. They often also tell you how to fix it. Each error log message contains a error code, which you can search for online for even more detailed descriptions
of how to address the problem. You can also configure your error log to contain a log ID which you can then correlate to an access log entry, so that you can determine what request caused the error condition.
You can read more about logging in the logs documentation.
This document covers only the bare basics. We hope that this gets you started, but there are many other things that you might need to know. Here's a partial list of what you might be looking for:
Authentication and Authorization (password protecting resources)
Access Control
Setting up SSL
Frequently Asked Questions
If you're completely new to the Apache HTTP Server, or even to running a website at all, you might not know where to start, or what questions to ask. This document walks you through the basics.
Clients, Servers, and URLs
Hostnames and DNS
Configuration Files and Directives
Web Site Content
Log Files and Troubleshooting
What Else Do I Need To Know?
Comments
Clients, Servers, and URLs
Client--->URLs---->ServerServer--->Response--->Client
URLs:
a) a protocol (e.g.
http),
b) a servername (e.g.
www.apache.org),
c) a URL-path (e.g.
/docs/current/getting-started.html),
1) a file (like
getting-started.html)
2) a handler (like server-status)
3) some kind of program file (like
index.php). We'll discuss this more below in the Web
Site Content section.
d) possibly a query string (e.g.
?arg=value) used to pass additional arguments to the server.
response:
a) a status code
b) optionally, a response body.
Hostnames and DNS
Client--->DNS--->ServerDNS: serverName--->IP address
What's virtual hosts?
More than one hostname may point to the same IP address, and more than one IP address can be attached to the same physical server. Thus, you can run more than one web site on the same physical server, using a feature called virtual
hosts.
How to local testing?
If you are testing a server that is not Internet-accessible, you can put host names in your hosts file in order to do local resolution. For example, you might want to put a record in your hosts file to map a request for
www.example.comto
your local system, for testing purposes. This entry would look like:
127.0.0.1 www.example.com
A hosts file will probably be located at
/etc/hostsor
C:\Windows\system32\drivers\etc\hosts.
You can read more about the hosts file at Wikipedia.org/wiki/Hosts_(file), and more about DNS at Wikipedia.org/wiki/Domain_Name_System.
Configuration Files and Directives
The Apache HTTP Server is configured via simple text files. These files may be located any of a variety of places, depending on how exactly you installed the server. Common locations for these files may be found inthe httpd wiki. If you installed httpd from source, the default location of the configuration files is
/usr/local/apache2/conf. The default configuration file
is usually called
httpd.conf. This, too, can vary in third-party distributions of the server.
The configuration is frequently broken into multiple smaller files, for ease of management. These files are loaded via the
Includedirective.
The names or locations of these sub-files are not magical, and may vary greatly from one installation to another. Arrange and subdivide these files as makes the most sense to you. If the file arrangement you have by default doesn't make sense
to you, feel free to rearrange it.
The server is configured by placing configuration directives in these configuration files. A directive
is a keyword followed by one or more arguments that set its value.
The question of "Where should I put that directive?" is generally answered by considering where you want a directive to be effective. If it is a global setting, it should appear in the configuration file, outside of any
<Directory>,
<Location>,
<VirtualHost>,
or other section. If it is to apply only to a particular directory, then it should go inside a
<Directory>section
referring to that directory, and so on. See the Configuration Sections document for further discussion of
these sections.
In addition to the main configuration files, certain directives may go in
.htaccessfiles located in the content directories.
.htaccessfiles
are primarily for people who do not have access to the main server configuration file(s). You can read more about
.htaccessfiles in the
.htaccesshowto.
Web Site Content
Web site content can take many different forms, but may be broadly divided into static and dynamic content.Static content is things like HTML files, image files, CSS files, and other files that reside in the filesystem. The
DocumentRootdirective
specifies where in your filesystem you should place these files. This directive is either set globally, or per virtual host. Look in your configuration file(s) to determine how this is set for your server.
Typically, a document called
index.htmlwill be served when a directory is requested without a file name being specified. For example, if
DocumentRootis
set to
/var/www/htmland a request is made for
http://www.example.com/work/, the file
/var/www/html/work/index.htmlwill
be served to the client.
Dynamic content is anything that is generated at request time, and may change from one request to another.
There are numerous ways that dynamic content may be generated. Various handlersare available to generate
content. CGI programs may be written to generate content for your site.
Third-party modules like mod_php may be used to write code that does a variety of things. Many third-party applications, written using a variety of languages and tools, are available for download and installation on your Apache HTTP Server. Support of these
third-party things is beyond the scope of this documentation, and you should find their documentation or other support forums to answer your questions about them.
Log Files and Troubleshooting
As an Apache HTTP Server administrator, your most valuable assets are the log files, and, in particular, the error log. Troubleshooting any problem without the error log is like driving with your eyes closed.The location of the error log is defined by the
ErrorLogdirective,
which may be set globally, or per virtual host. Entries in the error log tell you what went wrong, and when. They often also tell you how to fix it. Each error log message contains a error code, which you can search for online for even more detailed descriptions
of how to address the problem. You can also configure your error log to contain a log ID which you can then correlate to an access log entry, so that you can determine what request caused the error condition.
You can read more about logging in the logs documentation.
What Else Do I Need To Know?
This document covers only the bare basics. We hope that this gets you started, but there are many other things that you might need to know. Here's a partial list of what you might be looking for:Authentication and Authorization (password protecting resources)
Access Control
Setting up SSL
Frequently Asked Questions
相关文章推荐
- java apache commons HttpClient发送get和post请求的学习整理(转)
- java apache commons HttpClient发送get和post请求的学习整理
- tomcat集群学习记录1--初识apache http server
- java apache commons HttpClient发送get和post请求的学习整理
- java apache commons HttpClient发送get和post请求的学习整理
- java apache commons HttpClient发送get和post请求的学习整理
- Windows下安装Apache HTTP Server 无法启动遇到OS10048 通常每个套接字地址(协议/网络地址/端口)只允许使用一次 的问题解决方法
- java apache commons HttpClient发送get和post请求的学习整理
- HTTP 错误 500.0 - Internal Server Error 调用 GetFilterVersion 失败,在 ISAPI 筛选器 "D:\apache-tomcat-6.0.20\co
- java apache commons HttpClient发送get和post请求的学习整理
- IOS学习 网络HTTP Get和Post请求与登录界面加密 涉及按钮边框圆角与颜色设置
- 马哥Linux培训学习――编译安装Apache HTTP Server 2.4.10
- java apache commons HttpClient发送get和post请求的学习整理
- Weblogic 12c 的 Apache HTTP Server 整合插件(Plug-In)下载地址
- 在apache http server中配置虚拟机和虚拟路径的方法
- Android学习第4天,网络编程,http
- 第一季:Tomcat 8迷情】 第7集 apache http server+tomcat+mod_jk在linux上的负载均衡配置
- 网络爬虫学习笔记——GET方法下几种常用情况
- 【转】iOS学习笔记(八)——iOS网络通信http之NSURLConnection
- Apache HTTP Server 2.4编译安装及其新特性(四)