Linux 下 Apache

本文详细介绍了在Linux系统中如何安装Apache,设置URL指定目录,配置HTTPS服务以及深入解析Options指令,帮助用户全面了解和优化Apache服务器。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装

yum install httpd     #根据提示,输入Y安装即可成功安装

service httpd start   #启动Apache
备注:Apache启动之后会提示错误:

正在启动 httpd:httpd: Could not reliably determine the server's fully qualif domain name, using ::1 for ServerName
解决办法:

vi /etc/httpd/conf/httpd.conf #编辑

找到 #ServerName www.example.com:80

修改为 ServerName www.yujiawei.com:80 #这里设置为你自己的域名,如果没有域名,可以设置为localhost

:wq! #保存退出
chkconfig httpd on #设为开机启动

url指定目录

NameVirtualHost *:80//去掉注释

<VirtualHost *:8090>
    DocumentRoot /var/www/html/Life/public/
    ServerName life.y-jw.cn
</VirtualHost>

配置Apache的HTTPS服务

# yum install mod_ssl openssl

一些配置

vi /etc/httpd/conf/httpd.conf #编辑文件
ServerTokens OS  #在44行 修改为:ServerTokens Prod (在出现错误页的时候不显示服务器操作系统的名称)
ServerSignature On  #在536行 修改为:ServerSignature Off (在错误页中不显示Apache的版本)
Options Indexes FollowSymLinks  #在331行 修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)
#AddHandler cgi-script .cgi #在796行 修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)
AllowOverride None  #在338行 修改为:AllowOverride All (允许.htaccess)
Options Indexes MultiViews FollowSymLinks #在554行 修改为 Options MultiViews FollowSymLinks(不在浏览器上显示树状目录结构)
DirectoryIndex index.html index.html.var #在402行 修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var (设置默认首页文件,增加index.php)
KeepAlive Off #在76行 修改为:KeepAlive On (允许程序性联机)
MaxKeepAliveRequests 100 #在83行 修改为:MaxKeepAliveRequests 1000 (增加同时连接数)
:wq! #保存退出

Options指令详解

这里写图片描述
这里写图片描述
这里写图片描述

参考链接:http://www.365mini.com/page/apache-options-directive.htm

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值