LAMP之apache安装

环境:CentOS 64-bit ;

安装包:apr-1.4.6.tar.gz ;apr-util-1.4.1.tar.gz ;pcre-8.30.zip ;httpd-2.4.6.tar.gz;


 

前言:因为是一个全新的系统,所以各种包都没有,从头开始,安装的时候,都是检错一步一步来,最后安装起来的。


 

切换root用户:su - root

1.安装apr

tar zxvf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure -prefix=/usr/local/apr make make install

2.安装apr-util

tar zxvf apr-util-1.4.1.tar.gz 
cd apr-util-1.4.1
./configure -prefix=/usr/loacal/apr-util --with-apr=/usr/local/apr
make
make install

3.安装pcre

unzip pcre-8.30.zip 
cd pcre-8.30
./configure -prefix=/usr/local/pcre
make
make install

4.安装httpd

tar zxvf httpd-2.4.6.tar.gz
cd httpd-2.4.6
./configure -prefix=/usr/local/apache --enable-module=shared --enable-cgi --with-apr=/usr/local/apr --with-apr-util=/usr/lcoal/apr-util --with-pcre=/usr/local/pcre
make
make install

5.创建远连接

ln -s /usr/local/apache/bin/* /usr/local/bin/                        //创建远连接
ll /usr/local/bin/httpd /usr/local/bin/apachectl                    //检查远连接

//不创建远连接,可能导致后面直接执行:apachectl start ,出现httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

6.添加系统服务

cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

7.配置启动脚本

vim /etc/init.d/httpd
在文档第二行添加
#chkconfig: 35 85 15 
#description: welcome to apache    //description: 随便添加内容,然后保存,退出

8.检查httpd状态

chkconfig --add httpd
chkconfig --list httpd      //如果 3,5两项off,则执行#chkconfig --level 35 httpd on 

9.配置httpd.conf

vim /usr/local/apache/conf/httpd.conf

将#ServerName www.example.com :80 改为 ServerName www.baidu.com //ServerName 后面网址随便

10.检查apachectl语法

apachectl -t

11.启动apache,以及检验端口80是否被应用

a。启动

apachectl start

b。检验80端口

netstat -antp | grep 80

如果出现

tcp        0      0 :::80                       :::*                        LISTEN      2719/httpd

说明成功

c。浏览器检查

打开浏览器,输入http://localhost 页面显示:It works或者CentOS专有的apache服务器监测界面说明启动成功

posted @ 2013-10-14 16:48  Renekton  阅读(277)  评论(0编辑  收藏  举报