1、安装httpd服务

  输入命令:yum -y install httpd

 [root@N37012 ~]# yum -y install httpc
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
No package httpc available.
Error: Nothing to do
[root@N37012 ~]# yum -y install httpd
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 :2.4.-.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.-.el7.centos for package: httpd-2.4.-.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.-.el7.centos.x86_64
--> Processing Dependency: libaprutil-.so.()(64bit) for package: httpd-2.4.-.el7.centos.x86_64
--> Processing Dependency: libapr-.so.()(64bit) for package: httpd-2.4.-.el7.centos.x86_64
--> Running transaction check
---> Package apr.x86_64 :1.4.-.el7_4. will be installed
---> Package apr-util.x86_64 :1.5.-.el7 will be installed
---> Package httpd-tools.x86_64 :2.4.-.el7.centos will be installed
---> Package mailcap.noarch :2.1.-.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================
Installing:
httpd x86_64 2.4.-.el7.centos updates 2.7 M
Installing for dependencies:
apr x86_64 1.4.-.el7_4. os k
apr-util x86_64 1.5.-.el7 os k
httpd-tools x86_64 2.4.-.el7.centos updates k
mailcap noarch 2.1.-.el7 os k Transaction Summary
========================================================================================================================================================
Install Package (+ Dependent packages) Total download size: 3.0 M
Installed size: M
Downloading packages:
(/): httpd-tools-2.4.-.el7.centos.x86_64.rpm | kB ::
(/): apr-1.4.-.el7_4..x86_64.rpm | kB ::
(/): apr-util-1.5.-.el7.x86_64.rpm | kB ::
(/): mailcap-2.1.-.el7.noarch.rpm | kB ::
(/): httpd-2.4.-.el7.centos.x86_64.rpm | 2.7 MB ::
--------------------------------------------------------------------------------------------------------------------------------------------------------
Total 3.0 MB/s | 3.0 MB ::
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.-.el7_4..x86_64 /
Installing : apr-util-1.5.-.el7.x86_64 /
Installing : httpd-tools-2.4.-.el7.centos.x86_64 /
Installing : mailcap-2.1.-.el7.noarch /
Installing : httpd-2.4.-.el7.centos.x86_64 /
Verifying : httpd-tools-2.4.-.el7.centos.x86_64 /
Verifying : mailcap-2.1.-.el7.noarch /
Verifying : httpd-2.4.-.el7.centos.x86_64 /
Verifying : apr-1.4.-.el7_4..x86_64 /
Verifying : apr-util-1.5.-.el7.x86_64 / Installed:
httpd.x86_64 :2.4.-.el7.centos Dependency Installed:
apr.x86_64 :1.4.-.el7_4. apr-util.x86_64 :1.5.-.el7 httpd-tools.x86_64 :2.4.-.el7.centos mailcap.noarch :2.1.-.el7 Complete!
[root@N37012 ~]#

2、配置

Apache 主要的配置文件是 /etc/httpd/conf/httpd.conf 。 它包含许多在基本安装中不需要更改的配置。 实际上,只需对此文件进行一些更改即可启动并运行一个简单的网站。

3、监听端口

第一个要修改的是 Listen 配置项,它定义了 Apache 要监听页面请求的 IP 地址和端口。 现在,你只需要使这个网站可以从本地访问,所以使用 localhost 地址。 完成后,该行应该看起来像这样(位置大概在42行)

#Listen 12.34.56.78:80
Listen 127.0.0.1:80

通过将此配置项设置为 localhost 的 IP 地址,Apache 将只侦听来自本地主机的连接。 如果您希望 Web 服务器侦听来自远程主机的连接,则可以使用主机的外部 IP 地址。

4、网页页面html文件位置

DocumentRoot 配置项指定组成网站页面的 HTML 文件的位置。 该配置项不需要更改,因为它已经指向标准位置。 该行应该看起来像这样(位置大概在119行)

DocumentRoot "/var/www/html"

如果想更改存储网站文件的位置,可修改此配置项完成。例如改成/var/myhtml/html

DocumentRoot "/var/myhtml/html"

5、防火墙设置

  查看防火墙状态

 [root@N37012 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
Docs: man:firewalld()
[root@N37012 ~]#

  启动防火墙

 [root@N37012 ~]# systemctl start firewalld.service
[root@N37012 ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Sun -- :: CST; 1s ago
Docs: man:firewalld()
Main PID: (firewalld)
CGroup: /system.slice/firewalld.service
└─ /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid May :: N37012 systemd[]: Starting firewalld - dynamic firewall daemon...
May :: N37012 systemd[]: Started firewalld - dynamic firewall daemon.
[root@N37012 ~]#

  开放TCP的80端口,并重载防火墙

 [root@N37012 ~]# firewall-cmd --zone=public --add-port=/tcp --permanent
success
[root@N37012 ~]# firewall-cmd --reload
success
[root@N37012 ~]#

  查看防火墙开放端口

 [root@N37012 ~]# firewall-cmd --zone=public --list-ports
/tcp
[root@N37012 ~]#

6、创建index.html文件

  index.html文件是使用域名访问网站而不是访问特点网页时的默认文件。在/var/www/html中。

  创建index.html文件并输入文字hello word~

  输入命令:chown apache index.html

7、查看Apache状态,如未启动。则启动

 [root@N37012 html]# 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()
man:apachectl()
[root@N37012 html]# systemctl start httpd
[root@N37012 html]# 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 Sun -- :: CST; 4s ago
Docs: man:httpd()
man:apachectl()
Main PID: (httpd)
Status: "Processing requests..."
CGroup: /system.slice/httpd.service
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
├─ /usr/sbin/httpd -DFOREGROUND
└─ /usr/sbin/httpd -DFOREGROUND May :: N37012 systemd[]: Starting The Apache HTTP Server...
May :: N37012 httpd[]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 172.30.0.3....s message
May :: N37012 systemd[]: Started The Apache HTTP Server.
Hint: Some lines were ellipsized, use -l to show in full.
[root@N37012 html]#

8、访问web服务器

在Chrome或IE浏览器地址栏中输入Apache地址。即可访问到本机

Centos7之WEB服务器的更多相关文章

  1. centos7作为web服务器优化

    centos7作为web服务器优化 原文 http://itindex.net/detail/51140-centos7-web-服务器 1.加大打开文件数的限制(open files) 查看 uli ...

  2. centos7 搭建WEB服务器

    centos7 搭建WEB服务器 2017年09月17日 09:44:50 逝然1994 阅读数:18321 标签: centosapacheweb服务器 更多 个人分类: centos服务器简单配置 ...

  3. 【小技巧解决大问题】使用 frp 突破阿里云主机无弹性公网 IP 不能用作 Web 服务器的限制

    背景 今年 8 月份左右,打折价买了一个阿里云主机,比平常便宜了 2000 多块.买了之后,本想作为一个博客网站的,毕竟国内的服务器访问肯定快一些.满心欢喜的下单之后,却发现 http 服务,外网怎么 ...

  4. Centos7搭建邮件服务器-Postfix+Cyrus-sasl+Courier-authlib+Dovecot+ExtMail+Centos7

    1.环境介绍 MTA: Postfix 3.1.4 SASL: Cyrus-sasl 2.1.26 ; Courier-authlib 0.66.1(Cyrus-sasl使用Courier-authl ...

  5. Linux CentOS7系统配置nginx服务器

    作为一个以服务器为主要市场的操作系统,主要就是对客户端的请求进行响应,进行处理的.在经历过系统镜像安装和本地配置好ssh功能后,接下来进行服务器的安装,这里我以nginx为主,介绍一下如何安装ngin ...

  6. nginx web服务器应用

    Nginx介绍 Nginx是一个开源的,支持高性能,高并发的www服务和代理服务软件,因具有高并发(特别是静态资源),占用系统资源少等特性,且功能丰富而逐渐流行起来.功能应用上,Nginx不但是一个优 ...

  7. 基于Docker和Golang搭建Web服务器

    1 场景描述 基于centos7的docker镜像搭建golang开发环境 在docker容器内,使用golang实现一个Web服务器 启动docker容器,并在容器内启动Web服务器 我购买了一个最 ...

  8. 阿里云部署自己的web服务器

    阿里云部署自己的web服务器 [外链图片转存失败(img-GIKNTPPx-1564287221547)(https://upload-images.jianshu.io/upload_images/ ...

  9. 搭建一套简单的web服务器,记录实验过程

    搭建web服务器 一.实验内容: 实验要求: 1.完成一个简单的web服务器,web服务器从mysql里读取数据进行返回 2.Mysql需要有一个单独的数据盘,每个mysql虚拟机的磁盘挂载方式需要都 ...

随机推荐

  1. Linux--6 redis订阅发布、持久化、集群cluster、nginx入门

    一.redis发布订阅 Redis 通过 PUBLISH .SUBSCRIBE 等命令实现了订阅与发布模式. 其实从Pub/Sub的机制来看,它更像是一个广播系统,多个Subscriber可以订阅多个 ...

  2. Spark (Python版) 零基础学习笔记(二)—— Spark Transformations总结及举例

    1. map(func) 将func函数作用到数据集的每个元素,生成一个新的分布式的数据集并返回 >>> a = sc.parallelize(('a', 'b', 'c')) &g ...

  3. DNS A记录 CNAME NS记录等的区别

    DNS域名解析 tracetrt dig A记录 将此域名绑定到固定ip C记录 将此域名绑定到另一个域名上,通常是A记录的别名 AAAA记录 用来绑定ipv6地址 https://www.ezloo ...

  4. 配置了SSH后还是每次都要求输入密码

    保存凭证可以解决问题 git config --global credential.helper store

  5. 禁用thinkpad触摸板的方法

    控制面板----硬件和声音----设备和打印机----鼠标----ThinkPad------开启触摸板(前面的勾勾去掉)

  6. GraphQL实战经验和性能问题的解决方案

    在现在的公司使用GraphQL有一段时间了. 现公司从创立之后的很长一段时间内是纯PHP的技术栈,前端.后端都在PHP代码中糅合在一起.新功能越加越多,页面越来越复杂之后,那些混在在PHP代码中的HT ...

  7. python 发布

    使用distutils.core.setup函数发布程序 将要发布的包放到mypub的目录下 在mypub目录下创建一个setup.py文件 setup.py文件的设置 from distutils. ...

  8. MVVM技术 - 的实现 @{}来进行 调用那个 DataBinding方法

    new Material Design 支持哭 还有 Data Binding 结束   使用DataBindign 结束 我们很方面的实现 MVVM设计模式   什么是MVVM model 呢.   ...

  9. git从安装到应用的学习

    本文内容是对廖雪峰老师Git教程做的笔记,外加一些自己的学习心得,还抱着学以致用的心态来实践一番 Git学习笔记 分布式版本控制与集中式版本控制的最大区别 集中式的版本控制,本地没有历史记录,完整的仓 ...

  10. java 整型相除得到浮点型

    public class TestFloatOrDouble { public static void main(String[] args) { Point num1 = new Point(84, ...