httpd服务
apache和nginx都可以作为web服务器,但nginx用的更多
- 性能: Nginx通常被认为在处理并发连接和静态内容时更有效率。
- 配置: Apache的配置相对更复杂,而Nginx的配置更直观和简洁。
- 用途: Apache广泛用于传统的Web服务器角色,而Nginx通常用于高性能的反向代理和负载均衡。
httpd
是 Apache HTTP Server 的主要执行文件,也是它的二进制可执行文件,被用作 Apache Web服务器的守护进程。Apache HTTP Server是Apache软件基金会的一个开放源码的Web服务器软件
apache官网:http://httpd.apache.org
参考https://blog.csdn.net/m0_57776598/article/details/123605600
下载
安装epel源
yum install epel-release -y
安装httpd
yum install httpd -y
重要文件
/etc/httpd 服务目录
/etc/httpd/conf/httpd.conf 主配置文件
/var/www/html 网站数据目录
/var/log/httpd/access_log 访问日志
/var/log/httpd/error_log 错误日志
配置文件中的参数
# apache的安装根目录
ServerRoot "/etc/httpd"# 监听的端口号
Listen 80# 虚拟主机配置(默认)
<VirtualHost *:80>ServerAdmin webmaster@localhost # 管理员邮箱DocumentRoot "/var/www/html" # 网站数据目录ServerName localhost # 虚拟主机的域名或IPErrorLog "/var/log/httpd/error_log" # 错误日志CustomLog "/var/log/httpd/access_log" common # 访问日志
</VirtualHost># 指定运行apache进程的用户
User apache
# 指定有运行apache进程的用户组
Group apache# 默认的目录索引文件,可以指定多个文件,服务器将按顺序查找
# 当访问一个目录时,若没有指定文件名,服务器就会尝试显示index.html
DirectoryIndex index.html# 目录权限配置
<Directory "/var/www/html">Options Indexes FollowSymLinks # 目录的选项,允许列出目录内容和遵循符号链接AllowOverride None # 允许使用.htaccess文件覆盖配置Require all granted # 目录访问权限
</Directory># 网页超时时间
Timeout 300