需下载的源程序:
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/
安装编译工具:
[root@centos ]#yum install autoconf automake binutils gcc gcc-c++ make patch perl
如系统已装apr等可先删除(不删除编译没试过后果不清楚)
[root@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里 (不带版本号)
[root@centos ]#cd httpd-2.4.4/srclib/apr
[root@centos ]#./configure –prefix=/usr/local/apr/
[root@centos ]#make
[root@centos ]#make install
编译和安装 apr-util-1.5.2
直接解压到httpd-2.4.4/srclib/apr-util里(不带版本号)
[root@centos ]#cd httpd-2.4.4/srclib/apr-util
[root@centos ]#./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
[root@centos ]#make
[root@centos ]#make install
编译和安装 pcre-8.33
直接解压到httpd-2.4.4/srclib/pcre里(不带版本号)
[root@centos ]#cd httpd-2.4.4/srclib/pcre
[root@centos ]#./configure –prefix=/usr/local/pcre
[root@centos ]#make
[root@centos ]#make install
编译httpd-2.4.4
[root@centos ]#tar -zxf httpd-2.4.4.tar.gz -C /usr/src/ //解压到/usr/src下
[root@centos ]#cd /usr/src/httpd-2.4.4
[root@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里面,并去除版本号
[root@centos ]#cp -r apr-1.4.8 httpd-2.4.4/srclib/apr
[root@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
[root@centos ]#openssl genrsa -out localhost.key 1024
用 server.key 生成证书签署请求 CSR
[root@centos ]#openssl req -new -key localhost.key -out localhost.csr
生成证书CRT文件server.crt。
[root@centos ]#openssl x509 -days 365 -req -in localhost.csr -signkey localhost.key -out localhost.crt
修改ssl.conf指定我们自己生成的证书
[root@centos ]#vim /etc/httpd/conf.d/ssl.conf
找到如下位置,修改路径
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
========================================================================
杀掉apache进程号
[root@centos ]#kill 'cat /usr/local/apache/logs/httpd.pid'
(用[root@centos ]#ps ax | grep httpd [root@centos ]#kill -9 **** 容易出错,没效率)
========================================================================
实现自启动
[root@centos ]#cp /usr/local/apache-2.4.4/bin/apachectl /etc/init.d/
(可使用 service apachectl start|stop|status 运行)
[root@centos ]#ln -s /etc/init.d/apachectl /etc/rc3.d/S90httpd 启动级别3时自动启动Httpd
[root@centos ]#ln -s /etc/init.d/apachectl /etc/rc0.d/K90httpd 关机
[root@centos ]#ln -s /etc/init.d/apachectl /etc/rc6.d/K90httpd 重启
chckconfig添加为系统服务
[root@centos ]#cp /usr/local/apache-2.4.4/bin/apachectl /etc/rc.d/init.d/httpd
[root@centos ]#vim /etc/rc.d/init.d/httpd
第二行添加
# chkconfig: 235 90 90 //在运行级(2、3、5)下分别启动httpd;
# description: Apache //启动序号(S90);关闭序号(K90)。第二行为描述必须要写!
可用
[root@centos ]# chkconfig --add httpd
[root@centos ]# chkconfig --list httpd
httpd 0:off 1:off 2:on 3:on 4:off 5:on 6:off
=========================================================================
[root@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
解决方法:
[root@centos ]#vim /usr/local/apache-2.4.4/conf/httpd.conf
找到#ServerName localhost:80 把注释去掉即可
=========================================================================
运行多个Apache服务器
使用不同的配置文件
httpd -f /usr/local/apache/conf/httpd.conf
=========================================================================
安装php模式
[root@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
[root@centos ]# cp php.ini-production /usr/local/php/lib/php.ini
问题:configure: error: xml2-config not found. Please check your libxml2 installation
解决:检查是否安装了libxm包
[root@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包
[root@centos ]#yum install libxml2
[root@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在目录下
$link=MySQL_connect(’MySQL服务器名’,'MySQL用户名’,'密码’);
if(!$link) echo "Error !";
else echo "Ok!";
MySQL_close();
?>
=========================================================================
安装mod-perl:
[root@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.
解决: [root@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
解决: [root@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
解决:????
=========================================================================
=========================================================================