Linux之http服务基本配置案例
搭建服务
1、 首先下载httpd服务
[root@redhat ~]# dnf install httpd
Updating Subscription Management repositories.
Unable to read consumer identityThis system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.Repository epel is listed more than once in the configuration
Last metadata expiration check: 1:35:46 ago on Tue 17 Aug 2021 12:28:59 PM CST.
Dependencies resolved.
================================================================================================Package Arch Version Repository Size
================================================================================================
Installing:httpd x86_64 2.4.37-39.module_el8.4.0+778+c970deab AppStream 1.4 M
Installing dependencies:apr x86_64 1.6.3-11.el8 AppStream 125 kapr-util x86_64 1.6.1-6.el8 AppStream 105 kcentos-logos-httpd noarch 85.8-1.el8 baseOS 75 khttpd-filesystem noarch 2.4.37-39.module_el8.4.0+778+c970deab AppStream 38 khttpd-tools x86_64 2.4.37-39.module_el8.4.0+778+c970deab AppStream 106 kmod_http2 x86_64 1.15.7-3.module_el8.4.0+778+c970deab AppStream 154 k
Installing weak dependencies:apr-util-bdb x86_64 1.6.1-6.el8 AppStream 25 kapr-util-openssl x86_64 1.6.1-6.el8 AppStream 27 kTransaction Summary
================================================================================================
Install 9 PackagesTotal download size: 2.0 M
Installed size: 5.6 M
Is this ok [y/N]: y
Downloading Packages:
(1/9): apr-util-1.6.1-6.el8.x86_64.rpm 241 kB/s | 105 kB 00:00
(2/9): centos-logos-httpd-85.8-1.el8.noarch.rpm 167 kB/s | 75 kB 00:00
(3/9): apr-1.6.3-11.el8.x86_64.rpm 261 kB/s | 125 kB 00:00
(4/9): apr-util-openssl-1.6.1-6.el8.x86_64.rpm 401 kB/s | 27 kB 00:00
(5/9): apr-util-bdb-1.6.1-6.el8.x86_64.rpm 164 kB/s | 25 kB 00:00
(6/9): httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.n 446 kB/s | 38 kB 00:00
(7/9): httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64 884 kB/s | 106 kB 00:00
(8/9): mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64.rp 931 kB/s | 154 kB 00:00
(9/9): httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64.rpm 3.7 MB/s | 1.4 MB 00:00
------------------------------------------------------------------------------------------------
Total 2.0 MB/s | 2.0 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transactionPreparing : 1/1 Installing : apr-1.6.3-11.el8.x86_64 1/9 Running scriptlet: apr-1.6.3-11.el8.x86_64 1/9 Installing : apr-util-bdb-1.6.1-6.el8.x86_64 2/9 Installing : apr-util-openssl-1.6.1-6.el8.x86_64 3/9 Installing : apr-util-1.6.1-6.el8.x86_64 4/9 Running scriptlet: apr-util-1.6.1-6.el8.x86_64 4/9 Installing : httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64 5/9 Running scriptlet: httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch 6/9 Installing : httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch 6/9 Installing : centos-logos-httpd-85.8-1.el8.noarch 7/9 Installing : mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64 8/9 Installing : httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64 9/9 Running scriptlet: httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64 9/9 Verifying : centos-logos-httpd-85.8-1.el8.noarch 1/9 Verifying : apr-1.6.3-11.el8.x86_64 2/9 Verifying : apr-util-1.6.1-6.el8.x86_64 3/9 Verifying : apr-util-bdb-1.6.1-6.el8.x86_64 4/9 Verifying : apr-util-openssl-1.6.1-6.el8.x86_64 5/9 Verifying : httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64 6/9 Verifying : httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch 7/9 Verifying : httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64 8/9 Verifying : mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64 9/9
Installed products updated.Installed:apr-1.6.3-11.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 centos-logos-httpd-85.8-1.el8.noarch httpd-2.4.37-39.module_el8.4.0+778+c970deab.x86_64 httpd-filesystem-2.4.37-39.module_el8.4.0+778+c970deab.noarch httpd-tools-2.4.37-39.module_el8.4.0+778+c970deab.x86_64 mod_http2-1.15.7-3.module_el8.4.0+778+c970deab.x86_64 Complete!
2、关闭防火墙
[root@redhat ~]# systemctl stop firewalld
3、启动服务
查看httpd状态(目前已经成功启动)
[root@redhat ~]# systemctl start httpd //启动
[root@redhat ~]# systemctl status httpd //查看状态
● httpd.service - The Apache HTTP ServerLoaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)Active: active (running) since Tue 2021-08-17 14:09:08 CST; 20s ago //running正在运行Docs: man:httpd.service(8)Main PID: 17932 (httpd)Status: "Running, listening on: port 80"Tasks: 213 (limit: 11076)Memory: 42.9MCGroup: /system.slice/httpd.service├─17932 /usr/sbin/httpd -DFOREGROUND├─17933 /usr/sbin/httpd -DFOREGROUND├─17934 /usr/sbin/httpd -DFOREGROUND├─17935 /usr/sbin/httpd -DFOREGROUND└─17936 /usr/sbin/httpd -DFOREGROUNDAug 17 14:09:03 redhat systemd[1]: Starting The Apache HTTP Server...
Aug 17 14:09:08 redhat httpd[17932]: AH00558: httpd: Could not reliably determine the server's>
Aug 17 14:09:08 redhat systemd[1]: Started The Apache HTTP Server.
Aug 17 14:09:14 redh
案例一:
要求搭建web服务器,能够访问到网页内容为“小胖,你咋这么胖呢!”
更改配置实现访问资源
[root@redhat ~]# vim /etc/httpd/conf.d/vhost.conf
1、vhost.conf配置文件内容
<VirtualHost 192.168.12.130:80>DocumentRoot /www/130ServerName 192.168.12.130
</VirtualHost>
<Directory /www>AllowOverride noneRequire all granted
</Directory>
2、根据配置文件创建对应的资源(文件)
[root@redhat ~]# mkdir -p /www/130
[root@redhat ~]# echo ”小胖你,你咋这么胖呢!“ > /www/130/index.html
3、重启httpd服务
[root@redhat ~]# systemctl start httpd
4、浏览器查看配置的资源
案例二:
创建基于域名的虚拟主机,能够使用www.xiaopang.com和www.dapang.com访问各自的网站网站存放路径分别为/xiaopang和/dapang,内容自定。
1、配置文件
[root@redhat ~]# vim /etc/httpd/conf.d/vhost.conf
2、vhost.conf配置文件内容
#<VirtualHost 192.168.12.130:80># DocumentRoot /www/130#ServerName 192.168.12.130
#</VirtualHost>
<VirtualHost 192.168.12.130:80>DocumentRoot /www/xiaopangServerName www.xiaopang.com
</VirtualHost><VirtualHost 192.168.12.130:80>DocumentRoot /www/dapangServerName www.dapang.com
</VirtualHost><Directory /www>AllowOverride noneRequire all granted
</Directory>
3、根据配置文件创建对应的资源(文件)
[root@redhat ~]# mkdir -p /www/{xiaopang,dapang}
[root@redhat ~]# echo this is xiaopang > /www/xiaopang/index.html
[root@redhat ~]# echo this is dapang > /www/dapang/index.html
4、重启httpd服务
[root@redhat ~]# systemctl restart httpd
5、临时关闭SELinux
设置SELinux 成为permissive模式 临时关闭selinux的
[root@redhat ~]# setenforce 0
6、进入我们的主 机配置
[root@redhat ~]# vim /etc/hosts
7、在里面添加我们的ip与域名
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.12.130 www.xiaopang.com
192.168.12.130 www.dapang.com
8、使用curl命令查看网页资源
[root@redhat ~]# curl www.xiaopang.com
this is xiaopang
[root@redhat ~]# curl www.dapang.com
this is dapang
如果要想在Windows的网页实现访问
则需要用nodepad++打开我们C:\Windows\System32\drivers\etc下的hosts文件,因为我们在对此文件进行操作时会需要权限而nodepad++刚好解决了这个问题,添加我们的IP 然后是对应的域名
网页输入域名结果如下
Linux之http服务基本配置案例相关推荐
- Linux下DHCP服务的配置相关参数说明
Linux下DHCP服务的配置相关参数说明 DHCP配置通常包括三部分:parameters.declarations.option. 1. parameters parameters用于说明DHCP ...
- 最新华为交换机配置ssh服务端配置案例
最新华为交换机配置ssh服务端配置案例 # aaa local-user dcrmyy password irreversible-cipher Huawei@123local-user dcrmyy ...
- Linux搭建samba服务及使用案例
简介 Samba服务------SMB协议 Samba协议基础 在NetBIOS 出现之后,Microsoft就使用NetBIOS实现了一个网络文件/打印服务系统,这个系统基于NetBIOS设定了一套 ...
- linux下NIS服务的配置
[NIS服务器端配置] 第一步:安装相关软件 安装第三张光盘中的ypserv-2.19-3和portmap-4.0-65.2.2.1,安装第二张光盘中的yp-tools-2.9.0.1和ypbind- ...
- linux中openssh服务搭建,配置OPenSSH服务器
一.安装机配置OPenSSH服务器 1.安装与启动OpenSSH 首先查询系统是否安装了与OpenSSH相关的软件包: #rpm -qa| grep openssh 安装完成后,可以使用下述命令启动: ...
- openstack运行系统环境基础配置以及安装openstack平台基础服务安装配置案例
目录 一,配置前环境准备及要求 三台节点的物理环境 二,网络规划如下图 三,部署操作系统及OpenStack运行环境 1,虚拟机系统配置(以下三台节点都做) 1.1主机名 1.2核心防护,防火墙关闭 ...
- Linux之SSH服务端配置文件安全设置
远程访问安全-SSH 如何才能让ssh更加安全? ssh安全性和配置最佳实践: * 将root账户仅限制为控制台访问,不允许ssh登录 # vim /etc/ssh/sshd_config Permi ...
- linux安装redis服务,配置PHP扩展
Redis安装 1,安装redis wget http://download.redis.io/releases/redis-3.0.5.tar.gz tar -zxvf redis-3.0.5.ta ...
- linux安装了vnc服务器,Linux安装VNC服务及配置
linux部署环境如果没有远程桌面,那就只有静默安装了,当然这有难度,不过有VNC很不错,远程桌面环境部署方便多了,环境还算清晰,速度不卡,部署平台完全没有问题,部署方式可以参考如下笔记: [root ...
- krb5安装包 linux_【RedHat Linux】kerberos 服务端配置
1. 安装软件包 # yum install krb5-server krb5-libs krb5-workstation 2. 修改配置文件 kdc.conf , krb5.conf # vi /v ...
最新文章
- golang如何打印float64的整数部分_2020-08-10:如何不用加减乘除求浮点数的2倍值?...
- 深入理解Java ClassLoader及在 JavaAgent 中的应用
- 掌握大数据数据分析师吗?_要掌握您的数据吗? 这就是为什么您应该关心元数据的原因...
- POJ 2299 - Ultra-QuickSort BIT
- Vuex 状态管理的工作原理
- 陌陌看好的移动营销 Criteo表示尚未成为主流
- opencv android 羽化,学习OpenCV:滤镜系列(15)——羽化(模糊边缘)
- react native 学习
- TCL_事务控制语言
- Struts2-02-OGNL及值栈
- 【数据预测】基于matlab双向长短时记忆(biLSTM)数据预测【含Matlab源码 1793期】
- ps零基础学习计算机,如何零基础学习PS?写给新手朋友的一些经验
- 基于C#的房屋租赁管理系统设计与实现
- Windows11右键桌面没新建
- WinForm大型企业ERP系统
- 一个运行成功的hibernate例子(解决一直报hibernate mapping exception的错误)
- 餐饮加盟行业怎么找加盟商?线上怎么引流?这几招教你线上低成本获客!
- Google Earth Engine——飓风最佳轨迹数据库(HURDAT2)。大西洋盆地1851-2018年。
- 【JDBC】JDBC
- vs2017开发ActiveX(主讲OCX)(七)、方法