ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

26.Apache

2020-09-17 17:00:39  阅读:169  来源: 互联网

标签:httpd 26 x86 00 html 64 Apache el7


1.Apache简介

  Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源代码的网页服务器软件,可以在大多数电脑操作系统中运行,由于其跨平台和安全性(尽管不断有新的漏洞被发现,但由于其开放源代码的特点,漏洞总能被很快修补。因此总合来说,其安全性还是相当高的。)。被广泛使用,是最流行的Web服务器软件之一。它快速、可靠并且可通过简单的API扩充,将Perl/Python等解释器编译到服务器中。

2.安装

  1)查看是否安装httpd  

[root@localhost ~]# rpm -qa httpd

  2)安装httpd  

[root@localhost ~]# yum install httpd* -y
Loaded plugins: fastestmirror, langpacks
base                                                                             | 3.6 kB  00:00:00     
extras                                                                           | 2.9 kB  00:00:00     
updates                                                                          | 2.9 kB  00:00:00     
updates/7/x86_64/primary_db                                                      | 4.5 MB  00:00:00     
Loading mirror speeds from cached hostfile
 * base: mirrors.bfsu.edu.cn
 * extras: mirrors.bfsu.edu.cn
。。。
Dependency Updated:
  cyrus-sasl.x86_64 0:2.1.26-23.el7                  cyrus-sasl-gssapi.x86_64 0:2.1.26-23.el7           
  cyrus-sasl-lib.x86_64 0:2.1.26-23.el7              cyrus-sasl-md5.x86_64 0:2.1.26-23.el7              
  cyrus-sasl-plain.x86_64 0:2.1.26-23.el7            cyrus-sasl-scram.x86_64 0:2.1.26-23.el7            
  expat.x86_64 0:2.1.0-11.el7                        libdb.x86_64 0:5.3.21-25.el7                       
  libdb-utils.x86_64 0:5.3.21-25.el7                 openldap.x86_64 0:2.4.44-21.el7_6                  

Complete!

  3)启动httpd服务,查看启动后的状态;   

[root@localhost ~]# systemctl start httpd.service 
[root@localhost ~]# systemctl status httpd.service 
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2020-09-15 11:36:25 CST; 11s ago
     Docs: man:httpd(8)
           man:apachectl(8)

 4)体验http服务  

[root@linuxprobe ~]# firefox

  地址栏中输入http://127.0.0.1

  

 

3.配置服务文件参数  

  在 httpd 服务程序的主配置文件中,存在三种类型的信息:注释行信息、全局配置、区域配置

  全局配置参数就是一种全局性的配置参数,可作用于对所有的子站点,既保证了子站点的正常访问,也有效减少了频繁写入重复参数的工作量。区域配置参数则是单独针对于每个独立的子站点进行设置的。

  1)httpd 服务程序的主要配置文件及存放位置

  

 

  2)配置httpd 服务程序时最常用的参数以及用途

    

  DocumentRoot 参数用于定义网站数据的保存路径,其参数的默认值是把网站数据存放到/var/www/html 目录中;而当前网站普遍的首页面名称是index.html,因此可以向/var/www/html 目录中写入一个文件,替换掉httpd 服务程序的默认首页面,该操作会立即生效。  

root@localhost html]# echo "hello, thank you" > /var/www/html/index.html

  

 

 3)在默认情况下,网站数据是保存在/var/www/html 目录中,将保存网站数据的目录修改为/home/wwwroot 目录:

    建立网站数据的保存目录,并创建首页文件。  

[root@localhost html]# mkdir /home/wwwroot
[root@localhost html]# echo "The New Web Directory" > /home/wwwroot/index.html

  打开httpd 服务程序的主配置文件,将约第119 行用于定义网站数据保存路径的参数DocumentRoot 修改为/home/wwwroot,同时还需要将约第124 行用于定义目录权限的参数Directory 后面的路径也修改为/home/wwwroot。配置文件修改完毕后即可保存并退出。  

[root@localhost html]# vim /etc/httpd/conf/httpd.conf 
DocumentRoot: The directory out of which you will serve your
116 # documents. By default, all requests are taken from this directory, but
117 # symbolic links and aliases may be used to point to other locations.
118 #
119 DocumentRoot "/home/wwwroot"
120
121 #
122 # Relax access to content within /var/www.
123 #
124 <Directory "/home/wwwroot">
125 AllowOverride None
126 # Allow open access:
127 Require all granted
128 </Directory>
………………省略部分输出信息………………

    重新启动httpd 服务程序并验证效果,浏览器刷新页面后的内容如图10-6 所示。在尝试访问http://127.0.0.1/index.html 页面时,竟然发现页面中显示“Forbidden,You don't have permission toaccess /index.html on this server.”。而这一切正是SELinux 在捣鬼。

 

标签:httpd,26,x86,00,html,64,Apache,el7
来源: https://www.cnblogs.com/xinghen1216/p/13686144.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有