当前位置: 澳门新濠3559 > 操作系统 > 正文

cetos6.8源码安装apache2.4.29,lnmp编译安装

时间:2019-11-07 21:41来源:操作系统
下载软件包: lamp编译安装与nginx共存 一、安装Apache 1、安装前的依赖包 apr、apr-util、pcre 下载相应的包 安装apr tar zxvf apr-1.5.2.tar.gz cd apr-1.5.2 sudo ./configure --prefix=/usr/local/src/apr-1.5.2 sudo

下载软件包:

lamp编译安装与nginx共存

一、安装Apache
1、安装前的依赖包
apr、apr-util、pcre
下载相应的包
安装apr
tar zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
sudo ./configure --prefix=/usr/local/src/apr-1.5.2
sudo make && make install

cetos6.8源码安装apache2.4.29

wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.33.tar.gz
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.6.3.tar.gz
wget http://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz

 

安装apr-util
tar zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
sudo ./configure --prefix=/usr/local/src/apr-util-1.6.1 --with-apr=/usr/local/src/apr-1.5.2
sudo make && make install
//编译安装apr-util必须指定apr的安装位置
Q: 致命错误:expat.h:没有那个文件或目录
缺少expat的开发库
A:sudo apt-get install libexpat-dev

apache官网: http://httpd.apache.org

首先需要安装apr和apr-util

01

安装pcre
tar zxvf pcre-8.38.tar.gz
cd pcre-8.38
sudo ./configure --prefix=/usr/local/src/pcre-8.38
sudo make && make install

具体安装步骤:

tar xf apr-1.6.3.tar.gz 
cd apr-1.6.3/
./configure
sudo make
sudo make install

置顶处[lnmp编译安装][1]的php安装在/usr/local/路径下,本篇为lamp编译安装。apache与nginx共存,适用于apache的php安装在/usr/下

2、安装apache
tar zxvf httpd-2.4.29.tar.gz
cd httpd-2.4.29
sudo ./configure --prefix=/usr/local/src/httpd-2.4.29
--sysconfdir=/etc/httpd
--enable-so --enable-ssl --enable-cgi --enable-rewrite
--with-zlib --with-pcre=/usr/local/src/pcre-8.38
--with-apr=/usr/local/src/apr-1.5.2
--with-apr-util=/usr/local/src/apr-util-1.6.1
--enable-mods-shared=most --enable-mpms-shared=all --with-mpm=event

1 配置安装apache的基础环境
2 下载想要安装的版本源码包
3 解压,预编译,编译,安装
4 启动,停止,测试页面,检验是否安装成功
5 编写启动脚本,将apache添加为系统服务,设置为开机启动

 安装apr-util:

02

选项解释:
--prefix=/usr/local/src/httpd-2.4.29 # 指定安装目录
--sysconfdir=/etc/httpd # 指定配置文件安装路径
--enable-so --enable-ssl #允许运行时加载DSO模块 # 启动ssl加密功能
--enable-cgi --enable-rewrite # 启用cgi协议 #启用URL重写功能
--with-zlib --with-pcre # 指定pcre的安装路径
--with-apr=/usr/local/src/apr-1.5.2 #指定apr的安装路径
--with-apr-util=/usr/local/src/apr-util-1.6.1 # 指定apr-util的安装路径
--enable-modules=most # 启用大多数共享模块
--enable-mpms-shared=most #启用MPM大多数参数
--with-mpm=event #指定使用的MPM的类型

=================================================================== 

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

apache安装

Q:
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures
A:
sudo apt-get update
sudo apt-get install openssl
sudo apt-get install libssl-dev

1 配置安装环境:

sudo make

03

启动Apache服务器并验证
切换到编译Apache的bin目录下
sudo ./apachectl start

yum -y install gcc gcc++ zlib zlib-devel 

sudo make install

依赖两个包apr,apr-util,资源都在apache官网下。

Q:
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
A:
几种可能的解决方案:
(1)由于服务器的80端口被占用引起的,如果是windows的话就是IIS,停掉Default Web Site就可以了;
(2)将httpd.conf中的Listen 80行改为 Listen 81,换一个端口
(3)将httpd.conf中的Listen 80行改为 Listen 127.0.0.1:80

卸载原有的Apache
cetos6.8源码安装apache2.4.29,lnmp编译安装。rpm -qa|grep httpd
删除已经安装的所有httpd包
rpm -e --nodeps httpd-xxx-xxx.el6.xxx.x86_64

这两个必不可少,如果缺少其他的依赖,请自行百度

04

O:不使用sudo命令,没有写入日志的权限
(13)Permission denied: AH00091: httpd: could not open error log file /usr/local/src/httpd-2.4.29/logs/error_log.
AH00015: Unable to open logs

2 下载对应版本的包
wget

安装apr-util的,在编译的时候报错:

1.apr

澳门新濠3559 1

1)去 下载apache源码包

xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory

05

success.png

2)解压到/usr/src,在下载目录执行tar -zxvf httpd-x.x.x.tar.gz -C /usr/src (我用的是httpd-2.4.29.tar.gz)

解决方法:

tar xf apr-1.4.6.tar.bz2

二、安装MySQL

3)进入目录/usr/src/httpd-2.4.29,

sudo apt-get install libexpat1-dev

06

 # ./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl

 

cd apr-1.4.6

4)出现configure: error: APR not found。解决办法:

还有其他依赖:

07

  4.1)去apr下载地址 下载源码
  wget
  

1,pcre

sudo ./configure --help | less             (可以查看帮助文件)

  4.2)解压到/usr/src,在下载目录执行tar -zxvf apr-x.x.x.tar.gz -C /usr/src/ (我用的是apr- 1.6.3.tar.gz)

sudo apt-get install libpcre3 libpcre3-dev

08

  4.3)进入目录/usr/src/apr-1.6.3,执行./configure --prefix=/usr/local/apr;make;make install

 

sudo ./configure --prefix=/usr/local/apr  (指定安装路径)

5)再次进入目录/usr/src/httpd-2.4.29,增加参数--with-apr=/usr/local/apr/

2,openssl

09

重新执行:./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr/

sudo apt-get install openssl libssl-dev

sudo make

6)出现configure: error: APR-util not found .解决办法

 

10

  6.1)去apr-util下载地址 下载源码
  wget
  

3,zlib

sudo make install

  6.2)解压到/usr/src,在下载目录执行tar -zxvf apr-util-x.x.x.tar.gz -C /usr/src/ (我用的是apr-util-1.6.1.tar.gz)

sudo apt-get install zlib1g-dev

11

  6.3)进入目录/usr/src/apr-util-1.6.1,执行./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/;make;make install

 

 

  6.4)make的时候出现错误
xml/apr_xml.c:35:19: error: expat.h: No such file or directory
xml/apr_xml.c:66: error: expected specifier-qualifier-list before ‘XML_Parser’
xml/apr_xml.c: In function ‘cleanup_parser’:
xml/apr_xml.c:364: error: ‘apr_xml_parser’ has no member named ‘xp’
xml/apr_xml.c:365: error: ‘apr_xml_parser’ has no member named ‘xp’
  解决办法:可能是缺少expat库
    6.4.1)yum install expat-devel 安装之后再make;make install

编译apache

12

7)再次进入目录/usr/src/httpd-2.4.29,增加参数--with-apr-util=/usr/local/apr-util/,重新执行:./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/

./configure 
--prefix=/usr/local/httpd24 
--sysconfdir=/etc/httpd24 
--enable-so 
--enable-ssl 
--enable-cgi 
--enable-rewrite 
--with-zlib 
--with-pcre 
--with-mpm=prefork 
--enable-modules=most 
--enable-mpms-shared=all  

2.apr-util

8)出现configure: error: pcre-config for libpcre not found.解决办法:

最后make makeinstall

13

  8.1)去pcre下载地址 下载源码(注意:下载的时候一定不要下错了,不是pcre2 )
  wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

 

tar xf apr-util-1.5.2.tar.bz2

  8.2)解压到/usr/src,在下载目录执行tar -zxvf pcre-x.x.tar.gz -C /usr/src/ (我用的是pcre-8.40.tar.gz)

root@dev:~# /usr/local/httpd24/bin/apachectl start
root@dev:~# ps -ef | grep httpd
root     24411 17534  0 06:15 ?        00:00:00 /usr/local/httpd24/bin/httpd -k start
daemon   24412 24411  0 06:15 ?        00:00:00 /usr/local/httpd24/bin/httpd -k start
daemon   24413 24411  0 06:15 ?        00:00:00 /usr/local/httpd24/bin/httpd -k start
daemon   24414 24411  0 06:15 ?        00:00:00 /usr/local/httpd24/bin/httpd -k start
daemon   24415 24411  0 06:15 ?        00:00:00 /usr/local/httpd24/bin/httpd -k start
daemon   24416 24411  0 06:15 ?        00:00:00 /usr/local/httpd24/bin/httpd -k start
root     24418 24367  0 06:15 pts/19   00:00:00 grep --color=auto httpd

14

  8.3)进入目录/usr/src/pcre-8.31,执行./configure --prefix=/usr/local/pcre;make;make install

修改配置文件( vim /etc/httpd24/httpd.conf )

 cd apr-util-1.5.2

 

ServerName 127.0.0.1

15

9)再次进入目录/usr/src/httpd-2.4.29,增加参数--with-pcre=/usr/local/pcre,重新执行:./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre

DocumentRoot 后面指定一个网站根目录 

 sudo ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

10)出现configure: WARNING: OpenSSL version is too old;checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures;解决办法:

16

  10.1)openssl源码下载地址 下载源码
  wget

(--prefix指定安装路径;--with-apr指定apr的安装路径,apr-util依赖于apr)

  10.2)解压到/usr/src,在下载目录执行tar -zxvf openssl-x.x.x.tar.gz -C /usr/src/ (我用的是openssl-1.0.2n.tar.gz)

17

  10.3)进入目录/usr/src/openssl-1.0.1c,执行./config --prefix=/usr/local/openssl shared;make;make install

sudo  make && make install

 注意此处的shared选项,否则在httpd make的时候会报mod_ssl相关错误

18

 

 

11)再次进入目录/usr/src/httpd-2.4.3,增加参数--with-ssl=/usr/local/openssl,重新执行:./configure --prefix=/usr/local/apache2 --with-mpm=worker --enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache --enable-nonportable-atomics --enable-mods-shared=most --enable-so --enable-rewrite --enable-ssl --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --with-ssl=/usr/local/openssl ;预编译没有问题

19

make出现以下错误:
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory `/usr/local/httpd-2.4.26/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/httpd-2.4.26/support'
make: *** [all-recursive] Error 1

3.appache

解决办法发:centos6.8的系统使用1.6的apr 和apr-util版本太高了,需要降低版本,将apr和apr-util降为1.5的版本,在重新编译安装即可。下载地址如下:

20

 

开始编译

12)设置apache开机自动启动

21

首先拷贝apachectl到目录/etc/init.d/,执行命令sudo cp apachectl /etc/init.d/httpd
vim /etc/init.d/httpd 脚本首行添加以下两行
# chkconfig: 2345 71 71
# description: Apache2.4 is a world wide web server
注意:2345 是指改服务可以随系统的2345启动级别启动和停止,71 71 两个数字分别指启动顺序和停止顺序。
13)将httpd添加为开机启动
chkconfig --add httpd
这行命令的意思是在/etc/rc.d/rc*/ 添加/etc/init.d/httpd这个文件
chkconfig --list |grep httpd 查看是否将httpd添加为系统服务
chkconfig httpd on 开启开机启动httpd服务

tar xf httpd-2.4.4.tar.bz2

14)去浏览器输入127.0.0.1,可以显示apache自带的网页It works。该网页的默认目录是在/usr/local/apache2/htdocs/。apache到此就安装OK了。

22

 

cd httpd-2.4.4

23

sudo ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-cgid --enable-modules=most --enable-mods-shared=most --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-mpms-shared=all --with-mpm=event

24

--sysconfdir=/etc/httpd  :指定配置文件安装位置

25

--enable-so              :支持动态共享模块如果没有这个模块PHP将无法与apache结合工作

26

--enable-ssl             :启用支持ssl

27

--enable-cgi             :支持cgi

28

澳门新濠3559,--enable-rewrite         :支持URL重写

29

 --with-zlib             :压缩库,在互联网上传播时可节约带宽

30

--with-apr=/usr/local/apr :指定apr路径

31

--with-apr-util=/usr/local/apr-util :指定apr-util路径

32

--enable-mpms-shared=all 支持多道处理模块

33

--with-mpm=event         设定默认的模块

34

sudo make

35

sudo  make install

36

 

37

启动apache

38

sudo  /usr/local/apache/bin/apachectl start

39

 

40

mysql安装

41

与置顶的lnmp安装方法一致,为二进制安装。

42

 

43

php安装

44

依赖文件 :libbz2 libfreetype6-dev libltdl-dev libxml2-dev libpng12-dev libjpeg-dev libmcrypt-dev libcurl4-openssl-dev

45

编译配置:

46

sudo ./configure --prefix=/usr/php  --with-config-file-path=/usr/php/etc  --with-config-file-scan-dir=/usr/php/lib/php --with-mcrypt --with-jpeg-dir --with-png-dir --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql/bin/mysql_config --with-mysqli=/usr/local/mysql/bin/mysql_config --with-openssl  --with-zlib --with-freetype-dir --enable-mbstring --enable-sockets  --with-curl --with-gd --with-iconv-dir     --with-pcre-dir   --with-xmlrpc --enable-ftp --enable-gd-jis-conv --enable-gd-native-ttf --enable-soap  --enable-mod-charset --enable-mysqlnd --enable-shmop  --enable-zip --enable-static  --enable-debug --enable-exif --enable-bcmath  --enable-fpm --with-apxs2=/usr/local/apache/bin/apxs   --with-bz2  --enable-maintainer-zts

47

sudo make

48

sudo make install

49

sudo cp php.ini-development /usr/php/etc/php.ini

50

sudo useradd --no-create-home --shell=/sbin/nologin www

51

cd /usr/php/etc

52

sudo cp php-fpm.conf.default php-fpm.conf

53

sudo vim php-fpm.conf (修改user=www group=www)

54

 

55

 

56

1.相关问题

57

apache启动

58

  1. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message

59

 

60

 

61

 

62

 

63

有部分内容从jqhoudun的[博客][2]内截取,包括apr,apr-util,apache的编译安装,php的配置的部分编译配置。

01 置顶处[lnmp编译安装][1]的php安装在/usr/local/路径下,本篇为lamp编译安装。apache与nginx共存,适用于apache的php安装在...

编辑:操作系统 本文来源:cetos6.8源码安装apache2.4.29,lnmp编译安装

关键词: