26.Apache
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 在捣鬼。
最新文章
- 干货——myeclipse快捷键
- 【AS3】Flash与后台数据交换四种方法整理
- BCP command usage in SQL Server
- iOS 分类和继承
- 【HDOJ】4985 Little Pony and Permutation
- hdu 5094 Maze(水搜索)
- struts2讲义----建立一个struts2工程
- Hibernate 系列教程16-二级缓存
- 关于JS脚本语言的基础语法
- SQL列子 转载
- RSA 前段加密 java 后台解密 已调试通过
- jira8.0.2安装与破解
- 项目中遇到的IE8浏览器访问页面过慢问题
- 关于git提示“warning: LF will be replaced by CRLF”终极解答
- mysql存储引擎ARCHIVE
- css布局一屏幕的自适应高度
- 大数据入门第八天——MapReduce详解(三)MR的shuffer、combiner与Yarn集群分析
- Object C学习笔记8-字符串NSString之二
- Python中的内建函数(Built_in Funtions)
- 【线程】结果缓存实现(future与concurrenthashmap)
热门文章
- 备战金三银四!一线互联网公司java岗面试题整理:Java基础+多线程+集合+JVM合集!
- [论文阅读笔记] node2vec Scalable Feature Learning for Networks
- C#:使用连接字符串连接数据库
- Java NIO 缓冲区 Buffer
- 为什么.NET Standard 仍然有意义?
- Linux学习笔记 | 常见错误之VMware启动linux后一直黑屏
- zabbix自定义监控nginx
- 【Oracle】10g查看trace生成文件位置及文件名称
- 攻防世界—pwn—hello_pwn
- 实现简易版德州扑克|学习麻瓜编程以项目为导向入门前端 HTML+CSS+JS