我使用的是centos7,安装Apache 2.4.x,并且还安装了vsftpd,配置了用户 xxx.com
根目录 /var/virtual/xxx.com/public_html,用户目录 /var/virtual/xxx.com
当我设置 /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 ~]#
黄舟2017-04-25 09:03:30
Because you modified DocumentRoot, you should ensure that the four directories /var/virtual/xxx.com/public_html apache have access rights
習慣沉默2017-04-25 09:03:30
It is recommended to abandon the old and rough ftp and deploy through git or sftp.
大家讲道理2017-04-25 09:03:30
I haven’t used ftp for many years, and I am basically promoting git deployment.
为情所困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>