LINUX APACHE

参考+总结

 

官网下载文件

Download $ lynx http://httpd.apache.org/download.cgi
Extract $ gzip -d httpd-NN.tar.gz $ tar xvf httpd-NN.tar $ cd httpd-NN
Configure $ ./configure --prefix=PREFIX
Compile $ make
Install $ make install
Customize $ vi PREFIX/conf/httpd.conf
Test $ PREFIX/bin/apachectl -k start

 2、解压安装

  

1 tar zvxf httpd-2.2.21.tar.gz 
2 cd httpd-2.2.21
3 ./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite
4 make 5 make install

第三步 应该会出现问题

1.下载所需软件包:


  1. wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz  
  2. wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz  
  3. wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip   

2.编译安装:


  1. yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs 

具体步骤如下:


  a:解决apr not found问题>>>>>>


  1. [root@xt test]# tar -zxf apr-1.4.5.tar.gz  
  2. [root@xt test]# cd  apr-1.4.5  
  3. [root@xt apr-1.4.5]# ./configure --prefix=/usr/local/apr  
  4. [root@xt apr-1.4.5]# make && make install  
  5.  

  b:解决APR-util not found问题>>>>


  1. [root@xt test]# tar -zxf apr-util-1.3.12.tar.gz  
  2. [root@xt test]# cd apr-util-1.3.12  
  3. [root@xt apr-util-1.3.12]# ./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr/bin/apr-1-config  
  4. [root@xt apr-util-1.3.12]# make && make install 

c:解决pcre问题>>>>>>>>>


  1. [root@xt test]#unzip -o pcre-8.10.zip  
  2. [root@xt test]#cd pcre-8.10  
  3. [root@xt pcre-8.10]#./configure --prefix=/usr/local/pcre  
  4. [root@xt pcre-8.10]#make && make install 

 编译Apache时加上:


--with-apr=/usr/local/apr \


--with-apr-util=/usr/local/apr-util/ \


 --with-pcre=/usr/local/pcre


最后


运行./configure 命令进行编译源代码,


--prefix=/usr/local/apach2 是设置编译安装到的系统目录,


 --enable-s  参数是使httpd服务能够动态加载模块功能,


--enable-rewrite  是使httpd服务具有网页地址重写功能。


3.启动apache:


/usr/local/apache2/bin/apachectl start


4.将apache加入到系统服务,用service命令来控制apache的启动和停止


  •  首先以apachectl脚本为模板生成Apache服务控制脚本:

  grep -v "#" /usr/local/apache2/bin/apachectl  > /etc/init.d/apache


  • 用vi编辑Apache服务控制脚本/etc/init.d/apache:

  vi /etc/init.d/apache


  • 在文件最前面插入下面的行,使其支持chkconfig命令:

  #!/bin/sh              


  # chkconfig: 2345 85 15              


  # description: Apache is a World Wide Web server.


  • 保存后退出vi编辑器,执行下面的命令增加Apache服务控制脚本执行权限:    

  chmod  +x  /etc/init.d/apache


  • 执行下面的命令将Apache服务加入到系统服务:    

  chkconfig --add apache


  • 执行下面的命令检查Apache服务是否已经生效:    

  chkconfig --list apache              


  • 命令输出类似下面的结果:              

  apache          0:off 1:off 2:on 3:on 4:on 5:on 6:off       


  表明apache服务已经生效,在2、3、4、5运行级别随系统启动而自动启动,以后可以使用service命令控制Apache的启动和停止。  


  • 启动Apache服务:   service apache start   
  • 停止Apache服务:        service apache stop   
  • 执行下面的命令关闭开机自启动:      chkconfig apache off

 

 

 

 

 


posted @ 2015-04-16 01:50  牟眸  阅读(210)  评论(0编辑  收藏  举报