-------------------------------------------------
// DNF is the next upcoming major version of YUM, a package manager for
RPM-based Linux distributions.
# dnf -y install httpd
# rpm -qa | grep httpd
httpd-tools-2.4.37-16.module_el8.1.0+256+ae790463.x86_64
centos-logos-httpd-80.5-2.el8.noarch
httpd-2.4.37-16.module_el8.1.0+256+ae790463.x86_64
httpd-filesystem-2.4.37-16.module_el8.1.0+256+ae790463.noarch
//執行檔
# ls /usr/sbin | grep httpd
httpd
//設定檔
# ls /etc/httpd/conf
httpd.conf
//站台預設 跟目錄
# ls /var/www/
html
# systemctl start httpd.service
# systemctl enable httpd.service
# systemctl status httpd.service
//displays information about a selection of the active processes.
//To see every process on the system using BSD syntax:
# ps -axu | grep httpd
root 958 0.0 0.5 280208 10988 ? Ss 14:30 0:00 /usr/sbin/httpd -DFOREGROUND
apache 991 0.0 0.4 292424 8252 ? S 14:30 0:00 /usr/sbin/httpd -DFOREGROUND
...
# ls /usr/lib/systemd/system | grep httpd
httpd.service
httpd@.service
httpd.service.d
httpd.socket
httpd.socket.d
# firewall-cmd --state
running
# firewall-cmd --get-service | grep http
# ls /usr/lib/firewalld/services/ | grep http
https.xml
http.xml
wbem-https.xml
wbem-http.xml
# firewall-cmd --reload
# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens32
sources:
services: cockpit dhcpv6-client http ssh
...
HostOS
http://192.168.1.4/
-------------------------------------------------設定虛擬目錄 Alias-------在其他的系統目錄 /opt
# ls -l /
...
drwxr-xr-x. 2 root root 6 5月 11 2019 opt
...
# mkdir /opt/web
# echo Hello Alias > /opt/web/index.html
# ls -l /opt
drwxr-xr-x. 2 root root 24 3月 26 14:59 web
# ls -l /opt/web/
-rw-r--r--. 1 root root 12 3月 26 14:59 index.html
# vi /etc/httpd/conf/httpd.conf
...
Alias /kk1web /opt/web
<Directory /opt/web>
Require all granted
</Directory>
# systemctl restart httpd.service
HostOS
http://192.168.1.4/kk1web/Hello Alias
-------------------------------------------------設定虛擬目錄 Alias-------在 /home
# vi /var/www/html/1.html
This is /var/www/html/1.html
HostOS
http://192.168.1.4/1.html
This is /var/www/html/1.html
# mkdir /home/web
# vi /home/web/1.html
This is One Web on /home/web
# vi /etc/httpd/conf/httpd.conf
...
Alias /web01 /home/web
<Directory "/home/web">
Require all granted
</Directory>
# systemctl restart httpd.service
HostOS
http://192.168.1.4/web01/1.html
ForbiddenYou don't have permission to access /web01/1.html on this server.
# tail -1 /var/log/httpd/error_log
[Thu Mar 26 15:15:25.107073 2020] [core:error] [pid 2426:tid 139987941058304] (13)Permission denied: [client 192.168.1.2:52012] AH00132: file permissions deny server access: /home/web/1.html
# ls -Z /var/www
system_u:object_r:httpd_sys_content_t:s0 html
# ls -Z /var/www/html
unconfined_u:object_r:httpd_sys_content_t:s0 1.html
# ls -Z /
...
system_u:object_r:usr_t:s0 opt
# ls -Z /home
unconfined_u:object_r:user_home_dir_t:s0 web
# ls -Z /home/web/
unconfined_u:object_r:user_home_t:s0 1.html
# chcon -t httpd_sys_content_t /home/web
# ls -Z /home
unconfined_u:object_r:httpd_sys_content_t:s0 web
沒有留言:
張貼留言