Ubuntu14.04配置Apache服务 (httpd-2.4.12)

2015-02-19 wcdj


摘要:本文主要记录在Ubuntu14.04环境下通过源码编译方式配置Apache服务,当然也可以简便使用包管理工具apt-get install apache2来安装Apache。

1, 下载apache
http://httpd.apache.org/download.cgi#apache24
wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.12.tar.gz

2, 安装依赖
(1) 下载apr
http://apr.apache.org/download.cgi
wget http://apache.dataguru.cn//apr/apr-1.5.1.tar.gz
./configure && make && make install

(2) 下载apr-util
wget http://apache.dataguru.cn//apr/apr-util-1.5.4.tar.gz
./configure --with-apr=/usr/local/apr && make && make install

(3) 安装pcre
http://ftp.exim.llorien.org/pcre/
wget http://ftp.exim.llorien.org/pcre/pcre-8.36.tar.gz
注意:Ubuntu默认并不提供C/C++的编译环境,因此在安装pcre前需要先在Ubuntu安装C/C++环境。
sudo apt-get install build-essential

3, 编译apache
./configure --enable-so --with-mpm=prefork && make && make install

  --with-mpm=MPM          Choose the process model for Apache to use by
                          default. MPM={event|worker|prefork|winnt} This will
                          be statically linked as the only available MPM
                          unless --enable-mpms-shared is also specified.
http://php.net/manual/en/install.unix.apache2.php

4, 修改apache配置
vi /usr/local/apache2/conf/httpd.conf
(1) 修改端口,由于本机80端口已被其他服务占用,故更换为其他端口:
Listen 8081
(2) 将ServerName节点的注释去除:
ServerName www.example.com:80

5, 运行apache
/usr/local/apache2/bin/apachectl start



6, 测试
http://104.131.173.242:8081/


注意:在Ubuntu上,源码安装apache的web root路径是/usr/local/apache2/htdocs,而apt-get方式安装的apache2的web root路径是/var/www/html,且日志目录为/var/log/apache2。


参考
http://httpd.apache.org/docs/2.4/
http://httpd.apache.org/docs/2.4/mod/directives.html





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值