02 WWW架設
(2020/11/09)
一、架設WWW伺服器
[centos@shsps ~]$ rpm -qa |grep httpd (檢查有無httpd服務的相關程式,發現沒有安裝)
[centos@shsps ~]$ yum -y install httpd httpd-tools (利用yum來安裝httpd及httpd-tools的套件)
Error: This command has to be run under the root user. (無法執行)
[centos@shsps ~]$ sudo -s (取得root權限)
[root@shsps centos]# yum -y install httpd httpd-tools (重新安裝就可以了)
[root@shsps centos]# rpm -qa |grep httpd (再查一次,就有相關套件了)
httpd-filesystem-2.4.37-21.module_el8.2.0+494+1df74eae.noarch
httpd-tools-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64
centos-logos-httpd-80.5-2.el8.noarch
httpd-2.4.37-21.module_el8.2.0+494+1df74eae.x86_64
[root@shsps centos]# systemctl start httpd.service (啟動httpd的服務,也可以寫systemctl start httpd)
[root@shsps centos]# service httpd stop (以前的寫法,也會導到如上的指令)
Redirecting to /bin/systemctl stop httpd.service
[root@shsps centos]# service httpd start (以前的寫法)
Redirecting to /bin/systemctl start httpd.service
[root@shsps centos]# systemctl enable httpd.service (開機就啟動httpd的服務)
發現仍無法瀏覽網頁
二、關閉SELinux
[root@shsps centos]# vi /etc/sysconfig/selinux
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these three value
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
先把上面的內容,改成disabled,並且要重新啟動機器,這樣就可以關閉SELinux
關閉防火牆,本虛擬機好像沒有安裝firwall,所以執行如下指令時並無作用
[root@shsps centos]# systemctl stop firewalld.service
Failed to stop firewalld.service: Unit firewalld.service not loaded.
[root@shsps centos]# systemctl disable firewalld.service
Failed to disable unit: Unit file firewalld.service does not exist.
三、開啟80埠
到虛擬機的安全群組的規則增加一條可利用80埠進入的規則,不用重新開機
四、輸入網址
輸入網址,會顯示一預設網頁,代表WWW架設成功
五、WWW相關設定檔
待補上