[root@server ~]# yum -y install httpd [root@server ~]# systemctl start httpd [root@server ~]# systemctl enable httpd
[root@server ~]# ls -ldZ /var/www/ drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /var/www/
[root@server ~]# mkdir /html [root@server ~]# ls -ldZ /html/ drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /html/ [root@server ~]# chcon -R -t httpd_sys_content_t /html/ [root@server ~]# ls -ldZ /html/ drwxr-xr-x. root root unconfined_u:object_r:httpd_sys_content_t:s0 /html/ [root@server ~]# restorecon -R /html/ [root@server ~]# ls -ldZ /html/ drwxr-xr-x. root root unconfined_u:object_r:default_t:s0 /html/ [root@server ~]# # --reference 設置和目錄相同的上下文 [root@server ~]# chcon -R --reference=/var/www/html /www
[root@server ~]# semanage fcontext -a -t httpd_sys_content_t '/html(/.*)?' [root@server ~]# ls -ldZ /html drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /html [root@server ~]# restorecon -R /html/ [root@server ~]# ls -ldZ /html drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 /html
1)檢查配置文件是否容許寫
2)檢查文件系統是否容許寫
3)檢查 selinux (上下文|布爾值)html
[root@server ~]# yum -y install vsftpd [root@server ~]# systemctl start vsftpd [root@server ~]# systemctl enable vsftpd
[root@server ~]# vim /etc/vsftpd/vsftpd.conf
# 容許匿名上傳 anon_upload_enable=YES anon_mkdir_write_enable=YES
[root@server ~]# ls -ld /var/ftp/ drwxr-xr-x. 4 root root 27 8月 17 14:29 /var/ftp/ [root@server ~]# cd /var/ftp/ [root@server ftp]# mkdir test [root@server ftp]# chown -R ftp.ftp test [root@server ftp]# ls -ld test drwxr-xr-x. 2 ftp ftp 6 8月 17 14:48 test
[root@server ~]# getsebool -a | grep ftp ftpd_anon_write --> off ftpd_connect_all_unreserved --> off ftpd_connect_db --> off ftpd_full_access --> off ftpd_use_cifs --> off ftpd_use_fusefs --> off ftpd_use_nfs --> off ftpd_use_passive_mode --> off httpd_can_connect_ftp --> off httpd_enable_ftp_server --> off tftp_anon_write --> off tftp_home_dir --> off [root@server ftp]# setsebool -P ftpd_anon_write on [root@server ftp]# setsebool -P ftpd_full_access on [root@server ~]# getsebool -a | grep ftp ftpd_anon_write --> on ftpd_connect_all_unreserved --> off ftpd_connect_db --> off ftpd_full_access --> on ftpd_use_cifs --> off ftpd_use_fusefs --> off ftpd_use_nfs --> off ftpd_use_passive_mode --> off httpd_can_connect_ftp --> off httpd_enable_ftp_server --> off tftp_anon_write --> off tftp_home_dir --> off