Centos7之WEB服务器
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服务器的更多相关文章
- centos7作为web服务器优化
centos7作为web服务器优化 原文 http://itindex.net/detail/51140-centos7-web-服务器 1.加大打开文件数的限制(open files) 查看 uli ...
- centos7 搭建WEB服务器
centos7 搭建WEB服务器 2017年09月17日 09:44:50 逝然1994 阅读数:18321 标签: centosapacheweb服务器 更多 个人分类: centos服务器简单配置 ...
- 【小技巧解决大问题】使用 frp 突破阿里云主机无弹性公网 IP 不能用作 Web 服务器的限制
背景 今年 8 月份左右,打折价买了一个阿里云主机,比平常便宜了 2000 多块.买了之后,本想作为一个博客网站的,毕竟国内的服务器访问肯定快一些.满心欢喜的下单之后,却发现 http 服务,外网怎么 ...
- 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 ...
- Linux CentOS7系统配置nginx服务器
作为一个以服务器为主要市场的操作系统,主要就是对客户端的请求进行响应,进行处理的.在经历过系统镜像安装和本地配置好ssh功能后,接下来进行服务器的安装,这里我以nginx为主,介绍一下如何安装ngin ...
- nginx web服务器应用
Nginx介绍 Nginx是一个开源的,支持高性能,高并发的www服务和代理服务软件,因具有高并发(特别是静态资源),占用系统资源少等特性,且功能丰富而逐渐流行起来.功能应用上,Nginx不但是一个优 ...
- 基于Docker和Golang搭建Web服务器
1 场景描述 基于centos7的docker镜像搭建golang开发环境 在docker容器内,使用golang实现一个Web服务器 启动docker容器,并在容器内启动Web服务器 我购买了一个最 ...
- 阿里云部署自己的web服务器
阿里云部署自己的web服务器 [外链图片转存失败(img-GIKNTPPx-1564287221547)(https://upload-images.jianshu.io/upload_images/ ...
- 搭建一套简单的web服务器,记录实验过程
搭建web服务器 一.实验内容: 实验要求: 1.完成一个简单的web服务器,web服务器从mysql里读取数据进行返回 2.Mysql需要有一个单独的数据盘,每个mysql虚拟机的磁盘挂载方式需要都 ...
随机推荐
- PyQt学习笔记
---------------个人学习笔记--------------- 1.QtWidgets.QApplication.instance().quit() 方法可退出当前窗体 2.self.Qla ...
- mysql报错this is incompatible with sql_mode=only_full_group_by
1.报错信息 com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: In aggregated query without GROUP ...
- Java实例学习——企业进销存管理系统(4)
Java实例学习——企业进销存管理系统(4) (本实例为书上实例,我所记录的是我的学习过程) 开始时间:2月12日 完成时间:暂未完成 2月18日——系统主窗体设计 只看了学习视频 2月19日—— 回 ...
- js对secure的支持是没问题的,httponly是为限制js而产生的,当然httponly的cookie也不会被js创建
function setCookie4(c_name,value,expiredays){ var cookieStr = ""; var exdate=new Date(); e ...
- 配置ftp服务器
计算机管理->用户->添加用户 iis网站右键->添加ftp站点(没有此选项确认已安装及开启了ftp服务)->进行相关设置即可
- Android 桌面悬浮窗效果实现,仿360手机卫士悬浮窗效果
首先是一个小的悬浮窗显示的是当前使用了百分之多少的内存,点击一下小悬浮窗,就会弹出一个大的悬浮窗,可以一键加速.好,我们现在就来模拟实现一下类似的效果. 先谈一下基本的实现原理,这种桌面悬浮窗的效果很 ...
- SpringBoot的快速构建
1.http://start.spring.io2.Spring Tool Suite3.IntelliJ IDEA4.Spring Boot CLI5.Maven手工构建
- JNI教程
一.什么是JNI JNI(Java Native Interface ),它是Java SDK的一部分,主要用于实现Java对其他语言编写的代码和库的调用,比如C和C++.JNI提供的API也能让JV ...
- [Jira]启动报错无法删除缓存文件felix-cache的解决方法
背景: 由于公司机房停电,jira服务器在停电期间需要关机处理,然而待重启启动服务时,jira出现报错,页面报错信息如下: Unable to clean the cache directory: / ...
- LeetCode Remove Nth Node From End of List 删除链表的倒数第n个结点
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode ...