Apache-2.2

在 Fedora 17 上使用 php 在 apache 上獲取 403

  • November 8, 2012

我把項目放在上面~/public_html/project並創建一個/var/www/html/project指向~/public_html/project.

/etc/httpd/conf/httpd.conf的如下所示

ServerRoot "/etc/httpd"

PidFile run/httpd.pid

Timeout 60

KeepAlive Off

MaxKeepAliveRequests 100

KeepAliveTimeout 5

<IfModule prefork.c>
StartServers       8
MinSpareServers    5
MaxSpareServers   20
ServerLimit      256
MaxClients       256
MaxRequestsPerChild  4000
</IfModule>

<IfModule worker.c>
StartServers         4
MaxClients         300
MinSpareThreads     25
MaxSpareThreads     75 
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

Listen 80

Include conf.d/*.conf

User apache
Group apache

ServerAdmin root@localhost

UseCanonicalName Off

DocumentRoot "/var/www/html"

<Directory />
   Options FollowSymLinks
   AllowOverride None
</Directory>

<Directory "/var/www/html">
   Options Indexes FollowSymLinks
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>

# Allow SVN access from public
<Directory "/var/www/svn">
   Options Indexes FollowSymLinks
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>

<IfModule mod_userdir.c>
   UserDir disabled
   # UserDir public_html
</IfModule>

DirectoryIndex index.html index.html.var

AccessFileName .htaccess

<FilesMatch "^\.ht">
   Order allow,deny
   Deny from all
   Satisfy All
</FilesMatch>

TypesConfig /etc/mime.types

DefaultType text/plain

<IfModule mod_mime_magic.c>
#   MIMEMagicFile /usr/share/magic.mime
   MIMEMagicFile conf/magic
</IfModule>

HostnameLookups Off

<IfModule mod_dav_fs.c>
   # Location of the WebDAV lock database.
   DAVLockDB /var/lib/dav/lockdb
</IfModule>

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

<Directory "/var/www/cgi-bin">
   AllowOverride None
   Options None
   Order allow,deny
   Allow from all
</Directory>

/var/log/httpd/error_log

[error] [client 127.0.0.1] Symbolic link not allowed or link target not accessible: /var/www/html/project
[error] [client 127.0.0.1] File does not exist: /var/www/html/favicon.ico

在瀏覽器中

Forbidden

You don't have permission to access /project on this server.

我得到這個錯誤。

ls -l結果:

drwxrwxrwx 3 js js 4.0K Nov 1 14:43 public_html/

項目

drwxr-xr-x. 6 js js 4.0K Nov 1 16:38 public_html/project/

我無法弄清楚問題所在。

我發現了與我的主目錄有關的問題。

基本上我只是用這個命令解決了

$ chmod o+rx ~

+Michael Hampton 的回答可能在某種程度上有所幫助。不管怎麼說,還是要謝謝你。

您需要啟用 httpd 才能通過 SELinux 讀取主目錄。

setsebool -P httpd_enable_homedirs 1
setsebool -P httpd_read_user_content 1

引用自:https://serverfault.com/questions/444629