美文网首页
WEB服务安装

WEB服务安装

作者: Tess鱼丸 | 来源:发表于2022-11-09 13:59 被阅读0次
[root@dns ~]# df -h
文件系统               容量  已用  可用 已用% 挂载点
devtmpfs               872M     0  872M    0% /dev
tmpfs                  901M     0  901M    0% /dev/shm
tmpfs                  901M  9.7M  891M    2% /run
tmpfs                  901M     0  901M    0% /sys/fs/cgroup
/dev/mapper/rhel-root   17G  4.3G   13G   25% /
/dev/nvme0n1p1        1014M  229M  786M   23% /boot
tmpfs                  181M  1.2M  179M    1% /run/user/42
tmpfs                  181M  4.6M  176M    3% /run/user/0
/dev/sr0               7.9G  7.9G     0  100% /run/media/root/RHEL-8-2-0-BaseOS-x86_64
[root@dns ~]# cd /etc/yum.repos.d/

[root@dns yum.repos.d]# cat localyum.repo 
[BaseOS]
name=BaseOS
baseurl=file:///mnt/cdrom/BaseOS
enabled=1
gpgcheck=0

[AppStream]
name=AppStream
baseurl=file:///mnt/cdrom/AppStream
enabled=1
gpgcheck=0
[root@dns yum.repos.d]# cd /mnt/

[root@dns /]# mount /dev/sr0 /mnt/cdrom/
mount: /mnt/cdrom: WARNING: device write-protected, mounted read-only.

[root@dns /]# cd /mnt/cdrom/
[root@dns cdrom]# 
[root@dns cdrom]# ls -al
总用量 53
dr-xr-xr-x. 7 root root  2048 4月   4 2020 .
drwxr-xr-x. 4 root root    31 10月 31 14:54 ..
dr-xr-xr-x. 4 root root  2048 4月   4 2020 AppStream
dr-xr-xr-x. 4 root root  2048 4月   4 2020 BaseOS
-r--r--r--. 1 root root    60 4月   4 2020 .discinfo
dr-xr-xr-x. 3 root root  2048 4月   4 2020 EFI
-r--r--r--. 1 root root  8266 4月   4 2020 EULA
-r--r--r--. 1 root root  1455 4月   4 2020 extra_files.json
-r--r--r--. 1 root root 18092 4月   4 2020 GPL
dr-xr-xr-x. 3 root root  2048 4月   4 2020 images
dr-xr-xr-x. 2 root root  2048 4月   4 2020 isolinux
-r--r--r--. 1 root root   103 4月   4 2020 media.repo
-r--r--r--. 1 root root  1669 4月   4 2020 RPM-GPG-KEY-redhat-beta
-r--r--r--. 1 root root  5134 4月   4 2020 RPM-GPG-KEY-redhat-release
-r--r--r--. 1 root root  1796 4月   4 2020 TRANS.TBL
-r--r--r--. 1 root root  1560 4月   4 2020 .treeinfo
[root@dns cdrom]# 

[root@dns cdrom]# rpm -qa |grep httpd
[root@dns cdrom]# 

[root@dns cdrom]# dnf clean all
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
12 文件已删除
[root@dns /]# 
[root@dns /]# dnf install httpd -y
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
BaseOS                                          194 MB/s | 2.3 MB     00:00    
AppStream                                       222 MB/s | 5.8 MB     00:00    
依赖关系解决。
================================================================================
 软件包           架构   版本                                   仓库       大小
================================================================================
安装:
 httpd            x86_64 2.4.37-21.module+el8.2.0+5008+cca404a3 AppStream 1.4 M
安装依赖关系:
 apr              x86_64 1.6.3-9.el8                            AppStream 125 k
 apr-util         x86_64 1.6.1-6.el8                            AppStream 105 k
 httpd-filesystem noarch 2.4.37-21.module+el8.2.0+5008+cca404a3 AppStream  36 k
 httpd-tools      x86_64 2.4.37-21.module+el8.2.0+5008+cca404a3 AppStream 103 k
 mod_http2        x86_64 1.11.3-3.module+el8.2.0+4377+dc421495  AppStream 158 k
 redhat-logos-httpd
                  noarch 81.1-1.el8                             BaseOS     26 k
安装弱的依赖:
 apr-util-bdb     x86_64 1.6.1-6.el8                            AppStream  25 k
 apr-util-openssl x86_64 1.6.1-6.el8                            AppStream  27 k
启用模块流:
 httpd                   2.4                                                   

事务概要
================================================================================
安装  9 软件包

总计:2.0 M
安装大小:5.5 M
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                 1/1 
  安装    : apr-1.6.3-9.el8.x86_64                                          1/9 
  运行脚本: apr-1.6.3-9.el8.x86_64                                          1/9 
  安装    : apr-util-bdb-1.6.1-6.el8.x86_64                                 2/9 
  安装    : apr-util-openssl-1.6.1-6.el8.x86_64                             3/9 
  安装    : apr-util-1.6.1-6.el8.x86_64                                     4/9 
  运行脚本: apr-util-1.6.1-6.el8.x86_64                                     4/9 
  安装    : httpd-tools-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64       5/9 
  运行脚本: httpd-filesystem-2.4.37-21.module+el8.2.0+5008+cca404a3.noarc   6/9 
  安装    : httpd-filesystem-2.4.37-21.module+el8.2.0+5008+cca404a3.noarch              6/9 
  安装    : redhat-logos-httpd-81.1-1.el8.noarch                                        7/9 
  安装    : mod_http2-1.11.3-3.module+el8.2.0+4377+dc421495.x86_64                      8/9 
  安装    : httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64                         9/9 
  运行脚本: httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64                         9/9 
  验证    : redhat-logos-httpd-81.1-1.el8.noarch                                        1/9 
  验证    : apr-1.6.3-9.el8.x86_64                                                      2/9 
  验证    : apr-util-1.6.1-6.el8.x86_64                                                 3/9 
  验证    : apr-util-bdb-1.6.1-6.el8.x86_64                                             4/9 
  验证    : apr-util-openssl-1.6.1-6.el8.x86_64                                         5/9 
  验证    : httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64                         6/9 
  验证    : httpd-filesystem-2.4.37-21.module+el8.2.0+5008+cca404a3.noarch              7/9 
  验证    : httpd-tools-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64                   8/9 
  验证    : mod_http2-1.11.3-3.module+el8.2.0+4377+dc421495.x86_64                      9/9 
Installed products updated.

已安装:
  apr-1.6.3-9.el8.x86_64                                                                    
  apr-util-1.6.1-6.el8.x86_64                                                               
  apr-util-bdb-1.6.1-6.el8.x86_64                                                           
  apr-util-openssl-1.6.1-6.el8.x86_64                                                       
  httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64                                       
  httpd-filesystem-2.4.37-21.module+el8.2.0+5008+cca404a3.noarch                            
  httpd-tools-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64                                 
  mod_http2-1.11.3-3.module+el8.2.0+4377+dc421495.x86_64                                    
  redhat-logos-httpd-81.1-1.el8.noarch                                                      

完毕!
[root@dns /]# 
[root@dns /]# rpm -qa |grep httpd
redhat-logos-httpd-81.1-1.el8.noarch
httpd-tools-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64
httpd-2.4.37-21.module+el8.2.0+5008+cca404a3.x86_64
httpd-filesystem-2.4.37-21.module+el8.2.0+5008+cca404a3.noarch
[root@dns /]# 

[root@dns /]# 
[root@dns /]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd.service(8)
[root@dns /]# 
[root@dns /]# systemctl start httpd
[root@dns /]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-11-10 09:05:49 EST; 3s ago
     Docs: man:httpd.service(8)
 Main PID: 32438 (httpd)
   Status: "Started, listening on: port 80"
    Tasks: 213 (limit: 11160)
   Memory: 22.7M
   CGroup: /system.slice/httpd.service
           ├─32438 /usr/sbin/httpd -DFOREGROUND
           ├─32445 /usr/sbin/httpd -DFOREGROUND
           ├─32446 /usr/sbin/httpd -DFOREGROUND
           ├─32447 /usr/sbin/httpd -DFOREGROUND
           └─32448 /usr/sbin/httpd -DFOREGROUND

11月 10 09:05:49 dns.long90.cn.10.168.192.in-addr.arpa systemd[1]: Starting The Apache HTTP>
11月 10 09:05:49 dns.long90.cn.10.168.192.in-addr.arpa systemd[1]: Started The Apache HTTP >
11月 10 09:05:50 dns.long90.cn.10.168.192.in-addr.arpa httpd[32438]: Server configured, lis>
...skipping...
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-11-10 09:05:49 EST; 3s ago
     Docs: man:httpd.service(8)
 Main PID: 32438 (httpd)
   Status: "Started, listening on: port 80"
    Tasks: 213 (limit: 11160)
   Memory: 22.7M
   CGroup: /system.slice/httpd.service
           ├─32438 /usr/sbin/httpd -DFOREGROUND
           ├─32445 /usr/sbin/httpd -DFOREGROUND
           ├─32446 /usr/sbin/httpd -DFOREGROUND
           ├─32447 /usr/sbin/httpd -DFOREGROUND
           └─32448 /usr/sbin/httpd -DFOREGROUND

11月 10 09:05:49 dns.long90.cn.10.168.192.in-addr.arpa systemd[1]: Starting The Apache HTTP>
11月 10 09:05:49 dns.long90.cn.10.168.192.in-addr.arpa systemd[1]: Started The Apache HTTP >
11月 10 09:05:50 dns.long90.cn.10.168.192.in-addr.arpa httpd[32438]: Server configured, lis>
~
[root@dns /]# 

[root@dns /]# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens160
  sources: 
  services: cockpit dhcpv6-client dns ssh
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
    
[root@dns /]# firewall-cmd --permanent --add-service=http
success
[root@dns /]# 
[root@dns /]# firewall-cmd --reload 
success
[root@dns /]# 
[root@dns /]# firewall-cmd --list-all  #再次查看放行条件
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens160
  sources: 
  services: cockpit dhcpv6-client dns http ssh
  ports: 
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 
[root@dns /]# 

[root@dns /]# setenforce 0
[root@dns /]# getenforce 
Permissive
[root@dns /]# 

[root@dns /]# systemctl restart httpd  #重启http配置
[root@dns /]# systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-11-10 09:11:16 EST; 11s ago
     Docs: man:httpd.service(8)
 Main PID: 32900 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 11160)
   Memory: 28.7M
   CGroup: /system.slice/httpd.service
           ├─32900 /usr/sbin/httpd -DFOREGROUND
           ├─32908 /usr/sbin/httpd -DFOREGROUND
           ├─32909 /usr/sbin/httpd -DFOREGROUND
           ├─32910 /usr/sbin/httpd -DFOREGROUND
           └─32911 /usr/sbin/httpd -DFOREGROUND

11月 10 09:11:16 dns.long90.cn.10.168.192.in-addr.arpa systemd[1]: Starting The Apache HTTP>
11月 10 09:11:16 dns.long90.cn.10.168.192.in-addr.arpa systemd[1]: Started The Apache HTTP >
11月 10 09:11:16 dns.long90.cn.10.168.192.in-addr.arpa httpd[32900]: Server configured, lis>
...skipping...
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-11-10 09:11:16 EST; 11s ago
     Docs: man:httpd.service(8)
 Main PID: 32900 (httpd)
   Status: "Running, listening on: port 80"
    Tasks: 213 (limit: 11160)
   Memory: 28.7M
   CGroup: /system.slice/httpd.service
           ├─32900 /usr/sbin/httpd -DFOREGROUND
           ├─32908 /usr/sbin/httpd -DFOREGROUND
           ├─32909 /usr/sbin/httpd -DFOREGROUND
           ├─32910 /usr/sbin/httpd -DFOREGROUND
           └─32911 /usr/sbin/httpd -DFOREGROUND

11月 10 09:11:16 dns.long90.cn.10.168.192.in-addr.arpa systemd[1]: Starting The Apache HTTP>
11月 10 09:11:16 dns.long90.cn.10.168.192.in-addr.arpa systemd[1]: Started The Apache HTTP >
11月 10 09:11:16 dns.long90.cn.10.168.192.in-addr.arpa httpd[32900]: Server configured, lis>
~
~
设置开机自启动
[root@dns /]# systemctl enable httpd 
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@dns /]# 
127.0.0.1.PNG welcome.PNG
回复Selinux
[root@dns /]# setenforce 1
[root@dns /]# getenforce 
Enforcing
[root@dns /]# 

创建并编辑index.html文件

[root@dns /]# cd /var/www/html/
[root@dns html]# ls -al
总用量 0
drwxr-xr-x. 2 root root  6 12月  2 2019 .
drwxr-xr-x. 4 root root 33 11月 10 09:03 ..
[root@dns html]# 
[root@dns html]# vim index.html
[root@dns html]# 
[root@dns html]# cat index.html 
welcome !!!
[root@dns html]# 

查看编辑后的网页

welcome.PNG
[root@dns html]# vim /home/www/myweb.html
[root@dns html]# 
[root@dns conf]# cat /home/www/myweb.html 
the web's documentroot test
[root@dns conf]# 
[root@dns html]# cd /etc/httpd/conf
[root@dns conf]# 
[root@dns conf]# ls -al
总用量 28
drwxr-xr-x. 2 root root    37 11月 10 09:04 .
drwxr-xr-x. 5 root root   105 11月 10 09:04 ..
-rw-r--r--. 1 root root 11899 12月  2 2019 httpd.conf
-rw-r--r--. 1 root root 13064 12月  2 2019 magic
[root@dns conf]# cp -p httpd.conf httpd.conf.bak
[root@dns conf]# 
[root@dns conf]# ls -al
总用量 40
drwxr-xr-x. 2 root root    59 11月 10 09:25 .
drwxr-xr-x. 5 root root   105 11月 10 09:04 ..
-rw-r--r--. 1 root root 11899 12月  2 2019 httpd.conf
-rw-r--r--. 1 root root 11899 12月  2 2019 httpd.conf.bak
-rw-r--r--. 1 root root 13064 12月  2 2019 magic
[root@dns conf]# 
这三个地方修改成这样
#
DocumentRoot "/home/www"
#

#
<Directory "/home/www">
    AllowOverride None
    # Allow open access:
    Require all granted
</Directory>


#
<IfModule dir_module>
    DirectoryIndex index.html myweb.html
</IfModule>

再配置防火墙放行

[root@dns conf]# firewall-cmd --permanent --add-service=http
Warning: ALREADY_ENABLED: http
success
[root@dns conf]# 
[root@dns conf]# firewall-cmd --reload 

success
[root@dns conf]# 
[root@dns conf]# 
[root@dns conf]# setenforce 0
[root@dns conf]# 
[root@dns conf]# getenforce 
Permissive
[root@dns conf]# 

重启http服务

###
[root@dns conf]# systemctl restart httpd
[root@dns conf]# 
10.1.PNG
[root@dns ~]# useradd long
[root@dns ~]# passwd long
更改用户 long 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@dns ~]# 
[root@dns ~]# 
[root@dns ~]# passwd long
更改用户 long 的密码 。
新的 密码:
无效的密码: 密码少于 8 个字符
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@dns ~]# 
[root@dns ~]# chmod 705 /home/long
[root@dns ~]# 
[root@dns ~]# mkdir /home/long/public_html
[root@dns ~]# 
[root@dns ~]# 
[root@dns ~]# cd /home/long/public_html
[root@dns public_html]# echo "this is long's web" >>index.html
[root@dns public_html]# 
[root@dns public_html]# cat index.html 
this is long's web
[root@dns public_html]# 
[root@dns public_html]# vim /etc/httpd/conf.d/userdir.conf 
[root@dns public_html]# 

userdir.PNG
[root@dns public_html]# setenforce 0
^[[A[root@dns public_html]# getenforce 
Permissive
[root@dns public_html]# 
[root@dns public_html]# firewall-cmd --permanent --add-service=http
Warning: ALREADY_ENABLED: http
success
[root@dns public_html]# firewall-cmd --reload 

success
[root@dns public_html]# 
[root@dns public_html]# systemctl restart httpd

再到client1上面验证

~long.PNG
[root@dns ~]# mkdir -p /virdir/
[root@dns ~]# 
[root@dns ~]# cd /virdir/
[root@dns virdir]# 
[root@dns virdir]# echo "this is virtual directory.">>index.html
[root@dns virdir]# 
[root@dns virdir]# chmod 705 index.html 
[root@dns virdir]# 
###修改添加配置文件
[root@dns virdir]# vim /etc/httpd/conf/httpd.conf
###在结尾添加以下内容
Alias /test "/virdir"
<Directory "/virdir">
  AllowOverride None
  Require all granted
</Directory>

[root@dns virdir]# setenforce 0
[root@dns virdir]# 
[root@dns virdir]# getenforce 
Permissive
[root@dns virdir]# 
[root@dns virdir]# firewall-cmd --permanent --add-service=http
Warning: ALREADY_ENABLED: http
success
[root@dns virdir]# firewall-cmd --reload 
success
[root@dns virdir]# systemctl restart httpd
[root@dns virdir]# 

再次到client1验证

test.PNG
案例四:

配置基于IP地址的虚拟主机

[root@dns virdir]# mkdir /var/www/ip1 /var/www/ip2
[root@dns virdir]# 
[root@dns virdir]# 
[root@dns virdir]# echo "this is 192.168.10.1's web.">/var/www/ip1/index.html
[root@dns virdir]# echo "this is 192.168.10.10's web.">/var/www/ip2/index.html
[root@dns virdir]# 

[root@dns virdir]# vim /etc/httpd/conf.d/vhost.conf
####添加以下内容
<Virtualhost 192.168.10.1>
  DocumentRoot /var/www/ip1
</Virtualhost>
<Virtualhost 192.168.10.10>
  DocumentRoot /var/www/ip2
</Virtualhost>
[root@dns virdir]# 

####在结尾再添加一下内容
[root@dns virdir]# vim /etc/httpd/conf/httpd.conf

<Directory "/var/www/ip1">
  AllowOverride None
  Require all granted
</Directory>

<Directory "/var/www/ip2">
  AllowOverride None
  Require all granted
</Directory>

[root@dns virdir]# setenforce 0 
[root@dns virdir]# getenforce 
Permissive
[root@dns virdir]# firewall-cmd --permanent --add-service=http
You're performing an operation over default zone ('public'),
but your connections/interfaces are in zone 'libvirt' (see --get-active-zones)
You most likely need to use --zone=libvirt option.

Warning: ALREADY_ENABLED: http
success
[root@dns virdir]# firewall-cmd --reload 
success
[root@dns virdir]# 
[root@dns virdir]# systemctl restart httpd
[root@dns virdir]# 

最后.PNG

相关文章

  • 网站的基本概念

    服务器 web服务器,提供web服务(网站访问),就需要安装 web服务软件 apche tomcat iis ...

  • WEB服务安装

    设置开机自启动 回复Selinux 创建并编辑index.html文件 查看编辑后的网页 这三个地方修改成这样 再...

  • Centos6.5静默安装Oracle 10 g

    [TOC] 安装基础服务 安装说明有的云服务环境只能提供web的方式连接linux服务器,导致安装Oracle的时...

  • 2018-11-12 Flask安装配置

    安装 uwsgiWSGI(Web Server Gateway Interface),定义了web服务器(ngin...

  • 2018-05-10 D3 继续安装环境

    1.6 Web库的安装 现在日常访问的网站都是Web服务程序搭建而成的。Python也有Web服务程序,比如Fla...

  • shell编写一键源码安装LAMP脚本

    打印菜单 1)安装apache WEB服务器 2)安装Mysql DB服务器 3)安装PHP服务器 4)整合LAN...

  • Apache 服务器概述-安装-搭建 Web 网站服务器之前的环

    Apache 服务器概述-安装 Apache 服务器概述-安装 WEB 服务器也称为 WWW(WORLD WIDE...

  • javaWeb知识总结

    一.web服务器,servlet服务器,servlet和jvm 1.1web服务器 服务器:安装了服务器软件的计算...

  • Nginx反向代理配置

    首先部署实施后端Web服务器1)部署后端Web1服务器后端Web服务器可以简单使用yum方式安装httpd实现We...

  • lamp

    web服务、lamp平台、静态地址、安装包、修改配置文件、启动服务 安装Apache服务c/s模式默认端口:80 ...

网友评论

      本文标题:WEB服务安装

      本文链接:https://www.haomeiwen.com/subject/betatdtx.html