1.安装
yum install httpd(安装Apache,一般Fedora会默认安装)
systemctl start/stop httpd(启动/关闭apache)
systemctl enable httpd(添加至启动项)
2.配置
note:apache的默认文档目录是/var/www/html;默认配置路径是/etc/httpd/conf/httpd.conf和默认自定义配置路径是/etc/httpd/conf.d/*.conf
自定义配置优先,且按字母顺序以名称排在最后的为启动配置,例:../conf.d/b.conf会覆盖../conf.d/a.conf
<1>ServerRoot path
Apache安装路径

<2>listen ip&port
设置绑定的IP和端口,如果不设置默认是使用使用所有ip和80/443端口

<3>Dynamic Shared Object (DSO) Support
动态共享对象支持,添加一些动态模块通过LoadModule **/**.so
note:这些的模块可在安装目录/conf/modules.d/*.conf中找到

<4>设置运行的用户和组
默认用户和组是apache,这里权限很重要,设置管理员用户和组要慎重。

<5>ServerAdminEmailAddress
设置管理员邮箱,以便及时发送问题给管理员

<6>server domain
域名设置,没有域名写个IP或不写也行

<7>根目录权限设置
使用<Directory />....</Directory>来为目录设置权限

<8>根目录路径设置和更多权限设置
设置根目录路径

权限设置,可使用默认值,更多细节可以访问http://httpd.apache.org/docs/2.4/mod/core.html#options

<9>网站默认主页
格式如下图,设置的主页文件要存在

<10>.htaccess 和.htpasswd文件的保护
此项设置保护.htacess & .htpasswd不被客户端访问到,所有使用Require all denied

<11>errorlog path
设置的日志文件一般在"安装路径/logs"目录下

<12>loglevel(日志等级设置)
分为debug,info,notice,warn,error,crit,alert,emerg几个等级

<13>更多日志设置

<10>alias,cgi设置
网页别名,脚本别名设置,CGI权限设置

<11>添加文件类型,编码,脚本,过滤机制相关设置

<12>设置默认编码
一般为UTF-8

<13>错误响应
错误响应又三种方式:1,响应明文
2,导向新的本地URL
3,导向外部URL
例子如图片中:

<14>MMAP & Sendfile 功能的开启与关闭
使用默认值即可,有些系统不支持这两项

<15>其他设置


Addition:
official document:http://httpd.apache.org/docs/2.4
网友评论