​准备工作

  1. 先确保你的电脑上有管理员权限
  2. 准备好编译环境,需要安装gcc、make这些基础工具
  3. 下载好httpd-2.4.1.tar.gz文件,下载链接:https://pan.quark.cn/s/180a9ef8d2a3

具体安装步骤

  1. 解压文件
tar -zxvf httpd-2.4.1.tar.gz
  1. 进入解压后的目录
cd httpd-2.4.1
  1. 配置安装选项
./configure --prefix=/usr/local/apache2

(这里/usr/local/apache2是安装目录,你可以改成自己想装的位置)

  1. 编译源代码
make
  1. 安装
sudo make install
  1. 启动Apache
/usr/local/apache2/bin/apachectl start

安装后检查

  1. 打开浏览器访问 http://localhost
  2. 如果看到"It works!"页面,说明安装成功了

常用命令

停止服务: /usr/local/apache2/bin/apachectl stop
重启服务: /usr/local/apache2/bin/apachectl restart


小童童
1 声望0 粉丝