suchen

Heim  >  Fragen und Antworten  >  Hauptteil

403-forbidden - centos7 Apache 网站出现403无法访问

系统

我使用的是centos7,安装Apache 2.4.x,并且还安装了vsftpd,配置了用户 xxx.com
根目录 /var/virtual/xxx.com/public_html,用户目录 /var/virtual/xxx.com

vsftpd

当我设置 /var/virtual/xxx.com/public_html 的所有者为 Apache的时候,可以访问。
但vsftpd无法登录,改为 xxx.com 这个用户,vsftpd可以登录,Apache访问出现403提示。

命令过程


[root@localhost virtual]# mkdir -p /var/virtual/xxx.com/{public_html,logs,backup} [root@localhost virtual]# useradd xxx.com -g apache -d /var/virtual/xxx.com [root@localhost virtual]# chown xxx.com: -R /var/virtual/xxx.com [root@localhost virtual]# ls -l /var/virtual/xxx.com total 12 drwxr-xr-x 2 xxx.com apache 4096 Sep 9 00:50 backup drwxr-xr-x 2 xxx.com apache 4096 Sep 9 00:51 logs drwxr-xr-x 2 xxx.com apache 4096 Sep 9 09:50 public_html [root@localhost virtual]# ftp localhost Trying ::1... ftp: connect to address ::1Connection refused Trying 127.0.0.1... Connected to localhost (127.0.0.1). 220 (vsFTPd 3.0.2) Name (localhost:root): xxx.com 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (127,0,0,1,34,100). 150 Here comes the directory listing. drwxr-xr-x 2 1000 48 4096 Sep 08 16:50 backup drwxr-xr-x 2 1000 48 4096 Sep 08 16:51 logs drwxr-xr-x 2 1000 48 4096 Sep 09 01:50 public_html 226 Directory send OK. ftp> exit 221 Goodbye. [root@localhost virtual]# [root@localhost virtual]# sestatus SELinux status: disabled [root@localhost virtual]# uname Linux [root@localhost virtual]# uname -a Linux localhost.localdomain 3.15.4-x86_64-linode45 #1 SMP Mon Jul 7 08:42:36 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux [root@localhost virtual]#

备注

1)selinux已经关闭
2)两个用户 xxx.com 和 apache都是同一个用户组 apache用户组 GID = 48

[root@localhost ~]# grep xxx.com /etc/passwd
xxx.com:x:1000:48::/var/virtual/xxx.com:/bin/bash
[root@localhost ~]# grep apache /etc/passwd
apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin
[root@localhost ~]#
我想大声告诉你我想大声告诉你2773 Tage vor955

Antworte allen(5)Ich werde antworten

  • 黄舟

    黄舟2017-04-25 09:03:30

    因为你修改了 DocumentRoot 所以应该确保4个目录/var/virtual/xxx.com/public_html apache都有访问权限

    chmod o+x /var

    chmod o+x /var/virturl

    chmod o+x /var/virturl/xxx.com

    chmod o+x /var/virturl/xxx.com/public_html

    Antwort
    0
  • 習慣沉默

    習慣沉默2017-04-25 09:03:30

    建议放弃陈旧粗糙的ftp,可以通过git部署,或者sftp。

    Antwort
    0
  • 怪我咯

    怪我咯2017-04-25 09:03:30

    ftp配置的问题?

    Antwort
    0
  • 大家讲道理

    大家讲道理2017-04-25 09:03:30

    好多年不用ftp了,基本上正在推广git部署。

    Antwort
    0
  • 为情所困

    为情所困2017-04-25 09:03:30

    • chcon -R -t httpd_user_content_t public_html/ <path to web files>
    • chcon -R -t httpd_sys_content_t <path to web files>

    Antwort
    0
  • StornierenAntwort