---
title: "Apache（二）启动/停止   工具介绍"
author: "mzl0517"
date: "2012-03-24T18:07:39Z"
tags: []
categories: ["开源软件"]
slug: "apache"
draft: false
lastmod: "2012-03-24T18:28:44Z"
id: 1461034
url: "https://roteg.iteye.com/blog/1461034"
---

## 启动/停止Apache HttpServer

 

一、进入目录prefix/bin

 

通过执行 apachectl 控制apache；apachectl在运行时会设置一些必要的环境变量信息，以保证

 

httpd能正确的运行，然后再调用httpd。

 

二、修改prefix/conf/httpd.conf

 

把ServerName取消注释，并设置ServerName的值

 

三、apachectl（httpd）的部分运行参数

 

若apache配置为开机启动，则参数设置：[http://httpd.apache.org/docs/2.4/programs/apachectl.html](http://httpd.apache.org/docs/2.4/programs/apachectl.html)

 

若手动启动apache，则参数设置：[http://httpd.apache.org/docs/2.4/programs/httpd.html](http://httpd.apache.org/docs/2.4/programs/httpd.html)

 

-f  指定配置文件，默认文件是 prefix/conf/httpd.conf

 

start  | restart | graceful | stop | graceful-stop  

 

四、访问

 

可通过IP访问，默认会显示 It works!

 

 

五、Apache HTTP服务器与支持程序

[http://httpd.apache.org/docs/2.4/programs/](http://httpd.apache.org/docs/2.4/programs/)