centos8安装httpd教程
时间: 2024-11-02 07:06:59 浏览: 42
在CentOS 8系统上安装Apache HTTP服务器(HTTPD,通常称为Apache)是一个常见的任务,因为Apache是最流行的Web服务器软件之一。以下是详细的步骤:
1. **更新包列表**:
```bash
sudo yum update -y
```
2. **安装Epel Repository (可选)**:
如果您的系统不是默认仓库包含的软件包,可能需要添加额外的存储库来获取Apache。运行以下命令:
```bash
sudo curl -o /etc/yum.repos.d/epel.repo https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo rpm -Uvh epel-release-latest-8.noarch.rpm
```
3. **安装Apache**:
使用`yum`命令安装Apache:
```bash
sudo yum install httpd -y
```
安装过程中可能会提示设置安全配置文件,按提示操作即可。
4. **启动服务**:
```bash
sudo systemctl start httpd
```
5. **检查服务状态**:
```bash
sudo systemctl status httpd
```
确保状态显示为"active (running)"。
6. **配置防火墙**:
防火墙可能阻止了HTTP端口访问,可以暂时关闭防火墙,或者允许80端口:
```bash
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --reload
```
7. **查看默认站点**:
```bash
sudo nano /etc/httpd/conf.d/default.conf
```
修改DocumentRoot目录为合适的网站根目录(如/var/www/html),然后保存并退出。
8. **重启服务以应用更改**:
```bash
sudo systemctl restart httpd
```
阅读全文
相关推荐
















