內容選單標籤

2017年4月28日 星期五

ch15 Apache

Linux的安全防護機制

1.防火牆 FirewallD (外部)
# systemctl stop firewalld.service
# systemctl disable firewalld.service

# firewall-cmd --permanent --add-service=http
success
# firewall-cmd --reload
success



2.增強安全機制 SELinux Security Enhanced Linux (內部)
# vi /etc/sysconfig/selinux
#SELINUX=enforcing
SELINUX=disable                                //關閉SELinux,存檔後重新開機設定值才生效
...

# sestatus
SELinux status:                 enabled
...




-----------------------------------------------------安裝
# yum install -y httpd httpd-tools
# rpm -qa | grep httpd
httpd-tools-2.4.6-45.el7.centos.4.x86_64
httpd-2.4.6-45.el7.centos.4.x86_64
# systemctl start httpd
# systemctl enable httpd
# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2017-04-28 13:55:50 CST; 1min 24s ago


--------------------------------------------虛擬目錄
# mkdir /home/test
# vi /home/test/index.html
this is visual DIR
...

# vi /etc/httpd/conf/httpd.conf
...
Alias /test "/home/test"
<Directory "/home/test">
    Require all granted
</Directory>

# systemctl restart httpd


# chcon -R -t httpd_sys_content_t /home/test
# ls -Z /home/test
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 index.html

# sestatus
SELinux status:                 enabled
...




沒有留言:

張貼留言