共计 2035 个字符,预计需要花费 6 分钟才能阅读完成。
CentOS 下编译安装 Apache
卸载原有的 apache
首先从 http://httpd.apache.or 下载 apache 源码包 httpd-2.4.4.tar.gz
然后从 http://apr.apache.org 下载 apr-1.4.6.tar.gz 和 apr-util-1.5.1.tar.gz
然后从 http://sourceforge.net/ 下载 pcre-8.32.tar.gz 和 pcre-devel-8.32.tar.gz
先装 gcc 和 make
yum -y install gcc
yum -y install make
yum -y install gcc-c++ 没有这个 gcc-c++ 一会编译不 prce
切到下载好的源码包目录, 本人是~/Download
安装 apr:
tar -zvxf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure –prefix=/usr/local/apr
make && make install
安装 apr-util
tar -zvxf apr-util-1.5.1.tar.gz
cd apr-util-1.5.1
./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
make && make install
安装 pcre
tar -zvxf pcre-8.32.tar.gz
cd pcre-8.32
./configure
make && make install
安装 pcre-devel
如果已经安装好了 pcre 一定要安装
tar –zxvf pcre-devel-8.32.tar.gz
cd pcre-devel-8.32
./configure
make && make install
安装 apache 一定要先装上面那三个不然编译不了
tar -zvxf httpd-2.4.4.tar.gz
cd httpd-2.4.4
./configure –prefix=/usr/local/apache –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util
make && make install
配置 /usr/local/apache/conf 下的 http.conf 文件 (先备份)。
1、服务器
#ServerName www.example.com:80 前的 #号删除。
2、目录访问权限
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all #修改为此样
</Directory>
3、默认字符集
AddDefaultCharset utf-8 #指定默认字符集
4、启动 httpd
cd bin/
./apachectl start | restart | stop
将 httpd 添加为系统服务
cp apachectl /etc/init.d/httpd
/etc/init.d/
编辑 httpd,在第二行加入如下信息:
# chkconfig: 345 85 15
# description: Activates/Deactivates Apache Web Server
以上两句必须添加,否则会提示“httpd 服务不支持”;第一行 3 个数字参数意义分别为:哪些 Linux 级别需要启动 httpd(3,4,5);启动序号 (85);关闭序号 (15)。
添加启动信息 (Ubuntu 与 CentOS 有区别)
chkconfig –add httpd
查看是否添加成功
chkconfig –list
服务器控制
service httpd start | restart | stop
Ubuntu Server 14.04 安装 Web 服务器 (Linux+Apache+MySQL+PHP) http://www.linuxidc.com/Linux/2015-06/119061.htm
Linux 下安装配置 PHP 环境 (Apache2) http://www.linuxidc.com/Linux/2015-05/118062.htm
Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm
CentOS 5.9 下编译安装 LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm
RedHat 5.4 下 Web 服务器架构之源码构建 LAMP 环境及应用 PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm
Apache 的详细介绍 :请点这里
Apache 的下载地址 :请点这里
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2016-03/128956.htm
