lamp 环境搭建之编译安装apache

apache的编译安装:

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

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

3,为什么yum源的网址和官网地址不一样?可以自建yum源。

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

猜你喜欢

转载自www.cnblogs.com/fengfengyang/p/9858534.html