tongy 发表于 2013-7-22 08:56:55

apache-2.4.4安装与配置

需下载的源程序:httpd-2.4.4.tar.gzhttp://www.apache.org/dyn/closer.cgiapr-1.4.8.tar.gzapr-util-1.5.2.tar.gzhttp://apr.apache.org/download.cgipcre-8.33.tar.gzhttp://sourceforge.net/projects/pcre/files/pcre/
安装编译工具: #yum install autoconf automake binutils gcc gcc-c++ make patch perl
如系统已装apr等可先删除(不删除编译没试过后果不清楚)#yum remove apr-util-devel apr apr-util-mysql apr-docs apr-devel apr-util apr-util-docs
编译和安装 apr 1.4.8 直接解压到httpd-2.4.4/srclib/apr里 (不带版本号) #cd httpd-2.4.4/srclib/apr #./configure –prefix=/usr/local/apr/ #make #make install
编译和安装 apr-util-1.5.2 直接解压到httpd-2.4.4/srclib/apr-util里(不带版本号) #cd httpd-2.4.4/srclib/apr-util #./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr #make #make install
编译和安装 pcre-8.33 直接解压到httpd-2.4.4/srclib/pcre里(不带版本号) #cd httpd-2.4.4/srclib/pcre #./configure –prefix=/usr/local/pcre #make #make install

编译httpd-2.4.4 #tar -zxf httpd-2.4.4.tar.gz -C /usr/src/   //解压到/usr/src下 #cd /usr/src/httpd-2.4.4 #./configure --prefix=/usr/local/apache-2.4.4 \--enable-so \--enable-mods-shared=most \--with-mpm=worker \--with-apr=/usr/local/apr \--with-apr-util=/usr/local/apr-util \--with-pcre=/usr/local/pcre \--with-included-apr            //可先不加这句,编译不通过再加,选项重新配置httpd。
========================================================================
========================================================================“exports.c:1653: error: redefinition of 'ap_hack_apr_version_string'exports.c:1022: error: previous definition of 'ap_hack_apr_version_string' was heremake: *** Error 1make: Leaving directory `/usr/local/src/httpd-2.4.4/server'make: *** Error 1make: Leaving directory `/usr/local/src/httpd-2.4.4/server'make: *** Error 1”

解决办法:在configure后加上 “--with-included-apr”。========================================================================
1. 缺失 APR APR-utilconfigure: error: Bundled APR requested but not found at ./srclib/. Download and unpack the corresponding apr and apr-util packages to ./srclib/.
解决办法:将APR和APR-util源码下载,解压放到httpd-2.4.4/srclib里面,并去除版本号#cp -r apr-1.4.8 httpd-2.4.4/srclib/apr#cp -r apr-util-1.5.2 httpd-2.4.4/srclib/apr-util
========================================================================Syntax error on line 105 of /etc/httpd/conf.d/ssl.conf:SSLCertificateFile: file '/etc/pki/tls/certs/localhost.crt' does not exist or is empty
生成证书文件创建一个rsa私钥,文件名为localhost.key
#openssl genrsa -out localhost.key 1024
用 server.key 生成证书签署请求 CSR
#openssl req -new -key localhost.key -out localhost.csr

生成证书CRT文件server.crt。
#openssl x509 -days 365 -req -in localhost.csr -signkey localhost.key -out localhost.crt
修改ssl.conf指定我们自己生成的证书
#vim /etc/httpd/conf.d/ssl.conf
找到如下位置,修改路径
SSLCertificateFile /etc/pki/tls/certs/localhost.crtSSLCertificateKeyFile /etc/pki/tls/private/localhost.key========================================================================
杀掉apache进程号#kill 'cat /usr/local/apache/logs/httpd.pid'(用#ps ax | grep httpd#kill -9 **** 容易出错,没效率)========================================================================
实现自启动#cp /usr/local/apache-2.4.4/bin/apachectl /etc/init.d/(可使用 service apachectl start|stop|status 运行)
#ln -s /etc/init.d/apachectl /etc/rc3.d/S90httpd    启动级别3时自动启动Httpd#ln -s /etc/init.d/apachectl /etc/rc0.d/K90httpd    关机#ln -s /etc/init.d/apachectl /etc/rc6.d/K90httpd    重启
chckconfig添加为系统服务#cp /usr/local/apache-2.4.4/bin/apachectl /etc/rc.d/init.d/httpd#vim /etc/rc.d/init.d/httpd
第二行添加# chkconfig: 235 90 90    //在运行级(2、3、5)下分别启动httpd;# description: Apache      //启动序号(S90);关闭序号(K90)。第二行为描述必须要写!
可用# chkconfig --add httpd       # chkconfig --list httpd      httpd         0:off   1:off   2:on    3:on    4:off   5:on    6:off=========================================================================# service apachectl startAH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ***.***.***.***. Set the 'ServerName' directive globally to suppress this message
解决方法:#vim /usr/local/apache-2.4.4/conf/httpd.conf
找到#ServerName localhost:80把注释去掉即可=========================================================================
运行多个Apache服务器使用不同的配置文件httpd -f /usr/local/apache/conf/httpd.conf
=========================================================================

安装php模式# ./configure --prefix=/usr/local/php-5.5.0 \--with-mysql=/usr/local/mysql/mysqldir \         //添加mysql支持--with-apxs2=/usr/local/apache-2.4.4/bin/apxs
# cp php.ini-production /usr/local/php/lib/php.ini问题:configure: error: xml2-config not found. Please check your libxml2 installation解决:检查是否安装了libxm包
       # rpm -qa |greplibxml2      libxml2-python-2.7.6-8.el6_3.4.i686      libxml2-2.7.6-8.el6_3.4.i686
重新安装libxml2和libxml2-devel包       #yum install libxml2       #yum install libxml2-devel在httpd.conf中添加LoadModule php5_module      modules/libphp5.soAddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.php
------------------------------------------------------------------------检测与mysql的连接性新建个testdb.php在目录下<?php$link=MySQL_connect(’MySQL服务器名’,'MySQL用户名’,'密码’);if(!$link) echo "Error !";else echo "Ok!";MySQL_close();?>
=========================================================================安装mod-perl:# perl Makefile.PLMP_APXS=/usr/local/apache-2.4.4/bin/apxsMP_APR_CONFIG=/usr/local/apr/bin/apr-1-config
出错:Can't locate ExtUtils/Embed.pm in @INC (@INC contains: lib Apache-Test/lib /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at lib/Apache2/Build.pm line 27.解决: #yum install perl-ExtUtils-Embed-------------------------------------------------------------------------出错:Your Perl is configured to link against libgdbm, but libgdbm.so was not found. You could just symlink it to /usr/lib/libgdbm.so.2.0.0解决: #yum install gdbm-devel-------------------------------------------------------------------------出错:mod_perl.c:1002: error: ‘request_rec’ has no member named ‘content_type’mod_perl.c:1011: error: ‘request_rec’ has no member named ‘per_dir_config’mod_perl.c:1013: error: ‘request_rec’ has no member named ‘request_configmod_perl.c:1067: error: ‘request_rec’ has no member named ‘handler’make: *** Error 1make: Leaving directory `/usr/src/mod_perl-2.0.8/src/modules/perl'make: *** Error 2

小风儿 发表于 2013-7-22 11:57:53

爱——不是想出来的,爱——是做出来的!!

fumingxia 发表于 2013-7-22 20:50:49

长大了娶唐僧做老公,能玩就玩一玩,不能玩就把他吃掉。

【魄爺】 发表于 2013-7-23 01:53:25

路过,学习下

陈银山 发表于 2013-7-23 06:13:15

只要不下流,我们就是主流!

萨尔法保护 发表于 2013-7-23 12:54:29

吃饭与ml是第一生产力。

奥飞火千万电 发表于 2013-7-24 02:15:45

不知该说些什么。。。。。。就是谢谢
页: [1]
查看完整版本: apache-2.4.4安装与配置