LAMP快速构建apache web服务器


LAMP 

图-LAMP

apache服务器的最新稳定发布版本是httpd-2.2..0,官方下载地址是:[url]http://httpd.apache.org/download.cgi[/url]。我们通过下面的步骤来快速的搭建一个web服务器。

1、 下载源码文件httpd-2.2.0.tar.gz 到linux服务器的某个目录。

2、 解压文件 # tar zxvf httpd-2.2.0.tar.gz .

3、 配置 # ./c ╟refix=/usr/local/apache //指定安装目录,以后要删除安装就只需删除这个目录。

4、 编译和安装。 # make ; make install .

5、 编写启动脚本,把它放到目录 /etc/rc.d/init.d/里,这里取名为httpd,其内容如下:

  1. #!/bin/bash  
  2.  
  3. #descripti server  
  4.  
  5. #chkc 235 98 98  
  6.  
  7. case "$1" in 
  8.  
  9. start)  
  10.  
  11. echo "starting apache daemon..." 
  12.  
  13. /usr/local/apache2/bin/apachectl -k start  
  14.  
  15. stop)  
  16.  
  17. echo "stopping apache daemon..." 
  18.  
  19. /usr/local/apache2/bin/apachectl -k stop  
  20.  
  21. restart)  
  22.  
  23. echo "restarting apache daemon..." 
  24.  
  25. /usr/local/apache2/bin/apachectl -k restart  
  26.  
  27. status)  
  28.  
  29. statusproc /usr/local/apache2/bin/httpd  
  30.  
  31. echo "usage: $0 {start|stop|restart|status}" 
  32.  
  33. exit 1  
  34.  
  35. esac  
  36.  

注意:#descripti server 这一行必须加上,否则在执行命令 # chkc ╟add httpd 时会出现“service apache does not support chkc 2345 98 98 表示在执行命令 # chkc ╟add httpd 时会在目录 /etc/rc2.d/ 、/etc/rc3.d/ /etc/rc5.d 分别生成文件 s98httpd和 k98httpd。这个数字可以是别的。

6、 执行命令 # chkc ╟add httpd ,进入目录/etc/rc3.d/检查是否生成文件 s98httpd及k98httpd.

7、 启动服务 # service httpd start .

通过文章的描述,想必大家都能亲手用LAMP构建一个apache web服务器了!学会的读者快跟朋友分享吧!

相关内容