日期:2014-05-16  浏览次数:20839 次

Linux下PHP环境的搭建
参考文章:http://www.jb51.net/article/10172.htm
        http://jiarry.bokee.com/6753889.html

1  在http://apr.apache.org/download.cgi 下载apr-1.4.6.tar.gz apr-util-1.4.1.tar.gz
    在http://ishare.iask.sina.com.cn/f/22932110.html?from=like 下载pcre-8.10.tar.gz (http://pcre.org/)
    在http://httpd.apache.org/download.cgi#apache24 下载httpd-2.4.2.tar.gz


# tar -zvxf apr-1.4.6.tar.gz
linux-liangfuming:/home/apache # cd apr-1.4.6/
linux-liangfuming:/home/apache/apr-1.4.6 # ./configure --prefix=/home/apache/apr


#tar -zvxf apr-util-1.4.1.tar.gz
#cd apr-util-1.4.1/
linux-liangfuming:/home/apache/apr-util-1.4.1 # ./configure --prefix=/home/apache/apr-util  --with-apr=/home/apache/apr --with-expat=builtin
先只用前面红色一段在make的时候报错
libtool: link: cannot find the library `/home/apache/apr-util-1.4.1/xml/expat/libexpat.la' or unhandled argument `/home/apache/apr-util-1.4.1/xml/expat/libexpat.la'
然后加了后面一段话,再make的时候 ok (清楚原来make的文件 用#make clean命令)
参考地址:http://crazytoon.com/2010/07/16/error-while-compiling-apache-on-centos-5-5/
make install


#tar -zvxf pcre-8.10.tar.gz
linux-liangfuming:/home/apache # cd pcre-8.10/
linux-liangfuming:/home/apache/pcre-8.10 # ./configure -prefix=/home/apache/pcre

linux-liangfuming:/home/apache # tar -zvxf httpd-2.4.2.tar.gz
#cd httpd
linux-liangfuming:/home/apache/httpd-2.4.2 # ./configure --prefix=/home/apache/apache-home --enable-module=so --with-apr=/home/apache/apr --with-apr-util=/home/apache/apr-util --with-pcre=/home/apache/pcre
启动会报一下错
linux-liangfuming:/home/apache/apache-home/bin # ./httpd -k start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.0.25. Set the 'ServerName' directive globally to suppress this message
只需在httpd.conf文件中添加 ServerName 127.0.0.1:80
重新启动即可

安装PHP
到http://www.php.net/downloads.php 下载php-5.4.4.tar.gz
到http://download.chinaunix.net/download.php?id=35177&ResourceID=6095 下载libxml2-2.7.8.tar.gz

linux-liangfuming:/home/php # tar -zvxf libxml2-2.7.8.tar.gz
linux-liangfuming:/home/php/libxml2-2.7.8 # ./configure

# tar -zvxf php-5.4.4.tar.gz
linux-liangfuming:/home/php # cd php-5.4.4/
linux-liangfuming:/home/php/php-5.4.4 # ./configure --prefix=/home/php/php-home --with-apxs2=/home/apache/apache-home/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml --with-mysql

--with-config-file-path=/usr/local/php/etc 指定自己的php.ini路径 然后从源码里面 cp过去php.ini 源码里面有个php.ini-development和php.ini-production 如果不是本地调试模式的 选择后者。
就是因为没指定这个 所以反问不了php文件


配置httpd.conf 一定要把下面的话注释 否则不能访问
#<Directory />
#    AllowOverride none
#    Require all denied
#</Directory>