/usr/local/apache2/conf
目录下/etc/httpd/conf/httpd.conf
目录下dnf install httpd -y
systemctl stop firewalld
setenforce 0 #临时关闭
cp /etc/httpd/conf/httpd.conf{,.bak}
rm -f /etc/httpd/conf/httpd.conf
egrep -v "^ *#|^$" httpd.conf.bak > httpd.conf
/etc/httpd/conf/httpd.conf
<!--ServerRoot设置Apache软件的安装主目录,在这里是/etc/httpd目录-->
ServerRoot "/etc/httpd"
<!--格式:Listen [IP地址:]端口 [协议]-->
Listen 80
<!--通常在ServerRoot目录下的modules目录中,用于存放模块,文件后缀.so。如果希望Apache动态加载模块,需要在编译的时候通过--enable-so将mod_so以静态的方式编译到Apache的核心模块中。-->
<!--加载其他附加配置文件的路径。-->
Include conf.modules.d/*.conf
<!--指定Apache运行用户。-->
User apache
<!--指定Apache运行用户组。-->
Group apache
<!--用于收集客户问题反馈的邮箱。-->
ServerAdmin root@localhost
<Directory />
AllowOverride none
Require all denied
</Directory>
<!--Web服务对客户端开放可见文档的根目录,即是访问网站的根路径。-->
DocumentRoot "/var/www/html"
<!--设置DocumentRoot指定目录的属性。-->
<Directory "/var/www">
AllowOverride None
Require all granted
</Directory>
<Directory "/var/www/html">
<!--找不到主页时,以目录的方式呈现。-->
Options Indexes FollowSymLinks
<!--none表示不使用,all表示允许,.htaccess控制。-->
AllowOverride None
<!--granted允许所有访问,denied拒绝所有访问。-->
Require all granted
</Directory>
<IfModule dir_module>
<!--定义主页文件,在这里是index.html-->
DirectoryIndex index.html
</IfModule>
<Files ".ht*">
Require all denied
</Files>
<!--定位服务器错误日志的位置,默认在ServerRoot目录下的log/error_log。-->
ErrorLog "logs/error_log"
<!--等级比warn高的日志才会被记录下来。-->
LogLevel warn
<IfModule log_config_module>
<!--日志格式,可自定义。-->
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
<IfModule logio_module>
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>
<!--这个是客户端的访问日志。-->
CustomLog "logs/access_log" combined
</IfModule>
<IfModule alias_module>
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
</IfModule>
<Directory "/var/www/cgi-bin">
AllowOverride None
Options None
Require all granted
</Directory>
<IfModule mime_module>
TypesConfig /etc/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</IfModule>
<!--设置网站字符编码。-->
AddDefaultCharset UTF-8
<IfModule mime_magic_module>
MIMEMagicFile conf/magic
</IfModule>
EnableSendfile on
IncludeOptional conf.d/*.conf
vim httpd.conf
ErrorDocument 404 http://www.new404.com #重定向到一个新的404页面。
(后续待补充)
原文:https://www.cnblogs.com/Skybiubiu/p/14964818.html