返回列表 回复 发帖

手把手教你建立Win32环境下的Apache Web服务器(1)

<STRONG><FONT color=#dc143c>手把手教你建立Win32环境下的Apache Web服务器</FONT></STRONG><FONT color=#555555> <BR><BR></FONT><FONT color=#00008b>我们的目标:</FONT><FONT color=#555555> <BR>在Win32环境下建立Web服务器,可以运行CGI程序及PHP脚本程序,如果需要,还可以使用MySql数据库,要有良好的可移植性,廉价(最好是免费),这样即使我们的网站有了名气也不会出现版权问题。 <BR><BR></FONT><FONT color=#00008b>准备必要的软件:</FONT><FONT color=#555555> <BR><BR>Windows 2000 Pro <BR>因为我们要建立服务器,所以不能使用Win9x类的系统,我们要的是稳定高效,但是你只是玩玩我也不管,下面都以Win2000pro为准。 <BR><BR>Apache 2.0.45 (注:我的安装路径C:\Apache) <BR>我们的Web服务器主角,最新版本2.0.45,性能不逊色于IIS,甚至在某些方面远超过IIS,虽然在Win32系统上不能完全发挥Apache的优越性能,但是也不会比IIS差。 <BR><BR>ActivePerl 5.8.0.802 (注:我的安装路径C:\USR) <BR>运行Perl程序及CGI程序我们必须要用这个解释器。 <BR><BR>HP 4.3.1 (注:我的安装路径C:\PHP) <BR>HP脚本的解释器,PHP语言具有很好的可移植性。 <BR><BR>MySql 4.0.12 (注:我的安装路径C:\MySql) <BR>应用最广泛的免费数据库,功能虽然没有MSSQL多,但是速度及稳定性非常好。 <BR><BR></FONT><FONT color=#00008b>开始安装:</FONT><FONT color=#555555> <BR>   软有软件安装都很简单,只要按照提示安装就可以了,需要说明的是一般的CGI程序默认Perl解释路径是/usr/bin/perl,所以安装ActivePerl的时候不要用软件默认的路径,安装在C:\usr下,那么你的CGI程序一般都不用修改就可以直接运行了,还有我是修改Apache2的安装路径为c:\Apahce的,我觉得这样比较习惯。 <BR>   你说你不懂英文?看不懂安装信息?kao!那你还混个P呀!呵呵,其实我英文也很差劲,没什么只要能看懂路径位置知道修改就可以了,其他的都用默认的,一直下一步直到完成。 <BR><BR></FONT><FONT color=#00008b>服务器设置:</FONT><FONT color=#555555> <BR>   如果你成功安装了这些软件,那么Apache已经可以运行了,但是只能提供基本的Web服务,所以我们还要修改配置文件让我们的主机可以运行脚本。 <BR><BR>   打开C:\Apache\conf文件夹下的httpd.conf文件,这个就是Apache的配置文件了,所有的设置都在这一个文件里面完成,不详细说明里面的配置了,只要注意下面红字部分的改动或添加的蓝字内容就可以,以下是我的httpd.conf文件全内容(呵呵,偷懒没有详细说明),只要参照修改就可以了,记得修改完成,要重新启动Apache才会生效。 <BR></FONT><FONT color=#a52a2a>(注:我的/文件夹D:\root\www,/cgi-bin/文件夹D:\root\cgi-bin,如果你不想和我的一样,请调整相关设置)</FONT><FONT color=#555555> <BR><BR><BR># <BR># Based upon the NCSA server configuration files originally by Rob McCool. <BR># <BR># This is the main Apache server configuration file.  It contains the <BR># configuration directives that give the server its instructions. <BR># See <URL:http://httpd.apache.org/docs-2.0/> for detailed information about <BR># the directives. <BR># <BR># Do NOT simply read the instructions in here without understanding <BR># what they do.  They're here only as hints or reminders.  If you are unsure <BR># consult the online docs. You have been warned.   <BR># <BR># The configuration directives are grouped into three basic sections: <BR>#  1. Directives that control the operation of the Apache server process as a <BR>#     whole (the 'global environment'). <BR>#  2. Directives that define the parameters of the 'main' or 'default' server, <BR>#     which responds to requests that aren't handled by a virtual host. <BR>#     These directives also provide default values for the settings <BR>#     of all virtual hosts. <BR>#  3. Settings for virtual hosts, which allow Web requests to be sent to <BR>#     different IP addresses or hostnames and have them handled by the <BR>#     same Apache server process. <BR># <BR># Configuration and logfile names: If the filenames you specify for many <BR># of the server's control files begin with "/" (or "drive:/" for Win32), the <BR># server will use that explicit path.  If the filenames do *not* begin <BR># with "/", the value of ServerRoot is prepended -- so "logs/foo.log" <BR># with ServerRoot set to "C:/Apache" will be interpreted by the <BR># server as "C:/Apache/logs/foo.log". <BR># <BR># NOTE: Where filenames are specified, you must use forward slashes <BR># instead of backslashes (e.g., "c:/apache" instead of "c:\apache"). <BR># If a drive letter is omitted, the drive on which Apache.exe is located <BR># will be used by default.  It is recommended that you always supply <BR># an explicit drive letter in absolute paths, however, to avoid <BR># confusion. <BR># <BR><BR>### Section 1: Global Environment <BR># <BR># The directives in this section affect the overall operation of Apache, <BR># such as the number of concurrent requests it can handle or where it <BR># can find its configuration files. <BR># <BR><BR># <BR># ServerRoot: The top of the directory tree under which the server's <BR># configuration, error, and log files are kept. <BR># <BR># NOTE!  If you intend to place this on an NFS (or otherwise network) <BR># mounted filesystem then please read the LockFile documentation (available <BR># at <URL:http://httpd.apache.org/docs-2.0/mod/mpm_common.html#lockfile>); <BR># you will save yourself a lot of trouble. <BR># <BR># Do NOT add a slash at the end of the directory path. <BR># <BR></FONT><FONT color=#a52a2a>ServerRoot "C:/Apache"</FONT><FONT color=#555555> <BR><BR># <BR># ScoreBoardfile: File used to store internal server process information. <BR># If unspecified (the default), the scoreboard will be stored in an <BR># anonymous shared memory segment, and will be unavailable to third-party <BR># applications. <BR># If specified, ensure that no two invocations of Apache share the same <BR># scoreboard file. The scoreboard file MUST BE STORED ON A LOCAL DISK. <BR># <BR>#ScoreBoardFile logs/apache_runtime_status <BR><BR># <BR># Pidfile: The file in which the server should record its process <BR># identification number when it starts. <BR># <BR>idFile logs/httpd.pid <BR><BR># <BR># Timeout: The number of seconds before receives and sends time out. <BR># <BR>Timeout 300 <BR><BR># <BR># KeepAlive: Whether or not to allow persistent connections (more than <BR># one request per connection). Set to "Off" to deactivate. <BR># <BR>KeepAlive On <BR><BR># <BR># MaxKeepAliveRequests: The maximum number of requests to allow <BR># during a persistent connection. Set to 0 to allow an unlimited amount. <BR># We recommend you leave this number high, for maximum performance. <BR># <BR>MaxKeepAliveRequests 100 <BR><BR># <BR># KeepAliveTimeout: Number of seconds to wait for the next request from the <BR># same client on the same connection. <BR># <BR>KeepAliveTimeout 15 <BR><BR>## <BR>## Server-Pool Size Regulation (MPM specific) <BR>## <BR><BR># WinNT MPM <BR># ThreadsPerChild: constant number of worker threads in the server process <BR># MaxRequestsPerChild: maximum  number of requests a server process serves <BR><IfModule mpm_winnt.c> <BR>ThreadsPerChild 250 <BR>MaxRequestsPerChild  0 <BR></IfModule> <BR><BR># <BR># Listen: Allows you to bind Apache to specific IP addresses and/or <BR># ports, instead of the default. See also the <VirtualHost> <BR># directive. <BR># <BR># Change this to Listen on specific IP addresses as shown below to <BR># prevent Apache from glomming onto all bound IP addresses (0.0.0.0) <BR># <BR>#Listen 12.34.56.78:80 <BR>Listen 80 <BR><BR># <BR># Dynamic Shared Object (DSO) Support <BR># <BR># To be able to use the functionality of a module which was built as a DSO you <BR># have to place corresponding `LoadModule' lines at this location so the <BR># directives contained in it are actually available _before_ they are used. <BR># Statically compiled modules (those listed by `httpd -l') do not need <BR># to be loaded here. <BR># <BR># Example: <BR># LoadModule foo_module modules/mod_foo.so <BR># <BR>LoadModule access_module modules/mod_access.so <BR>LoadModule actions_module modules/mod_actions.so <BR>LoadModule alias_module modules/mod_alias.so <BR>LoadModule asis_module modules/mod_asis.so <BR>LoadModule auth_module modules/mod_auth.so <BR>#LoadModule auth_anon_module modules/mod_auth_anon.so <BR>#LoadModule auth_dbm_module modules/mod_auth_dbm.so <BR>#LoadModule auth_digest_module modules/mod_auth_digest.so <BR>LoadModule autoindex_module modules/mod_autoindex.so <BR>#LoadModule cern_meta_module modules/mod_cern_meta.so <BR>LoadModule cgi_module modules/mod_cgi.so <BR>#LoadModule dav_module modules/mod_dav.so <BR>#LoadModule dav_fs_module modules/mod_dav_fs.so <BR>LoadModule dir_module modules/mod_dir.so <BR>LoadModule env_module modules/mod_env.so <BR>#LoadModule expires_module modules/mod_expires.so <BR>#LoadModule file_cache_module modules/mod_file_cache.so <BR>#LoadModule headers_module modules/mod_headers.so <BR>LoadModule imap_module modules/mod_imap.so <BR>LoadModule include_module modules/mod_include.so <BR>#LoadModule info_module modules/mod_info.so <BR>LoadModule isapi_module modules/mod_isapi.so <BR>LoadModule log_config_module modules/mod_log_config.so <BR>LoadModule mime_module modules/mod_mime.so <BR>#LoadModule mime_magic_module modules/mod_mime_magic.so <BR>#LoadModule proxy_module modules/mod_proxy.so <BR>#LoadModule proxy_connect_module modules/mod_proxy_connect.so <BR>#LoadModule proxy_http_module modules/mod_proxy_http.so <BR>#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so <BR>LoadModule negotiation_module modules/mod_negotiation.so <BR>#LoadModule rewrite_module modules/mod_rewrite.so <BR>LoadModule setenvif_module modules/mod_setenvif.so <BR>#LoadModule speling_module modules/mod_speling.so <BR>#LoadModule status_module modules/mod_status.so <BR>#LoadModule unique_id_module modules/mod_unique_id.so <BR>LoadModule userdir_module modules/mod_userdir.so <BR>#LoadModule usertrack_module modules/mod_usertrack.so <BR>#LoadModule vhost_alias_module modules/mod_vhost_alias.so <BR>#LoadModule ssl_module modules/mod_ssl.so <BR><BR># <BR># ExtendedStatus controls whether Apache will generate "full" status <BR># information (ExtendedStatus On) or just basic information (ExtendedStatus <BR># Off) when the "server-status" handler is called. The default is Off. <BR># <BR>#ExtendedStatus On <BR><BR>### Section 2: 'Main' server configuration <BR># <BR># The directives in this section set up the values used by the 'main' <BR># server, which responds to any requests that aren't handled by a <BR># <VirtualHost> definition.  These values also provide defaults for <BR># any <VirtualHost> containers you may define later in the file. <BR># <BR># All of these directives may appear inside <VirtualHost> containers, <BR># in which case these default settings will be overridden for the <BR># virtual host being defined. <BR># <BR><BR># <BR># ServerAdmin: Your address, where problems with the server should be <BR># e-mailed.  This address appears on some server-generated pages, such <BR># as error documents.  e.g. admin@your-domain.com <BR># <BR>ServerAdmin webmaster@localhost <BR><BR># <BR># ServerName gives the name and port that the server uses to identify itself. <BR># This can often be determined automatically, but we recommend you specify <BR># it explicitly to prevent problems during startup. <BR># <BR># If this is not set to valid DNS name for your host, server-generated <BR># redirections will not work.  See also the UseCanonicalName directive. <BR># <BR># If your host doesn't have a registered DNS name, enter its IP address here. <BR># You will have to access it by its address anyway, and this will make <BR># redirections work in a sensible way. <BR># <BR></FONT><FONT color=#a52a2a>ServerName localhost:80</FONT><FONT color=#555555> <BR><BR># <BR># UseCanonicalName: Determines how Apache constructs self-referencing <BR># URLs and the SERVER_NAME and SERVER_PORT variables. <BR># When set "Off", Apache will use the Hostname and Port supplied <BR># by the client.  When set "On", Apache will use the value of the <BR># ServerName directive. <BR># <BR>UseCanonicalName Off <BR><BR># <BR># DocumentRoot: The directory out of which you will serve your <BR># documents. By default, all requests are taken from this directory, but <BR># symbolic links and aliases may be used to point to other locations. <BR># <BR></FONT><FONT color=#dc143c>DocumentRoot "D:/root/www"</FONT><FONT color=#555555> <BR><BR># <BR># Each directory to which Apache has access can be configured with respect <BR># to which services and features are allowed and/or disabled in that <BR># directory (and its subdirectories). <BR># <BR># First, we configure the "default" to be a very restrictive set of <BR># features.   <BR># <BR><Directory /> <BR>   Options FollowSymLinks <BR>   AllowOverride None <BR></Directory> <BR><BR># <BR># Note that from this point forward you must specifically allow <BR># particular features to be enabled - so if something's not working as <BR># you might expect, make sure that you have specifically enabled it <BR># below. <BR># <BR><BR># <BR># This should be changed to whatever you set DocumentRoot to. <BR># <BR></FONT><FONT color=#dc143c><Directory "D:/root/www"></FONT><FONT color=#555555> <BR><BR># <BR># Possible values for the Options directive are "None", "All", <BR># or any combination of: <BR>#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews <BR># <BR># Note that "MultiViews" must be named *explicitly* --- "Options All" <BR># doesn't give it to you. <BR># <BR># The Options directive is both complicated and important.  Please see <BR># </FONT><A href="http://httpd.apache.org/docs-2.0/mod/core.html#options" target=_blank>http://httpd.apache.org/docs-2.0/mod/core.html#options</A><FONT color=#555555> <BR># for more information. <BR># <BR>   Options Indexes FollowSymLinks <BR><BR># <BR># AllowOverride controls what directives may be placed in .htaccess files. <BR># It can be "All", "None", or any combination of the keywords: <BR>#   Options FileInfo AuthConfig Limit <BR># <BR>   AllowOverride None <BR><BR># <BR># Controls who can get stuff from this server. <BR># <BR>   Order allow,deny <BR>   Allow from all <BR><BR></Directory> <BR><BR># <BR># UserDir: The name of the directory that is appended onto a user's home <BR># directory if a ~user request is received.  Be especially careful to use <BR># proper, forward slashes here.  On Windows NT, "Personal/My Website" <BR># is a more appropriate choice. <BR># <BR>UserDir "My Documents/My Website" <BR><BR># <BR># Control access to UserDir directories.  The following is an example <BR># for a site where these directories are restricted to read-only. <BR># <BR># You must correct the path for the root to match your system's configured <BR># user directory location, e.g. "C:/WinNT/profiles/*/My Documents/My Website" <BR># or whichever, as appropriate. <BR># <BR>#<Directory "C:/Documents and Settings/*/My Documents/My Website"> <BR>#    AllowOverride FileInfo AuthConfig Limit <BR>#    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec <BR>#    <Limit GET POST OPTIONS PROPFIND> <BR>#        Order allow,deny <BR>#        Allow from all <BR>#    </Limit> <BR>#    <LimitExcept GET POST OPTIONS PROPFIND> <BR>#        Order deny,allow <BR>#        Deny from all <BR>#    </LimitExcept> <BR>#</Directory> <BR><BR># <BR># DirectoryIndex: sets the file that Apache will serve if a directory <BR># is requested. <BR># <BR># The index.html.var file (a type-map) is used to deliver content- <BR># negotiated documents.  The MultiViews Option can be used for the <BR># same purpose, but it is much slower. <BR># <BR></FONT><FONT color=#dc143c>DirectoryIndex index.html index.htm index.php</FONT><FONT color=#555555> <BR><BR># <BR># AccessFileName: The name of the file to look for in each directory <BR># for additional configuration directives.  See also the AllowOverride <BR># directive. <BR># <BR>AccessFileName .htaccess <BR><BR># <BR># The following lines prevent .htaccess and .htpasswd files from being <BR># viewed by Web clients. <BR># <BR><Files ~ "^\.ht"> <BR>   Order allow,deny <BR>   Deny from all <BR></Files> <BR><BR># <BR># TypesConfig describes where the mime.types file (or equivalent) is <BR># to be found. <BR># <BR>TypesConfig conf/mime.types <BR><BR># <BR># DefaultType is the default MIME type the server will use for a document <BR># if it cannot otherwise determine one, such as from filename extensions. <BR># If your server contains mostly text or HTML documents, "text/plain" is <BR># a good value.  If most of your content is binary, such as applications <BR># or images, you may want to use "application/octet-stream" instead to <BR># keep browsers from trying to display binary files as though they are <BR># text. <BR># <BR>DefaultType text/plain <BR><BR># <BR># The mod_mime_magic module allows the server to use various hints from the <BR># contents of the file itself to determine its type.  The MIMEMagicFile <BR># directive tells the module where the hint definitions are located. <BR># <BR><IfModule mod_mime_magic.c> <BR>   MIMEMagicFile conf/magic <BR></IfModule> <BR><BR># <BR># HostnameLookups: Log the names of clients or just their IP addresses <BR># e.g., </FONT><A href="http://www.apache.org/" target=_blank>www.apache.org</A><FONT color=#555555> (on) or 204.62.129.132 (off). <BR># The default is off because it'd be overall better for the net if people <BR># had to knowingly turn this feature on, since enabling it means that <BR># each client request will result in AT LEAST one lookup request to the <BR># nameserver. <BR># <BR>HostnameLookups Off <BR><BR># <BR># EnableMMAP: Control whether memory-mapping is used to deliver <BR># files (assuming that the underlying OS supports it). <BR># The default is on; turn this off if you serve from NFS-mounted <BR># filesystems.  On some systems, turning it off (regardless of <BR># filesystem) can improve performance; for details, please see <BR># </FONT><A href="http://httpd.apache.org/docs-2.0/mod/core.html#enablemmap" target=_blank>http://httpd.apache.org/docs-2.0/mod/core.html#enablemmap</A><FONT color=#555555> <BR># <BR>#EnableMMAP off <BR><BR># <BR># EnableSendfile: Control whether the sendfile kernel support is <BR># used  to deliver files (assuming that the OS supports it). <BR># The default is on; turn this off if you serve from NFS-mounted <BR># filesystems.  Please see <BR># </FONT><A href="http://httpd.apache.org/docs-2.0/mod/core.html#enablesendfile" target=_blank>http://httpd.apache.org/docs-2.0/mod/core.html#enablesendfile</A><FONT color=#555555> <BR># <BR>#EnableSendfile off <BR><BR># <BR># ErrorLog: The location of the error log file. <BR># If you do not specify an ErrorLog directive within a <VirtualHost> <BR># container, error messages relating to that virtual host will be <BR># logged here.  If you *do* define an error logfile for a <VirtualHost> <BR># container, that host's errors will be logged there and not here. <BR># <BR>ErrorLog logs/error.log <BR><BR># <BR># LogLevel: Control the number of messages logged to the error.log. <BR># Possible values include: debug, info, notice, warn, error, crit, <BR># alert, emerg. <BR># <BR>LogLevel warn </FONT>
[color=&#35;FF00FF]『有一种天空,喜欢接近阴霾 有一种生活,不知是否存在』  『有一种希望,注定走向毁灭 有一种死亡,渐渐被人期待』  『有一种心境,分辨不清好坏 有一种爱情,不再渴望表白』  『有一种眼泪,只能流向心底 有一种悲伤,从不表现出来』
返回列表