相关内容:
1. yum 安装 MySQL;
2. yum 安装 PHP;
3. yum 安装 Nginx 以及相关配置;
4. yum 安装 Apache 以及相关配置(本篇);
卸载 CentOS 自带的 Apache
# 查询进程
ps -ef | grep httpd
yum list installed | grep httpd
# 卸载
yum remove httpd.x86_64 httpd-tools.x86_64 -y
安装 Apache
yum search httpd
yum install httpd
systemctl stop nginx
systemctl start httpd
systemctl enable httpd.service #开机自启动
修改 Apache 配置文件
# 查找配置文件,关键字 root,获取代码目录
vim /etc/httpd/conf/httpd.conf
/root
# 创建 PHP 测试文件
vim /var/www/html/index.php
# 写入测试内容
<?php
phpinfo();
?>
# 重启
yum install php
systemctl restart httpd
配置虚拟主机、开启 80 端口(可选配置项)
vim /etc/httpd/conf.d/vhost.conf
搞定!