这里给出官方的安装步骤,采用的是编译安装方式。
[Download](http://httpd.apache.org/docs/2.4/install.html#download)
$ lynx http://httpd.apache.org/download.cgi
[Extract](http://httpd.apache.org/docs/2.4/install.html#extract)
$ gzip -d httpd-NN.tar.gz
$ tar xvf httpd-NN.tar
$ cd httpd-NN
[Configure](http://httpd.apache.org/docs/2.4/install.html#configure)
$ ./configure --prefix=PREFIX
[Compile](http://httpd.apache.org/docs/2.4/install.html#compile)
$ make
[Install](http://httpd.apache.org/docs/2.4/install.html#install)
$ make install
[Customize](http://httpd.apache.org/docs/2.4/install.html#customize)
$ vi PREFIX/conf/httpd.conf
[Test](http://httpd.apache.org/docs/2.4/install.html#test)
$ PREFIX/bin/apachectl -k start
[Download]
官方下载地址:
$ wget http://mirror.bit.edu.cn/apache/httpd/httpd-xxx.tar.gz
[Extract]
$ tar zvf httpd-xxx.tar.gz//解压文件
[Configure]
$ ./configure --prefix=/usr/local/apache//这里是安装目录
[Compile]
$ make
[Install]
$ make install
常见命令
- 启动:PREFIX/bin/apachectl -k start
- 停止:PREFIX/bin/apachectl -k stop
- 重启:PREFIX/bin/apachectl -k restart
- 优雅重启:PREFIX/bin/apachectl -k graceful
- 优雅停止:PREFIX/bin/apachectl -k graceful-stop
常见错误
提示找不到配置文件,并且加载的配置文件路径并不在安装的Apache路径下面。(可能原因是编译多次,第一次未指定编译路径,第二次又指定了路径)
![](https://img.haomeiwen.com/i1935339/e60f78c512453406.png)
httpd被调用后第一件要做的事情就是找到并读取配置文件httpd.conf 。此文件的位置是在编译时设定的,但也可以象下面这样在运行时用 -f 选项来指定:
$ PREFIX1/bin/apachectl -f PREFIX2/conf/httpd.conf
网友评论