---
title: "在Ubuntu上建立服务器环境(3):编译安装Apache，配置其在webmin里可用"
author: "ycyk_168"
date: "2009-11-04T15:14:00Z"
tags: ["Access", "Apache", "GCC", "MySQL", "Ubuntu"]
slug: "ubuntu-3-apache-webmin"
draft: false
lastmod: "2009-11-11T15:16:51Z"
id: 514564
url: "https://ycyk168.iteye.com/blog/514564"
---

如果使用apt-get的方式安装apache，会发现apache的安装目录很乱，而且并不是按照默认的apache目录结构组织的，这给后期的配置造成了很大麻烦！  
在编译安装apache之前，需要确定您的系统是否已经安装gcc编译环境和Zlib，如果没有安装您可以通过以前几步安装：  
1、安装gcc：sudo apt-get build-dep gcc  
2、安装zlib：apt-get install zlib1g-dev  
3、下载apache2.2.14： sudo wget http://labs.xiaonei.com/apache-mirror/httpd/httpd-2.2.14.tar.gz  
4、解压apache：sudo tar -zxvf httpd-2.2.14.tar.gz  
5、进入解压出来的apache目录：  
sudo ./configure --prefix=/usr/server/apache --with-mysql=/usr/share/mysql --enable-so --enable-track-vars --enable-rewrite --with-zlib --enable-mods-shared=all --enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/var/www/wwwsource  
其中后面是三个参数：--enable-suexec --with-suexec-caller=daemon --with-suexec-docroot=/var/www/wwwsource是为安装Extmail而准备的  
6、sudo make  
7、sudo make install  
8、设置apache开机自启动：  
  1)复制 /usr/server/apache/bin/apachectl到/etc/init.d  
  2)加载为服务  
       sudo update-rc.d apachectl defaults  
9、在webmin里设置apache模块，因为webmin中默认的设置是按照apt-get安装apache的方式设置的，所以需要做适当的改动  
  1)增加虚拟服务器的文件：/usr/server/apache/conf/extra/httpd-vhosts.conf  
  2)Directory to create links in for new virtual servers 设为none  
  3)Apache服务器根目录：/usr/server/apache  
  4)httpd执行文件路径：/usr/server/apache/bin/httpd  
  5)命令apachectl的路径：/usr/server/apache/bin/apachectl  
  6)启动apache命令：/usr/server/apache/bin/apachectl start  
  7)停止apache命令：/usr/server/apache/bin/apachectl stop  
  8)Command to apply configuration设为：/usr/server/apache/bin/apachectl  
  9)httpd.conf的路径：/usr/server/apache/conf/httpd.conf  
  10)srm.conf的路径设为自动  
  11)access.conf的路径设为自动  
  12)mime.types的路径设为：/usr/server/apache/conf/mime.types  
  13)Environment file defining Apache variables 设为；None