配置apache2.4修改documentRoot出現You don't have permission to access / on this server



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 [email protected]
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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章