httpd.conf文件内容如下(这里不能写太多内容,前面有#的行我都给删掉了)
Define SRVROOT "D:/Apache24"
ServerRoot "${SRVROOT}"
Listen 80
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule allowmethods_module modules/mod_allowmethods.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule env_module modules/mod_env.so
LoadModule include_module modules/mod_include.so
LoadModule isapi_module modules/mod_isapi.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule mime_module modules/mod_mime.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule php5_module "D:/php5.6.1/php5apache2_4.dll"
PHPIniDir "D:/php5.6.1"
AddType application/x-httpd-php .php .html .htm
< IfModule unixd_module>
User daemon
Group daemon
< /IfModule>
ServerAdmin admin@example.com
ServerName localhost:80
< Directory />
AllowOverride none
Require all denied
< /Directory>
#DocumentRoot "${SRVROOT}/htdocs"-----这里要是把#去掉可以成功,但是根目录就不是我想要的了
DocumentRoot "D:/www"
< Directory "D:/www">-----这里要是填成${SRVROOT}/htdocs可以成功,但是根目录就不是我想要的了
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
< /Directory>
< IfModule dir_module>
DirectoryIndex index.php index.html
< /IfModule>
< Files ".ht*">
Require all denied
< /Files>
ErrorLog "logs/error.log"
LogLevel warn
< IfModule log_config_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
CustomLog "logs/access.log" common
< /IfModule>
< IfModule alias_module>
ScriptAlias /cgi-bin/ "${SRVROOT}/cgi-bin/"
< /IfModule>
< IfModule cgid_module>
< /IfModule>
< Directory "${SRVROOT}/cgi-bin">
AllowOverride None
Options None
Require all granted
< /Directory>
< IfModule mime_module>
TypesConfig conf/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php .html
< /IfModule>
< IfModule proxy_html_module>
Include conf/extra/proxy-html.conf
< /IfModule>
< IfModule ssl_module>
Include conf/extra/httpd-sni.conf
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
< /IfModule>
不改documentRoot可以正常运行,我想让根目录为d:/www
稀烂的中国网友,也碰到了这个问题,
httpd.conf中的DocumentRoot文件权限默认就有Require all granted,这个没有问题,一大堆垃圾回复。
在国外的网站上搜了好长时间终于找到问题了。
还要修改Apache24\conf\extra\httpd-vhosts.conf
< VirtualHost _default_:80>
#DocumentRoot "${SRVROOT}/htdocs"
DocumentRoot "d:/www"
#ServerName www.example.com:80
< /VirtualHost>
希望对后来者有帮助
FROM:http://bbs.csdn.net/topics/390904273