PHP5在Ubuntu下的安装问题
以前偷懒,redhat上都是用rpm装apache, PHP, MySQL,而在Ubuntu上都是用apt-get安装的。。但是最近因为想用apache2.2的proxy-ajp,奈何又没有release的安装包,只好硬着头皮自己编译。
编译apache2.2.0的时候很简单,就是把
tar xjf httpd-2.2.0.tar.bz2
把包解开,然后在httpd-2.2.0文件夹里
./configure --prefix=/usr/local/apache2 --enable-proxy --enable-proxy-ajp -enable-proxy-balancer --enable-so
再然后
make && make install
就搞定了。。其中--prefix是制定apache的安装路径,proxy几个是给tomcat连接用的,so是给PHP用的。。
但是紧接着在编译php的时候碰到了钉子!
./configure --with-apxs2=/usr/local/apache2/bin/apxs
她提示:hecking lex output file root... ./configure: line 3246: lex: command not found configure: error: can't find output from lex; giving up
后来查阅了许多资料之后发现,,人家在redhat下编译也遇到了同样的问题。。她需要一个叫做flex的东西。但是解决方案只给出了安装一个flex的rpm,那在Ubuntu下应该怎么办呢?不怕不怕,有新立得软件包管理器呢,关键字flex,很快就查到了。全称为A fast lexical 易做图yzer generator.具体干什么的我也只是一知半解。。反正Ubuntu的新立得软件包管理器里面这么描述来的:
flex is a tool for generating scanners: programs which recognized lexical
patterns in text. flex reads the given input files for a description of a
scanner to generate. The description is in the form of pairs of regular
expressions and C code, called rules. flex generates as output a C source
file, lex.yy.c, which defines a routine yylex(). This file is compiled
and linked with the -lfl library to produce an executable. When the
executable is run, it 易做图yzes its input for occurrences of the regular
expressions. Whenever it finds one, it executes the corresponding C code.
The behaviour of Flex has undergone a major change since version
2.5.4a; Flex scanners are now reenterant, you may have multiple
scanners in the same program with differing sets of defaults, and
they play nicer with modern C and C++ compilers. The Flip side is
that Flex no longer conforms to the POSIX lex behaviour, and the
scanners require conforming implementations when flex is used in ANSI
C mode. The package flex-old provides the older behaviour.
直接
sudo apt-get install flex
安装成功。。重新编译。。但是紧接着又遇到了问题。。
configure: error: xml2-config not found. Please check your libxml2 installation.
吃一堑长一智。。这下顺利多了。。
sudo apt-get install libxml2
//这个包其实默认已经装了。。不过如果没有更新,,她还是会正常进行下去:共升级了 0 个软件包,新安装了 0 个软件包,要卸载 0 个软件包,有 0 个软件未被升级 。
sudo apt-get install libxml2-dev
安装完成后,开始编译。。123
./configure --with-apxs2=/usr/local/apache2/bin/apxs
make && make install
很快就搞定了。。然后把php.ini从安装目录拷过去。。
cp php.ini-dist /usr/local/lib/php.ini
最后修改httpd.conf在里面添加下面几行:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
启动apache,
/usr/local/apache2/bin/apachectl -k start
收工!!
但是还要注意是在httpd.conf中所有含有Order、Allow和Deny的行都要dd掉,不然用“:!bin/apachectl -t”检查的时候会报错。当然了。。httpd服务也是起不起来的。具体原因还没有研究出来。。等有空的时候再说吧。。反正是删掉就行了。。
在此之前,我也曾经想过装FC-5了事。。因为FC-5只要在安装的时候点点鼠标。她就会把apache2.2 tomcat5.5 php5通通都装起来,并且整合好协调工作。。但是因为有很多网友说FC-5还存在着很多问题。。所以就作罢了。。现在想想还是自己编译好。。不用受制于任何操作系统。。UNIX,Linux, BSD。。。爱用哪个就用哪个。。。哈哈本文来自:http://www.xiaoyaxiao.com/5826.html
发表您的高见!