欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

CentOS 5.8 中源码安装apache2.4.7和php5.4.23

程序员文章站 2022-06-14 19:46:01
...

安装Apache2.4.7: 首先从 http://httpd.apache.org/download.cgi#apache24 下载apache源码包httpd-2.4.7.tar.gz wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.7.tar.gz 从 http://apr.apache.org/download.cgi 下载 apr-1.5.0.tar.gz和apr-util


安装Apache2.4.7:

首先从 http://httpd.apache.org/download.cgi#apache24
下载apache源码包httpd-2.4.7.tar.gz
wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.7.tar.gz

从 http://apr.apache.org/download.cgi 下载
apr-1.5.0.tar.gz和apr-util-1.5.1.tar.gz
wget http://apache.fayea.com/apache-mirror//apr/apr-1.5.0.tar.gz
wget http://apache.fayea.com/apache-mirror//apr/apr-util-1.5.3.tar.gz
从 http://sourceforge.net/projects/pcre/files/pcre/8.32/ 下载pcre-8.32.tar.gz
wget http://sourceforge.net/projects/pcre/files/pcre/8.32/pcre-8.32.tar.gz/download

源码统一放在/opt/sourcecode
安装路径:/opt/soft/
先装gcc和make
yum -y install gcc
yum -y install make
yum -y install gcc-c++ 没有这个gcc-c++一会编译不prce

****************************************************************************************************
这部分跳过
安装apr:
tar -zvxf apr-1.5.0.tar.gz
cd apr-1.5.0
./configure --prefix=/opt/soft/apr
make && make install


安装apr-util
tar -zvxf apr-util-1.5.3.tar.gz
cd apr-util-1.5.3
./configure --prefix=/opt/soft/apr-util --with-apr=/opt/soft/apr
make && make install
******************************************************************************************************

安装pcre
tar -zvxf pcre-8.32.tar.gz
cd pcre-8.32
./configure --prefix=/opt/soft/pcre
make && make install


安装apache
tar -zvxf httpd-2.4.7.tar.gz
cd httpd-2.4.7
将apr-1.5.0 和 apr-util-1.5.3 的源码解压到 httpd-2.4.7/srclib/下的 apr 和 apr-util中

./configure --prefix=/opt/soft/apache --with-pcre=/opt/soft/pcre --with-included-apr -enable-module=so --enable-so --enable-rewrite


//更多选项 ./configure --prefix=/opt/soft/apache --with-apr-util=/opt/soft/apr-util --with-apr=/opt/soft/apr --with-pcre=/opt/soft/pcre -enable-module=so --enable-so --enable-rewrite

make && make install


启动apache
/opt/soft/apache/bin/httpd
/opt/soft/apache/bin/apachectl restart



安装PHP5.5
yum -y install libxml2-devel 不装这个编译不了PHP5.4.23

从www.php.net下载PHP5.4.23

wget http://cn2.php.net/get/php-5.4.23.tar.gz/from/this/mirror
tar -zvxf php-5.4.23.tar.gz
cd php-5.4.23
./configure --prefix=/opt/soft/php --with-config-file-path=/opt/soft/php/etc --with-apxs2=/opt/soft/apache/bin/apxs --enable-fpm --with-mysql --enable-sysvsem --enable-sockets --enable-pcntl --enable-mbstring --enable-mysqlnd --enable-shmop --enable-zip --enable-ftp --enable-gd-native-ttf --enable-soap --enable-xml

make && make install


//更多选项... ./configure --prefix=/opt/soft/php --with-config-file-path=/opt/soft/php/etc --enable-fpm --enable-sysvsem --enable-sockets --enable-pcntl --enable-mbstring --enable-mysqlnd --enable-opcache --enable-shmop --enable-zip --with-mcrypt=/usr/local/libmcrypt/ --with-zlib=/usr/local/zlib/ --with-curl=/usr/local/curl/ --with-pcre-dir=/usr/local/pcre/ --with-t1lib=/usr/local/tlib/ --with-pdo-mysql=/usr/ --with-fpm-user=www --with-fpm-group=www


# cp php.ini-development /opt/soft/php/etc/php.ini
# vim /opt/soft/apache/conf/httpd.conf
确保以下字符串是否存在
LoadModule php5_module modules/libphp5.so
如果没有就加上
在AddType application*后面加如下一行
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

在DirectoryIndex index.html加上index.php
DirectoryIndex index.php index.html
#service httpd restart


/opt/softl/apache/bin/apachectl restart






centos 6.4
安装apache 和 php报错:
libtool: link: cannot find the library `/usr/lib/libexpat.la' or unhandled argument `/usr/lib/libexpat.la'
这两个文件没有被考到指定位置,可以自己拷贝过去。
cp /opt/sourcecode/httpd-2.4.7/srclib/apr-util/xml/expat/libexpat.la /usr/lib64/libexpat.la
cp /opt/sourcecode/httpd-2.4.7/srclib/apr-util/xml/expat/.libs/libexpat.so /usr/lib64/libexpat.so

解决编译代码出现/usr/bin/ld: cannot find -luuid错误 .
ln -s /lib64/libuuid.so.1 /usr/lib/libuuid.so
or
yum install uuid-devel
yum install libuuid-devel