需下载的源程序: httpd-2.4.4.tar.gz http://www.apache.org/dyn/closer.cgi apr-1.4.8.tar.gz apr-util-1.5.2.tar.gz http://apr.apache.org/download.cgi pcre-8.33.tar.gz http://sourceforge.net/projects/pcre/files/pcre/
安装编译工具: [iyunv@centos ]#yum install autoconf automake binutils gcc gcc-c++ make patch perl
如系统已装apr等可先删除(不删除编译没试过后果不清楚) [iyunv@centos ]#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里 (不带版本号) [iyunv@centos ]#cd httpd-2.4.4/srclib/apr [iyunv@centos ]#./configure –prefix=/usr/local/apr/ [iyunv@centos ]#make [iyunv@centos ]#make install
编译和安装 apr-util-1.5.2 直接解压到httpd-2.4.4/srclib/apr-util里(不带版本号) [iyunv@centos ]#cd httpd-2.4.4/srclib/apr-util [iyunv@centos ]#./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr [iyunv@centos ]#make [iyunv@centos ]#make install
编译和安装 pcre-8.33 直接解压到httpd-2.4.4/srclib/pcre里(不带版本号) [iyunv@centos ]#cd httpd-2.4.4/srclib/pcre [iyunv@centos ]#./configure –prefix=/usr/local/pcre [iyunv@centos ]#make [iyunv@centos ]#make install
编译httpd-2.4.4 [iyunv@centos ]#tar -zxf httpd-2.4.4.tar.gz -C /usr/src/ //解压到/usr/src下 [iyunv@centos ]#cd /usr/src/httpd-2.4.4 [iyunv@centos ]#./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 here make[2]: *** [exports.lo] Error 1 make[2]: Leaving directory `/usr/local/src/httpd-2.4.4/server' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/usr/local/src/httpd-2.4.4/server' make: *** [all-recursive] Error 1”
解决办法: 在configure后加上 “--with-included-apr”。 ========================================================================
1. 缺失 APR APR-util configure: 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里面,并去除版本号 [iyunv@centos ]#cp -r apr-1.4.8 httpd-2.4.4/srclib/apr [iyunv@centos ]#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
[iyunv@centos ]#openssl genrsa -out localhost.key 1024
用 server.key 生成证书签署请求 CSR
[iyunv@centos ]#openssl req -new -key localhost.key -out localhost.csr
生成证书CRT文件server.crt。
[iyunv@centos ]#openssl x509 -days 365 -req -in localhost.csr -signkey localhost.key -out localhost.crt
修改ssl.conf指定我们自己生成的证书
[iyunv@centos ]#vim /etc/httpd/conf.d/ssl.conf
找到如下位置,修改路径
SSLCertificateFile /etc/pki/tls/certs/localhost.crt SSLCertificateKeyFile /etc/pki/tls/private/localhost.key ========================================================================
杀掉apache进程号 [iyunv@centos ]#kill 'cat /usr/local/apache/logs/httpd.pid' (用[iyunv@centos ]#ps ax | grep httpd [iyunv@centos ]#kill -9 **** 容易出错,没效率) ========================================================================
实现自启动 [iyunv@centos ]#cp /usr/local/apache-2.4.4/bin/apachectl /etc/init.d/ (可使用 service apachectl start|stop|status 运行)
[iyunv@centos ]#ln -s /etc/init.d/apachectl /etc/rc3.d/S90httpd 启动级别3时自动启动Httpd [iyunv@centos ]#ln -s /etc/init.d/apachectl /etc/rc0.d/K90httpd 关机 [iyunv@centos ]#ln -s /etc/init.d/apachectl /etc/rc6.d/K90httpd 重启
chckconfig添加为系统服务 [iyunv@centos ]#cp /usr/local/apache-2.4.4/bin/apachectl /etc/rc.d/init.d/httpd [iyunv@centos ]#vim /etc/rc.d/init.d/httpd
第二行添加 # chkconfig: 235 90 90 //在运行级(2、3、5)下分别启动httpd; # description: Apache //启动序号(S90);关闭序号(K90)。第二行为描述必须要写!
可用 [iyunv@centos ]# chkconfig --add httpd [iyunv@centos ]# chkconfig --list httpd httpd 0:off 1:off 2:on 3:on 4:off 5:on 6:off ========================================================================= [iyunv@centos ]# service apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ***.***.***.***. Set the 'ServerName' directive globally to suppress this message
解决方法: [iyunv@centos ]#vim /usr/local/apache-2.4.4/conf/httpd.conf
找到#ServerName localhost:80 把注释去掉即可 =========================================================================
运行多个Apache服务器 使用不同的配置文件 httpd -f /usr/local/apache/conf/httpd.conf
=========================================================================
安装php模式 [iyunv@centos ]# ./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
[iyunv@centos ]# cp php.ini-production /usr/local/php/lib/php.ini 问题:configure: error: xml2-config not found. Please check your libxml2 installation 解决:检查是否安装了libxm包
[iyunv@centos php-5.5.0]# rpm -qa |grep libxml2 libxml2-python-2.7.6-8.el6_3.4.i686 libxml2-2.7.6-8.el6_3.4.i686
重新安装libxml2和libxml2-devel包 [iyunv@centos ]#yum install libxml2 [iyunv@centos ]#yum install libxml2-devel 在httpd.conf中添加 LoadModule php5_module modules/libphp5.so AddType application/x-httpd-php .php AddType 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: [iyunv@bogon mod_perl-2.0.8]# perl Makefile.PL MP_APXS=/usr/local/apache-2.4.4/bin/apxs MP_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. 解决: [iyunv@centos ]#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 解决: [iyunv@centos ]#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_config mod_perl.c:1067: error: ‘request_rec’ has no member named ‘handler’ make[1]: *** [mod_perl.lo] Error 1 make[1]: Leaving directory `/usr/src/mod_perl-2.0.8/src/modules/perl' make: *** [modperl_lib] Error 2
|