(一)lamp 环境搭建之编译安装apache

apache的编译安装:

  安装步骤大概参考:http://www.cnblogs.com/iyoule/archive/2013/10/24/3385540.html

简单的将分为三步:

  (1)安装apache的依赖库:apr,apr-util,prce。

  (2)移动apr和apr-util到指定目录下。

  (3)安装apache。

 

1,apache 的 servername 报错一般解决方法:
在httpd.conf文件中更改 ServerName 192.168.1.77:80 这行的域名改为ip即可。

2,取消apache默认的欢迎页面
注释/conf.d 文件夹中的welcome 页

4,apache2.4 以上支持php-fpm,也就是fastcgi连接php。

5,apache编译安装报错 apr not found
解决:下载apr,apr-util 包。解压安装。
再编译apache时 加上 --with-apr=/apr目录 --with-apr-util=/apr-util目录

6,apr-util-1.6.1 报错
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory

解决方法(缺少expat库)
yum install expat-devel -y

yum install -y pcre*

7,make apache报错:
collect2: error: ld returned 1 exit status
Makefile:48: recipe for target 'htpasswd' failed
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory '/etc/httpd-2.4.27/support'
/etc/httpd-2.4.27/build/rules.mk:75: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/etc/httpd-2.4.27/support'
/etc/httpd-2.4.27/build/rules.mk:75: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
    
这个错误是因为在httpd目录下的srclib目录里面没有apr和apr-util所导致的,
但是./configure又不会报错,到make才会报错,所以把下载下来到apr和apr-util解
压到srclib目录下到apr和apr-util目录,注意目录名字要一致。
(这个需要注意顺序,最好在make apaceh的解压文件之前将apr和apr-util移动过来)

8,将apache加入系统服务的步骤:

可以简单地把Apache启动命令加到/etc/rc.local文件,
让Apache随系统启动而自动启动(一般不这样做):
# echo"/usr/local/apache-2.2.6/bin/apachectl start" >> /etc/rc.local

下面介绍如何把Apache加入到系统服务,用service命令来控制Apache的启动和停止。
首先以apachectl脚本为模板生成Apache服务控制脚本:

grep -v "#"/usr/local/apache/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 Webserver.

保存后退出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

转载于:https://www.cnblogs.com/fengfengyang/p/9858534.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值