Rumah > php教程 > php手册 > teks badan

[PHP] - Apache + PHP 环境搭建

WBOY
Lepaskan: 2016-07-11 20:00:45
asal
2040 orang telah melayarinya

Apache和PHP的版本分别为:

  • httpd-2.4.9-win64-VC11.zip
  • php-5.6.9-Win32-VC11-x64.zip

下载地址:

php-5.6.9-Win32-VC11-x64

http://windows.php.net/downloads/releases/php-5.6.9-Win32-VC11-x64.zip

httpd-2.4.9-win64-VC11.zip

http://dldx.csdn.net/fd.php?i=615771039219219&s=de822f7950620fad9343c3728e04b1b6

 

本机使用提win7 64位(基本上现在的操作系统都是64位的了),同时,apache和php的编译器必需是一致

比如我上面的版本均是VC11。如果一个使用VC9一个是VC11,运行会出错。这点要注意。

  • 将Apache解压到:D:\Program Files\php5.6.9
  • 将php解压到:D:\Program Files\php5.6.9

 


 

Apache配置:

打开conf\httpd.conf文件,修改如下:

将所有:c:/apache24替换为:D:/Program Files/Apache24

 

前面加入:

LoadModule php5_module <span style="color: #800000;">"</span><span style="color: #800000;">D:/Program Files/php5.6.9/php5apache2_4.dll</span><span style="color: #800000;">"</span><span style="color: #000000;">
PHPIniDir </span><span style="color: #800000;">"</span><span style="color: #800000;">D:/Program Files/php5.6.9</span><span style="color: #800000;">"</span><span style="color: #000000;">
AddType application</span>/x-httpd-php .php .html .htm
Salin selepas log masuk

修改ServerName:

ServerName <span style="color: #800080;">127.0</span>.<span style="color: #800080;">0.1</span>:<span style="color: #800080;">80</span>
Salin selepas log masuk

修改Directory:

<directory></directory><span style="color: #000000;">
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</span>
Salin selepas log masuk

注释掉这个Directory:

#<directory style="color: #800000;">"<span style="color: #800000;">D:/Program Files/Apache24/htdocs</span><span style="color: #800000;">"</span>><span style="color: #000000;">
    #
    # Possible values </span><span style="color: #0000ff;">for</span> the Options directive are <span style="color: #800000;">"</span><span style="color: #800000;">None</span><span style="color: #800000;">"</span>, <span style="color: #800000;">"</span><span style="color: #800000;">All</span><span style="color: #800000;">"</span><span style="color: #000000;">,
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that </span><span style="color: #800000;">"</span><span style="color: #800000;">MultiViews</span><span style="color: #800000;">"</span> must be named *explicitly* --- <span style="color: #800000;">"</span><span style="color: #800000;">Options All</span><span style="color: #800000;">"</span><span style="color: #000000;">
    # doesn</span><span style="color: #800000;">'</span><span style="color: #800000;">t give it to you.</span>
<span style="color: #000000;">    #
    # The Options directive is both complicated and important.  Please see
    # http:</span><span style="color: #008000;">//</span><span style="color: #008000;">httpd.apache.org/docs/2.4/mod/core.html#options</span>
    # <span style="color: #0000ff;">for</span> <span style="color: #0000ff;">more</span><span style="color: #000000;"> information.
    #
    #Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed </span><span style="color: #0000ff;">in</span><span style="color: #000000;"> .htaccess files.
    # It can be </span><span style="color: #800000;">"</span><span style="color: #800000;">All</span><span style="color: #800000;">"</span>, <span style="color: #800000;">"</span><span style="color: #800000;">None</span><span style="color: #800000;">"</span><span style="color: #000000;">, or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    #AllowOverride None

    #
    # Controls </span><span style="color: #0000ff;">who</span><span style="color: #000000;"> can get stuff from this server.
    #
    #Require all granted
#</span></directory>
Salin selepas log masuk

加入默认页文件命名:

<ifmodule dir_module><span style="color: #000000;">
    DirectoryIndex index.html index.htm index.php
</span></ifmodule>
Salin selepas log masuk

开启虚拟主机:

Include conf/extra/httpd-vhosts.conf
Salin selepas log masuk

 

httpd.conf文件所有配置:

<span style="color: #008000;">#
#</span><span style="color: #008000;"> This is the main Apache HTTP server configuration file.  It contains the</span><span style="color: #008000;">
#</span><span style="color: #008000;"> configuration directives that give the server its instructions.</span><span style="color: #008000;">
#</span><span style="color: #008000;"> See <http:></http:> for detailed information.</span><span style="color: #008000;">
#</span><span style="color: #008000;"> In particular, see </span><span style="color: #008000;">
#</span><span style="color: #008000;"> <http:></http:></span><span style="color: #008000;">
#</span><span style="color: #008000;"> for a discussion of each configuration directive.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Do NOT simply read the instructions in here without understanding</span><span style="color: #008000;">
#</span><span style="color: #008000;"> what they do.  They're here only as hints or reminders.  If you are unsure</span><span style="color: #008000;">
#</span><span style="color: #008000;"> consult the online docs. You have been warned.  </span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Configuration and logfile names: If the filenames you specify for many</span><span style="color: #008000;">
#</span><span style="color: #008000;"> of the server's control files begin with "/" (or "drive:/" for Win32), the</span><span style="color: #008000;">
#</span><span style="color: #008000;"> server will use that explicit path.  If the filenames do *not* begin</span><span style="color: #008000;">
#</span><span style="color: #008000;"> with "/", the value of ServerRoot is prepended -- so "logs/access_log"</span><span style="color: #008000;">
#</span><span style="color: #008000;"> with ServerRoot set to "/usr/local/apache2" will be interpreted by the</span><span style="color: #008000;">
#</span><span style="color: #008000;"> server as "/usr/local/apache2/logs/access_log", whereas "/logs/access_log" </span><span style="color: #008000;">
#</span><span style="color: #008000;"> will be interpreted as '/logs/access_log'.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> NOTE: Where filenames are specified, you must use forward slashes</span><span style="color: #008000;">
#</span><span style="color: #008000;"> instead of backslashes (e.g., "c:/apache" instead of "c:\apache").</span><span style="color: #008000;">
#</span><span style="color: #008000;"> If a drive letter is omitted, the drive on which httpd.exe is located</span><span style="color: #008000;">
#</span><span style="color: #008000;"> will be used by default.  It is recommended that you always supply</span><span style="color: #008000;">
#</span><span style="color: #008000;"> an explicit drive letter in absolute paths to avoid confusion.</span>

<span style="color: #008000;">#
#</span><span style="color: #008000;"> ServerRoot: The top of the directory tree under which the server's</span><span style="color: #008000;">
#</span><span style="color: #008000;"> configuration, error, and log files are kept.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Do not add a slash at the end of the directory path.  If you point</span><span style="color: #008000;">
#</span><span style="color: #008000;"> ServerRoot at a non-local disk, be sure to specify a local disk on the</span><span style="color: #008000;">
#</span><span style="color: #008000;"> Mutex directive, if file-based mutexes are used.  If you wish to share the</span><span style="color: #008000;">
#</span><span style="color: #008000;"> same ServerRoot for multiple httpd daemons, you will need to change at</span><span style="color: #008000;">
#</span><span style="color: #008000;"> least PidFile.</span><span style="color: #008000;">
#
</span>ServerRoot "D:/Program Files/Apache24"

<span style="color: #008000;">#
#</span><span style="color: #008000;"> Mutex: Allows you to set the mutex mechanism and mutex file directory</span><span style="color: #008000;">
#</span><span style="color: #008000;"> for individual mutexes, or change the global defaults</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Uncomment and change the directory if mutexes are file-based and the default</span><span style="color: #008000;">
#</span><span style="color: #008000;"> mutex file directory is not on a local disk or is not appropriate for some</span><span style="color: #008000;">
#</span><span style="color: #008000;"> other reason.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Mutex default:logs</span>

<span style="color: #008000;">#
#</span><span style="color: #008000;"> Listen: Allows you to bind Apache to specific IP addresses and/or</span><span style="color: #008000;">
#</span><span style="color: #008000;"> ports, instead of the default. See also the <virtualhost></virtualhost></span><span style="color: #008000;">
#</span><span style="color: #008000;"> directive.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Change this to Listen on specific IP addresses as shown below to </span><span style="color: #008000;">
#</span><span style="color: #008000;"> prevent Apache from glomming onto all bound IP addresses.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;">Listen 12.34.56.78:80</span>
Listen 80

<span style="color: #008000;">#
#</span><span style="color: #008000;"> Dynamic Shared Object (DSO) Support</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> To be able to use the functionality of a module which was built as a DSO you</span><span style="color: #008000;">
#</span><span style="color: #008000;"> have to place corresponding `LoadModule' lines at this location so the</span><span style="color: #008000;">
#</span><span style="color: #008000;"> directives contained in it are actually available _before_ they are used.</span><span style="color: #008000;">
#</span><span style="color: #008000;"> Statically compiled modules (those listed by `httpd -l') do not need</span><span style="color: #008000;">
#</span><span style="color: #008000;"> to be loaded here.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Example:</span><span style="color: #008000;">
#</span><span style="color: #008000;"> LoadModule foo_module modules/mod_foo.so</span><span style="color: #008000;">
#
</span>LoadModule access_compat_module modules/mod_access_compat.<span style="color: #000000;">so
LoadModule actions_module modules</span>/mod_actions.<span style="color: #000000;">so
LoadModule alias_module modules</span>/mod_alias.<span style="color: #000000;">so
LoadModule allowmethods_module modules</span>/mod_allowmethods.<span style="color: #000000;">so
LoadModule asis_module modules</span>/mod_asis.<span style="color: #000000;">so
LoadModule auth_basic_module modules</span>/mod_auth_basic.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule auth_digest_module modules/mod_auth_digest.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule auth_form_module modules/mod_auth_form.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule authn_anon_module modules/mod_authn_anon.so</span>
LoadModule authn_core_module modules/mod_authn_core.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule authn_dbd_module modules/mod_authn_dbd.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule authn_dbm_module modules/mod_authn_dbm.so</span>
LoadModule authn_file_module modules/mod_authn_file.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule authn_socache_module modules/mod_authn_socache.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule authnz_ldap_module modules/mod_authnz_ldap.so</span>
LoadModule authz_core_module modules/mod_authz_core.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule authz_dbd_module modules/mod_authz_dbd.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule authz_dbm_module modules/mod_authz_dbm.so</span>
LoadModule authz_groupfile_module modules/mod_authz_groupfile.<span style="color: #000000;">so
LoadModule authz_host_module modules</span>/mod_authz_host.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule authz_owner_module modules/mod_authz_owner.so</span>
LoadModule authz_user_module modules/mod_authz_user.<span style="color: #000000;">so
LoadModule autoindex_module modules</span>/mod_autoindex.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule buffer_module modules/mod_buffer.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule cache_module modules/mod_cache.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule cache_disk_module modules/mod_cache_disk.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule cache_socache_module modules/mod_cache_socache.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule cern_meta_module modules/mod_cern_meta.so</span>
LoadModule cgi_module modules/mod_cgi.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule charset_lite_module modules/mod_charset_lite.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule data_module modules/mod_data.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule dav_module modules/mod_dav.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule dav_fs_module modules/mod_dav_fs.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule dav_lock_module modules/mod_dav_lock.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule dbd_module modules/mod_dbd.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule deflate_module modules/mod_deflate.so</span>
LoadModule dir_module modules/mod_dir.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule dumpio_module modules/mod_dumpio.so</span>
LoadModule env_module modules/mod_env.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule expires_module modules/mod_expires.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule ext_filter_module modules/mod_ext_filter.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule file_cache_module modules/mod_file_cache.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule filter_module modules/mod_filter.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule headers_module modules/mod_headers.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule heartbeat_module modules/mod_heartbeat.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule heartmonitor_module modules/mod_heartmonitor.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule ident_module modules/mod_ident.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule imagemap_module modules/mod_imagemap.so</span>
LoadModule include_module modules/mod_include.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule info_module modules/mod_info.so</span>
LoadModule isapi_module modules/mod_isapi.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule lbmethod_bybusyness_module modules/mod_lbmethod_bybusyness.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule lbmethod_bytraffic_module modules/mod_lbmethod_bytraffic.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule ldap_module modules/mod_ldap.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule logio_module modules/mod_logio.so</span>
LoadModule log_config_module modules/mod_log_config.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule log_debug_module modules/mod_log_debug.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule log_forensic_module modules/mod_log_forensic.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule lua_module modules/mod_lua.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule macro_module modules/mod_macro.so</span>
LoadModule mime_module modules/mod_mime.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule mime_magic_module modules/mod_mime_magic.so</span>
LoadModule negotiation_module modules/mod_negotiation.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule proxy_module modules/mod_proxy.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule proxy_ajp_module modules/mod_proxy_ajp.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule proxy_balancer_module modules/mod_proxy_balancer.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule proxy_connect_module modules/mod_proxy_connect.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule proxy_express_module modules/mod_proxy_express.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule proxy_ftp_module modules/mod_proxy_ftp.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule proxy_html_module modules/mod_proxy_html.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule proxy_http_module modules/mod_proxy_http.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule proxy_scgi_module modules/mod_proxy_scgi.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule proxy_wstunnel_module modules/mod_proxy_wstunnel.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule ratelimit_module modules/mod_ratelimit.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule reflector_module modules/mod_reflector.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule remoteip_module modules/mod_remoteip.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule request_module modules/mod_request.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule reqtimeout_module modules/mod_reqtimeout.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule rewrite_module modules/mod_rewrite.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule sed_module modules/mod_sed.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule session_module modules/mod_session.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule session_cookie_module modules/mod_session_cookie.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule session_crypto_module modules/mod_session_crypto.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule session_dbd_module modules/mod_session_dbd.so</span>
LoadModule setenvif_module modules/mod_setenvif.<span style="color: #000000;">so
</span><span style="color: #008000;">#</span><span style="color: #008000;">LoadModule slotmem_plain_module modules/mod_slotmem_plain.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule slotmem_shm_module modules/mod_slotmem_shm.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule socache_dbm_module modules/mod_socache_dbm.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule socache_memcache_module modules/mod_socache_memcache.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule socache_shmcb_module modules/mod_socache_shmcb.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule speling_module modules/mod_speling.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule ssl_module modules/mod_ssl.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule status_module modules/mod_status.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule substitute_module modules/mod_substitute.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule unique_id_module modules/mod_unique_id.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule userdir_module modules/mod_userdir.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule usertrack_module modules/mod_usertrack.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule version_module modules/mod_version.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule vhost_alias_module modules/mod_vhost_alias.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule watchdog_module modules/mod_watchdog.so</span><span style="color: #008000;">
#</span><span style="color: #008000;">LoadModule xml2enc_module modules/mod_xml2enc.so</span>
<span style="color: #000000;">
LoadModule php5_module </span>"D:/Program Files/php5.6.9/php5apache2_4.dll"<span style="color: #000000;">
PHPIniDir </span>"D:/Program Files/php5.6.9"<span style="color: #000000;">
AddType application</span>/x-httpd-php .php .html .<span style="color: #000000;">htm

</span><ifmodule unixd_module>
<span style="color: #008000;">#
#</span><span style="color: #008000;"> If you wish httpd to run as a different user or group, you must run</span><span style="color: #008000;">
#</span><span style="color: #008000;"> httpd as root initially and it will switch.  </span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> User/Group: The name (or #number) of the user/group to run httpd as.</span><span style="color: #008000;">
#</span><span style="color: #008000;"> It is usually good practice to create a dedicated user and group for</span><span style="color: #008000;">
#</span><span style="color: #008000;"> running httpd, as with most system services.</span><span style="color: #008000;">
#
</span><span style="color: #000000;">User daemon
Group daemon

</span></ifmodule>

<span style="color: #008000;">#</span><span style="color: #008000;"> 'Main' server configuration</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> The directives in this section set up the values used by the 'main'</span><span style="color: #008000;">
#</span><span style="color: #008000;"> server, which responds to any requests that aren't handled by a</span><span style="color: #008000;">
#</span><span style="color: #008000;"> <virtualhost> definition.  These values also provide defaults for</virtualhost></span><span style="color: #008000;">
#</span><span style="color: #008000;"> any <virtualhost> containers you may define later in the file.</virtualhost></span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> All of these directives may appear inside <virtualhost> containers,</virtualhost></span><span style="color: #008000;">
#</span><span style="color: #008000;"> in which case these default settings will be overridden for the</span><span style="color: #008000;">
#</span><span style="color: #008000;"> virtual host being defined.</span><span style="color: #008000;">
#
</span>
<span style="color: #008000;">#
#</span><span style="color: #008000;"> ServerAdmin: Your address, where problems with the server should be</span><span style="color: #008000;">
#</span><span style="color: #008000;"> e-mailed.  This address appears on some server-generated pages, such</span><span style="color: #008000;">
#</span><span style="color: #008000;"> as error documents.  e.g. admin@your-domain.com</span><span style="color: #008000;">
#
</span>ServerAdmin admin@example.<span style="color: #000000;">com

</span><span style="color: #008000;">#
#</span><span style="color: #008000;"> ServerName gives the name and port that the server uses to identify itself.</span><span style="color: #008000;">
#</span><span style="color: #008000;"> This can often be determined automatically, but we recommend you specify</span><span style="color: #008000;">
#</span><span style="color: #008000;"> it explicitly to prevent problems during startup.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> If your host doesn't have a registered DNS name, enter its IP address here.</span><span style="color: #008000;">
#
</span>ServerName 127.0.0.1:80

<span style="color: #008000;">#
#</span><span style="color: #008000;"> Deny access to the entirety of your server's filesystem. You must</span><span style="color: #008000;">
#</span><span style="color: #008000;"> explicitly permit access to web content directories in other </span><span style="color: #008000;">
#</span><span style="color: #008000;"> <directory> blocks below.</directory></span><span style="color: #008000;">
#
</span><directory></directory><span style="color: #000000;">
    Options FollowSymLinks
    AllowOverride None
    Order deny</span>,<span style="color: #000000;">allow
    Deny from all
</span>

<span style="color: #008000;">#
#</span><span style="color: #008000;"> Note that from this point forward you must specifically allow</span><span style="color: #008000;">
#</span><span style="color: #008000;"> particular features to be enabled - so if something's not working as</span><span style="color: #008000;">
#</span><span style="color: #008000;"> you might expect, make sure that you have specifically enabled it</span><span style="color: #008000;">
#</span><span style="color: #008000;"> below.</span><span style="color: #008000;">
#
</span>
<span style="color: #008000;">#
#</span><span style="color: #008000;"> DocumentRoot: The directory out of which you will serve your</span><span style="color: #008000;">
#</span><span style="color: #008000;"> documents. By default, all requests are taken from this directory, but</span><span style="color: #008000;">
#</span><span style="color: #008000;"> symbolic links and aliases may be used to point to other locations.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;">DocumentRoot "D:/Program Files/Apache24/htdocs"</span><span style="color: #008000;">
#</span><span style="color: #008000;"><directory files></directory></span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> Possible values for the Options directive are "None", "All",</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> or any combination of:</span>
    <span style="color: #008000;">#</span><span style="color: #008000;">   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> Note that "MultiViews" must be named *explicitly* --- "Options All"</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> doesn't give it to you.</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> The Options directive is both complicated and important.  Please see</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> http://httpd.apache.org/docs/2.4/mod/core.html#options</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> for more information.</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;">Options Indexes FollowSymLinks</span>

    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> AllowOverride controls what directives may be placed in .htaccess files.</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> It can be "All", "None", or any combination of the keywords:</span>
    <span style="color: #008000;">#</span><span style="color: #008000;">   AllowOverride FileInfo AuthConfig Limit</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;">AllowOverride None</span>

    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> Controls who can get stuff from this server.</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;">Require all granted</span><span style="color: #008000;">
#</span><span style="color: #008000;"></span>

<span style="color: #008000;">#
#</span><span style="color: #008000;"> DirectoryIndex: sets the file that Apache will serve if a directory</span><span style="color: #008000;">
#</span><span style="color: #008000;"> is requested.</span><span style="color: #008000;">
#
</span><ifmodule dir_module><span style="color: #000000;">
    DirectoryIndex index</span>.html index.htm index.<span style="color: #000000;">php
</span></ifmodule>

<span style="color: #008000;">#
#</span><span style="color: #008000;"> The following lines prevent .htaccess and .htpasswd files from being </span><span style="color: #008000;">
#</span><span style="color: #008000;"> viewed by Web clients. </span><span style="color: #008000;">
#
</span><files>
    <span style="color: #0000ff;">Require</span><span style="color: #000000;"> all denied
</span></files>

<span style="color: #008000;">#
#</span><span style="color: #008000;"> ErrorLog: The location of the error log file.</span><span style="color: #008000;">
#</span><span style="color: #008000;"> If you do not specify an ErrorLog directive within a <virtualhost></virtualhost></span><span style="color: #008000;">
#</span><span style="color: #008000;"> container, error messages relating to that virtual host will be</span><span style="color: #008000;">
#</span><span style="color: #008000;"> logged here.  If you *do* define an error logfile for a <virtualhost></virtualhost></span><span style="color: #008000;">
#</span><span style="color: #008000;"> container, that host's errors will be logged there and not here.</span><span style="color: #008000;">
#
</span>ErrorLog "logs/error.log"

<span style="color: #008000;">#
#</span><span style="color: #008000;"> LogLevel: Control the number of messages logged to the error_log.</span><span style="color: #008000;">
#</span><span style="color: #008000;"> Possible values include: debug, info, notice, warn, error, crit,</span><span style="color: #008000;">
#</span><span style="color: #008000;"> alert, emerg.</span><span style="color: #008000;">
#
</span><span style="color: #000000;">LogLevel warn

</span><ifmodule log_config_module>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> The following directives define some format nicknames for use with</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> a CustomLog directive (see below).</span>
    <span style="color: #008000;">#
</span>    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""<span style="color: #000000;"> combined
    LogFormat </span>"%h %l %u %t \"%r\" %>s %b"<span style="color: #000000;"> common

    </span><ifmodule logio_module>
      <span style="color: #008000;">#</span><span style="color: #008000;"> You need to enable mod_logio.c to use %I and %O</span>
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O"<span style="color: #000000;"> combinedio
    </span></ifmodule>

    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> The location and format of the access logfile (Common Logfile Format).</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> If you do not define any access logfiles within a <virtualhost></virtualhost></span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> container, they will be logged here.  Contrariwise, if you *do*</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> define per-<virtualhost> access logfiles, transactions will be</virtualhost></span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> logged therein and *not* in this file.</span>
    <span style="color: #008000;">#
</span>    CustomLog "logs/access.log"<span style="color: #000000;"> common

    </span><span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> If you prefer a logfile with access, agent, and referer information</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> (Combined Logfile Format) you can use the following directive.</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;">CustomLog "logs/access.log" combined</span>
</ifmodule>

<ifmodule alias_module>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> Redirect: Allows you to tell clients about documents that used to </span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> exist in your server's namespace, but do not anymore. The client </span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> will make a new request for the document at its new location.</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> Example:</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> Redirect permanent /foo http://www.example.com/bar</span>

    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> Alias: Maps web paths into filesystem paths and is used to</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> access content that does not live under the DocumentRoot.</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> Example:</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> Alias /webpath /full/filesystem/path</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> If you include a trailing / on /webpath then the server will</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> require it to be present in the URL.  You will also likely</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> need to provide a <directory> section to allow access to</directory></span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> the filesystem path.</span>

    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> ScriptAlias: This controls which directories contain server scripts. </span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> ScriptAliases are essentially the same as Aliases, except that</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> documents in the target directory are treated as applications and</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> run by the server when requested rather than as documents sent to the</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> client.  The same rules about trailing "/" apply to ScriptAlias</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> directives as to Alias.</span>
    <span style="color: #008000;">#
</span>    ScriptAlias /cgi-bin/ "D:/Program Files/Apache24/cgi-bin/"

</ifmodule>

<ifmodule cgid_module>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> ScriptSock: On threaded servers, designate the path to the UNIX</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> socket used to communicate with the CGI daemon of mod_cgid.</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;">Scriptsock cgisock</span>
</ifmodule>

<span style="color: #008000;">#
#</span><span style="color: #008000;"> "D:/Program Files/Apache24/cgi-bin" should be changed to whatever your ScriptAliased</span><span style="color: #008000;">
#</span><span style="color: #008000;"> CGI directory exists, if you have that configured.</span><span style="color: #008000;">
#
</span><directory files><span style="color: #000000;">
    AllowOverride None
    Options None
    </span><span style="color: #0000ff;">Require</span><span style="color: #000000;"> all granted
</span></directory>

<ifmodule mime_module>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> TypesConfig points to the file containing the list of mappings from</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> filename extension to MIME-type.</span>
    <span style="color: #008000;">#
</span>    TypesConfig conf/mime.<span style="color: #000000;">types

    </span><span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> AddType allows you to add to or override the MIME configuration</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> file specified in TypesConfig for specific file types.</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;">AddType application/x-gzip .tgz</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> AddEncoding allows you to have certain browsers uncompress</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> information on the fly. Note: Not all browsers support this.</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;">AddEncoding x-compress .Z</span>
    <span style="color: #008000;">#</span><span style="color: #008000;">AddEncoding x-gzip .gz .tgz</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> If the AddEncoding directives above are commented-out, then you</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> probably should define those extensions to indicate media types:</span>
    <span style="color: #008000;">#
</span>    AddType application/x-compress .<span style="color: #000000;">Z
    AddType application</span>/x-gzip .gz .<span style="color: #000000;">tgz

    </span><span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> AddHandler allows you to map certain file extensions to "handlers":</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> actions unrelated to filetype. These can be either built into the server</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> or added with the Action directive (see below)</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> To use CGI scripts outside of ScriptAliased directories:</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> (You will also need to add "ExecCGI" to the "Options" directive.)</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;">AddHandler cgi-script .cgi</span>

    <span style="color: #008000;">#</span><span style="color: #008000;"> For type maps (negotiated resources):</span>
    <span style="color: #008000;">#</span><span style="color: #008000;">AddHandler type-map var</span>

    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> Filters allow you to process content before it is sent to the client.</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;"> To parse .shtml files for server-side includes (SSI):</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> (You will also need to add "Includes" to the "Options" directive.)</span>
    <span style="color: #008000;">#
</span>    <span style="color: #008000;">#</span><span style="color: #008000;">AddType text/html .shtml</span>
    <span style="color: #008000;">#</span><span style="color: #008000;">AddOutputFilter INCLUDES .shtml</span>
</ifmodule>

<span style="color: #008000;">#
#</span><span style="color: #008000;"> The mod_mime_magic module allows the server to use various hints from the</span><span style="color: #008000;">
#</span><span style="color: #008000;"> contents of the file itself to determine its type.  The MIMEMagicFile</span><span style="color: #008000;">
#</span><span style="color: #008000;"> directive tells the module where the hint definitions are located.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;">MIMEMagicFile conf/magic</span>

<span style="color: #008000;">#
#</span><span style="color: #008000;"> Customizable error responses come in three flavors:</span><span style="color: #008000;">
#</span><span style="color: #008000;"> 1) plain text 2) local redirects 3) external redirects</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Some examples:</span><span style="color: #008000;">
#</span><span style="color: #008000;">ErrorDocument 500 "The server made a boo boo."</span><span style="color: #008000;">
#</span><span style="color: #008000;">ErrorDocument 404 /missing.html</span><span style="color: #008000;">
#</span><span style="color: #008000;">ErrorDocument 404 "/cgi-bin/missing_handler.pl"</span><span style="color: #008000;">
#</span><span style="color: #008000;">ErrorDocument 402 http://www.example.com/subscription_info.html</span><span style="color: #008000;">
#
</span>
<span style="color: #008000;">#
#</span><span style="color: #008000;"> MaxRanges: Maximum number of Ranges in a request before</span><span style="color: #008000;">
#</span><span style="color: #008000;"> returning the entire resource, or one of the special</span><span style="color: #008000;">
#</span><span style="color: #008000;"> values 'default', 'none' or 'unlimited'.</span><span style="color: #008000;">
#</span><span style="color: #008000;"> Default setting is to accept 200 Ranges.</span><span style="color: #008000;">
#</span><span style="color: #008000;">MaxRanges unlimited</span>

<span style="color: #008000;">#
#</span><span style="color: #008000;"> EnableMMAP and EnableSendfile: On systems that support it, </span><span style="color: #008000;">
#</span><span style="color: #008000;"> memory-mapping or the sendfile syscall may be used to deliver</span><span style="color: #008000;">
#</span><span style="color: #008000;"> files.  This usually improves server performance, but must</span><span style="color: #008000;">
#</span><span style="color: #008000;"> be turned off when serving from networked-mounted </span><span style="color: #008000;">
#</span><span style="color: #008000;"> filesystems or if support for these functions is otherwise</span><span style="color: #008000;">
#</span><span style="color: #008000;"> broken on your system.</span><span style="color: #008000;">
#</span><span style="color: #008000;"> Defaults: EnableMMAP On, EnableSendfile Off</span><span style="color: #008000;">
#
#</span><span style="color: #008000;">EnableMMAP off</span><span style="color: #008000;">
#</span><span style="color: #008000;">EnableSendfile on</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> Supplemental configuration</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> The configuration files in the conf/extra/ directory can be </span><span style="color: #008000;">
#</span><span style="color: #008000;"> included to add extra features or to modify the default configuration of </span><span style="color: #008000;">
#</span><span style="color: #008000;"> the server, or you may simply copy their contents here and change as </span><span style="color: #008000;">
#</span><span style="color: #008000;"> necessary.</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> Server-pool management (MPM specific)</span><span style="color: #008000;">
#</span><span style="color: #008000;">Include conf/extra/httpd-mpm.conf</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> Multi-language error messages</span><span style="color: #008000;">
#</span><span style="color: #008000;">Include conf/extra/httpd-multilang-errordoc.conf</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> Fancy directory listings</span><span style="color: #008000;">
#</span><span style="color: #008000;">Include conf/extra/httpd-autoindex.conf</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> Language settings</span><span style="color: #008000;">
#</span><span style="color: #008000;">Include conf/extra/httpd-languages.conf</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> User home directories</span><span style="color: #008000;">
#</span><span style="color: #008000;">Include conf/extra/httpd-userdir.conf</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> Real-time info on requests and configuration</span><span style="color: #008000;">
#</span><span style="color: #008000;">Include conf/extra/httpd-info.conf</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> Virtual hosts</span>
<span style="color: #0000ff;">Include</span> conf/extra/httpd-vhosts.<span style="color: #000000;">conf

</span><span style="color: #008000;">#</span><span style="color: #008000;"> Local access to the Apache HTTP Server Manual</span><span style="color: #008000;">
#</span><span style="color: #008000;">Include conf/extra/httpd-manual.conf</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> Distributed authoring and versioning (WebDAV)</span><span style="color: #008000;">
#</span><span style="color: #008000;">Include conf/extra/httpd-dav.conf</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> Various default settings</span><span style="color: #008000;">
#</span><span style="color: #008000;">Include conf/extra/httpd-default.conf</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> Configure mod_proxy_html to understand HTML4/XHTML1</span>
<ifmodule proxy_html_module>
<span style="color: #0000ff;">Include</span> conf/extra/proxy-html.<span style="color: #000000;">conf
</span></ifmodule>

<span style="color: #008000;">#</span><span style="color: #008000;"> Secure (SSL/TLS) connections</span><span style="color: #008000;">
#</span><span style="color: #008000;">Include conf/extra/httpd-ssl.conf</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Note: The following must must be present to support</span><span style="color: #008000;">
#</span><span style="color: #008000;">       starting without SSL on platforms with no /dev/random equivalent</span><span style="color: #008000;">
#</span><span style="color: #008000;">       but a statically compiled-in mod_ssl.</span><span style="color: #008000;">
#
</span><ifmodule ssl_module><span style="color: #000000;">
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</span></ifmodule>
<span style="color: #008000;">#
#</span><span style="color: #008000;"> uncomment out the below to deal with user agents that deliberately</span><span style="color: #008000;">
#</span><span style="color: #008000;"> violate open standards by misusing DNT (DNT *must* be a specific</span><span style="color: #008000;">
#</span><span style="color: #008000;"> end-user choice)</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"><ifmodule setenvif_module></ifmodule></span><span style="color: #008000;">
#</span><span style="color: #008000;">BrowserMatch "MSIE 10.0;" bad_DNT</span><span style="color: #008000;">
#</span><span style="color: #008000;"></span><span style="color: #008000;">
#</span><span style="color: #008000;"><ifmodule headers_module></ifmodule></span><span style="color: #008000;">
#</span><span style="color: #008000;">RequestHeader unset DNT env=bad_DNT</span><span style="color: #008000;">
#</span><span style="color: #008000;"></span>
Salin selepas log masuk

 

打开conf\extra\httpd-vhosts.conf文件:

修改为:

 

<span style="color: #008000;">#</span><span style="color: #008000;"> Virtual Hosts</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Required modules: mod_log_config</span>

<span style="color: #008000;">#</span><span style="color: #008000;"> If you want to maintain multiple domains/hostnames on your</span><span style="color: #008000;">
#</span><span style="color: #008000;"> machine you can setup VirtualHost containers for them. Most configurations</span><span style="color: #008000;">
#</span><span style="color: #008000;"> use only name-based virtual hosts so the server doesn't need to worry about</span><span style="color: #008000;">
#</span><span style="color: #008000;"> IP addresses. This is indicated by the asterisks in the directives below.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> Please see the documentation at </span><span style="color: #008000;">
#</span><span style="color: #008000;"> <http:></http:></span><span style="color: #008000;">
#</span><span style="color: #008000;"> for further details before you try to setup virtual hosts.</span><span style="color: #008000;">
#
#</span><span style="color: #008000;"> You may use the command line option '-S' to verify your virtual host</span><span style="color: #008000;">
#</span><span style="color: #008000;"> configuration.</span>

<virtualhost><span style="color: #000000;">
    ServerAdmin admin@example</span>.<span style="color: #000000;">com
    </span><span style="color: #008000;">#</span><span style="color: #008000;"> 虚拟主机路径</span>
    DocumentRoot "F:/PhpProject"
    <span style="color: #008000;">#</span><span style="color: #008000;"> 虚拟主机域名或IP</span>
    ServerName 127.0.0.1
    <span style="color: #008000;">#</span><span style="color: #008000;"> 虚拟主机域名或IP(别名或第二个域名)</span>
<span style="color: #000000;">    ServerAlias localhost
    </span><span style="color: #008000;">#</span><span style="color: #008000;"> 错误日志</span>
    ErrorLog "logs/dummy-host.localhost-error.log"<span style="color: #000000;">
    CustomLog </span>"logs/dummy-host.localhost-access.log"<span style="color: #000000;"> combined
    </span><span style="color: #008000;">#</span><span style="color: #008000;">------------------------------------------------------------------</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> 主目录配置权限</span>
    <span style="color: #008000;">#</span><span style="color: #008000;">------------------------------------------------------------------</span>
    <directory></directory>
        <span style="color: #008000;">#</span><span style="color: #008000;"> 列出目录资源</span>
<span style="color: #000000;">        Options Indexes FollowSymLinks
        </span><span style="color: #008000;">#</span><span style="color: #008000;"> 禁止列出目录资源</span>
        <span style="color: #008000;">#</span><span style="color: #008000;">Options FollowSymLinks</span>
<span style="color: #000000;">        AllowOverride All
        Order allow</span>,<span style="color: #000000;">deny
        Allow from all
    </span>
    
    <span style="color: #008000;">#</span><span style="color: #008000;">------------------------------------------------------------------</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> 虚拟目录配置</span>
    <span style="color: #008000;">#</span><span style="color: #008000;"> 以下别名配置意思是配置一个:http://localhost/p 的虚拟目录</span>
    <span style="color: #008000;">#</span><span style="color: #008000;">------------------------------------------------------------------</span>
    Alias /p "F:/PhpProject/ZendHello"
    <directory>
        <span style="color: #008000;">#</span><span style="color: #008000;"> 列出目录资源</span>
<span style="color: #000000;">        Options Indexes FollowSymLinks
        </span><span style="color: #008000;">#</span><span style="color: #008000;"> 禁止列出目录资源</span>
        <span style="color: #008000;">#</span><span style="color: #008000;">Options FollowSymLinks</span>
<span style="color: #000000;">        AllowOverride All
        Order allow</span>,<span style="color: #000000;">deny
        Allow from all
    </span></directory>
</virtualhost>
Salin selepas log masuk

其中,DocumentRoot是php源码的目录。


 

 

PHP配置:

打开php的解压目录,将php.ini-Deployment重命名为:php.ini

修改extension_dir为:

extension_dir = "D:/Program Files/php5.6.9/ext"
Salin selepas log masuk

修改extension:

extension=php_bz2.<span style="color: #000000;">dll
extension</span>=php_curl.<span style="color: #000000;">dll
extension</span>=php_fileinfo.<span style="color: #000000;">dll
extension</span>=php_gd2.<span style="color: #000000;">dll
extension</span>=php_gettext.<span style="color: #000000;">dll
extension</span>=php_gmp.<span style="color: #000000;">dll
extension</span>=php_intl.<span style="color: #000000;">dll
extension</span>=php_imap.<span style="color: #000000;">dll
;extension</span>=php_interbase.<span style="color: #000000;">dll
extension</span>=php_ldap.<span style="color: #000000;">dll
extension</span>=php_mbstring.<span style="color: #000000;">dll
extension</span>=php_exif.dll      ; Must be after mbstring <span style="color: #0000ff;">as</span><span style="color: #000000;"> it depends on it
extension</span>=php_mysql.<span style="color: #000000;">dll
extension</span>=php_mysqli.<span style="color: #000000;">dll
;extension</span>=php_oci8_12c.dll  ; <span style="color: #0000ff;">Use</span><span style="color: #000000;"> with Oracle Database 12c Instant Client
extension</span>=php_openssl.<span style="color: #000000;">dll
;extension</span>=php_pdo_firebird.<span style="color: #000000;">dll
extension</span>=php_pdo_mysql.<span style="color: #000000;">dll
;extension</span>=php_pdo_oci.<span style="color: #000000;">dll
extension</span>=php_pdo_odbc.<span style="color: #000000;">dll
extension</span>=php_pdo_pgsql.<span style="color: #000000;">dll
;extension</span>=php_pdo_sqlite.<span style="color: #000000;">dll
extension</span>=php_pgsql.<span style="color: #000000;">dll
;extension</span>=php_pspell.<span style="color: #000000;">dll
extension</span>=php_shmop.<span style="color: #000000;">dll

; The MIBS data available in the PHP distribution must be installed</span>.<span style="color: #000000;"> 
; See http</span>:<span style="color: #008000;">//</span><span style="color: #008000;">www.php.net/manual/en/snmp.installation.php </span>
;extension=php_snmp.<span style="color: #000000;">dll

;extension</span>=php_soap.<span style="color: #000000;">dll
;extension</span>=php_sockets.<span style="color: #000000;">dll
extension</span>=php_sqlite3.<span style="color: #000000;">dll
;extension</span>=php_sybase_ct.<span style="color: #000000;">dll
;extension</span>=php_tidy.<span style="color: #000000;">dll
;extension</span>=php_xmlrpc.<span style="color: #000000;">dll
;extension</span>=php_xsl.dll
Salin selepas log masuk

 

修改date.timezone:

<span style="color: #008080;">date</span>.timezone = Asia/Shanghai
Salin selepas log masuk

 

将apache设置为windows service方法:

到apache的bin目录(使用管理员身份运行cmd),运行命令:

httpd.exe -k install
Salin selepas log masuk

然后双击运行ApacheMonitor.exe即可。

卸载服务方法是:

httpd.exe -k uninstall
Salin selepas log masuk

 


 

 测试

在F:\PhpProject目录下面新建一个文件:index.php

<span style="color: #000000;">php
    </span><span style="color: #008080;">phpinfo</span><span style="color: #000000;">();
</span>?>
Salin selepas log masuk

将看到如下:

 


 

文章参考:

Windows下搭建PHP开发环境

http://www.cnblogs.com/pharen/archive/2012/02/06/2340628.html

 

手动将Apache注册为系统服务

http://www.cnblogs.com/zhenmingliu/archive/2012/01/09/2316886.html

 

sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Cadangan popular
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan