您的位置:首页 > 编程语言 > PHP开发

ubuntu安装LNMP0.6和“502错误及/usr/local/php/sbin/php-fpm: 没有那个文件或目录”解决方案

2011-04-08 19:32 886 查看
本文已测试环境:ubuntu10.04/ubuntu10.10

此问根据debian下系统更改,所以结果对debain应该也适用。





最近想搭个网页服务器,网上一搜,发现有个LNMP一键安装包,做的不错,傻瓜式安装,就尝试了下,但安完有问题,耗费将近一天才解决,重装数次,以下为解决方案。



1、下载LNMP一键安装包:

去这个网站 http://lnmp.org/install.html最好下载完整包。
2、解压LNMP一键安装包:

执行tar zxvf lnmp0.6.tar.gz 或者tar zxvf lnmp0.6-full.tar.gz 就会将LNMP一键安装包解压缩。

3、Ubuntu下安装步骤

cd lnmp0.6-full

sudo sh ./ubuntu.sh |tee lnmp.log



使用 /root/lnmp start 运行。



但安装完之后会出现

502错误
(502 Bad Gateway)

检查php没有成功安装。

/usr/local/php下面没有sbin等文件夹

会报/usr/local/php/sbin/php-fpm文件夹不存在

遂按照脚本手动安装,发现错误,

参照 http://www.yyserver.tk/html/space/LNMP/502/2011/0314/51.html 找到解决办法



究其原因,就是“Autoconf version 2.58 or higher is required for this script ”要求autoconf版本高于2.58而一键安装包里把autoconf版本换成了2.13.所以解决办法如下:



第一种方法
:(推荐用第二种,但此种方法不需要重装,省了很长时间的编译时间。)



首先卸载automake

apt-get remove automake

这样并不能卸载2.13,需要sudo rm /usr/local/bin/autoconf 才行。可能是因为2.13编译问题。

然后去 http://files.directadmin.com/ser ... utoconf-2.61.tar.gz
下载autoconf2.61

(不要使用更高版本,经尝试,出错。看来autoconf版本还是问题很多啊。有人说2.13是最经典版,但php偏偏要求更高版本,无奈啊)

tar xzf autoconf-2.61.tar.gz

cd autoconf-2.61

./configure --prefix=/usr

make

make install



然后重新编译php-fpm(重新解压一次lnmp0.6压缩包,因为下面两个gz文件被删除了。)

tar zxvf php-5.2.14.tar.gz

gzip -d ./suhosin-patch-5.2.14-0.9.7.patch.gz

gzip -cd php-5.2.14-fpm-0.5.14.diff.gz | patch -d php-5.2.14 -p1

cd php-5.2.14/

patch -p 1 -i ../suhosin-patch-5.2.14-0.9.7.patch

./buildconf --force

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic

make ZEND_EXTRA_LIBS='-liconv'

make install

mkdir -p /usr/local/php/etc/

cp php.ini-dist /usr/local/php/etc/php.ini

strip /usr/local/php/bin/php-cgi

cd ../

ln -s /usr/local/php/bin/php /usr/bin/php

cd $cur_dir

tar zxvf memcache-2.2.5.tgz

cd memcache-2.2.5/

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install

cd ../

tar zxvf PDO_MYSQL-1.0.2.tgz

cd PDO_MYSQL-1.0.2/

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql

make && make install

cd ../

# php extensions

sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"/nextension = "memcache.so"/nextension = "pdo_mysql.so"/n#' /usr/local/php/etc/php.ini

sed -i 's#output_buffering = Off#output_buffering = On#' /usr/local/php/etc/php.ini

sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /usr/local/php/etc/php.ini

sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /usr/local/php/etc/php.ini

sed -i 's/;date.timezone =/date.timezone = PRC/g' /usr/local/php/etc/php.ini

sed -i 's/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini

if [ `getconf WORD_BIT` = '32' ] && [ `getconf LONG_BIT` = '64' ] ; then

wget -c http://soft.vpser.net/web/zend/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

mkdir -p /usr/local/zend/

cp ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/

else

wget -c http://soft.vpser.net/web/zend/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz
tar zxvf ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

mkdir -p /usr/local/zend/

cp ZendOptimizer-3.3.9-linux-glibc23-i386/data/5_2_x_comp/ZendOptimizer.so /usr/local/zend/

fi

cat >>/usr/local/php/etc/php.ini<<EOF

;eaccelerator

;ionCube

[Zend Optimizer]

zend_optimizer.optimization_level=1

zend_extension="/usr/local/zend/ZendOptimizer.so"

EOF



-----------------------------------

另一个方法


此方法更改ubuntu.sh 重新安装。(此方法在ubuntu10.10成功,但在ubuntu10.04还是php未安装,不知为什么 。)



首先 ./unistall.sh 卸载。然后删掉解压包,重新解压一个新包。

修改/ubuntu
.sh中的:(277行左右)

cd php-5.2.14/

patch -p 1 -i ../suhosin-patch-5.2.14-0.9.7.patch

更换顺序。

更换 ./buildconf --force

为:

PHP_AUTOCONF=autoconf213 PHP_AUTOHEADER=autoheader213 ./buildconf --force

重新安装lnmp

,此方法完美运行,至今没发现问题。





其实还有种方法
,可以看作前两种的结合。已经在ubuntu10.04尝试,可行。

从上面的链接地址下载autoconf2.61.复制到lnmp解压包里,删除原来的autoconf2.13.修改ubuntu.sh ,替换

2.13为2.61.修改278 279行互换,重新编译安装。




http://lanbolee.com/blog/html/tag/automak 这个链接给出了上面修改的原因,有兴趣深入理解的可以参考。以下为内容复制。

[笔记]PHP阅读源码随笔(一)

几位同事大牛,做了一个开源文档项目 《PHP内核分析》
http://php-internal.com
,内容甚是精彩,也是几位大牛几年经验的总结。

因此,我也开始拜读。学习中。

第一步,准备环境。

在漫长的svn co出PHP 5.3 的源码后,准备buildconf。但是出现了如下的问题。

[root@localhost.localdomain:/root/php/php-src-5.3/]
$ ./buildconf
buildconf: checking installation...
buildconf: autoconf version 2.59 (ok)
buildconf: Your version of autoconf likely contains buggy cache code.
           Running vcsclean for you.
           To avoid this, install autoconf-2.13.
rebuilding aclocal.m4
rebuilding configure
rebuilding acconfig.h
rebuilding main/php_config.h.in
autoheader: WARNING: Using auxiliary files such as `acconfig.h', `config.h.bot'
autoheader: WARNING: and `config.h.top', to define templates for `config.h.in'
autoheader: WARNING: is deprecated and discouraged.
autoheader:
autoheader: WARNING: Using the third argument of `AC_DEFINE' and
autoheader: WARNING: `AC_DEFINE_UNQUOTED' allows to define a template without
autoheader: WARNING: `acconfig.h':
autoheader:
autoheader: WARNING:   AC_DEFINE([NEED_FUNC_MAIN], 1,
autoheader:             [Define if a function `main' is needed.])
autoheader:
autoheader: WARNING: More sophisticated templates can also be produced, see the
autoheader: WARNING: documentation.
[root@localhost.localdomain:/root/php/php-src-5.3/]

其中,问题是在于autoconf 貌似版本过高,因此,yum search了一下(CentOS这样就是方便啊啊啊啊啊啊!!!!——我也咆哮体一下)

[root@localhost.localdomain:/root/php/php-src-5.3/]
$ yum search autoconf
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Reducing CentOS-5 Testing to included packages only
Finished
================= Matched: autoconf ==========================
kdevelop.i386 : C++/C 的集成开发环境
autoconf.noarch : 用来自动配置源码的 GNU 工具。
autoconf213.noarch : 用来自动配置源码的 GNU 工具。
automake.noarch : 自动创建 Makefiles 的 GNU 工具。
libdhcp.i386 : A library for network interface configuration with DHCP
libtool.i386 : GNU 的可移植库工具
libtool-ltdl.i386 : GNU Libtool 动态模块加载程序的运行时库函数
m4.i386 : GNU 宏程序处理器。
[root@localhost.localdomain:/root/php/php-src-5.3/]
$ yum install autoconf213
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Reducing CentOS-5 Testing to included packages only
Finished
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package autoconf213.noarch 0:2.13-12.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================
 Package               Arch    Version     Repository    Size
==============================================================
Installing:
 autoconf213           noarch  2.13-12.1   base         252 k

Transaction Summary
==============================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 252 k
Is this ok [y/N]: y
Downloading Packages:
autoconf213-2.13-12.1.noarch.rpm                                                                                                                                                                                      | 252 kB     00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : autoconf213                                                                                                                                                                                                           1/1 

Installed:
  autoconf213.noarch 0:2.13-12.1                                                                                                                                                                                                             

Complete!
[root@localhost.localdomain:/root/php/php-src-5.3/]
$

再次尝试buildconf

[root@localhost.localdomain:/root/php/php-src-5.3/]
$ ./buildconf
buildconf: checking installation...
buildconf: autoconf version 2.59 (ok)
buildconf: Your version of autoconf likely contains buggy cache code.
           Running vcsclean for you.
           To avoid this, install autoconf-2.13.
rebuilding aclocal.m4
rebuilding configure
rebuilding acconfig.h
rebuilding main/php_config.h.in
autoheader: WARNING: Using auxiliary files such as `acconfig.h', `config.h.bot'
autoheader: WARNING: and `config.h.top', to define templates for `config.h.in'
autoheader: WARNING: is deprecated and discouraged.
autoheader:
autoheader: WARNING: Using the third argument of `AC_DEFINE' and
autoheader: WARNING: `AC_DEFINE_UNQUOTED' allows to define a template without
autoheader: WARNING: `acconfig.h':
autoheader:
autoheader: WARNING:   AC_DEFINE([NEED_FUNC_MAIN], 1,
autoheader:             [Define if a function `main' is needed.])
autoheader:
autoheader: WARNING: More sophisticated templates can also be produced, see the
autoheader: WARNING: documentation.
[root@localhost.localdomain:/root/php/php-src-5.3/]

继续失败

查询原因,在php官方网站中(SVN Access部分 http://www.php.net/svn.php#buildconf_fail
),建议的autoconf、libtool和automake的组合是:

autoconf, automake and libtool information

There seem to be problems with libtool 1.4.2. It is suggested that you
use libtool 1.4, along with autoconf 2.13 and automake 1.4. You should
also ensure that autoconf, automake and libtool are installed in the
same directory. libtool 1.5 will not work.

The following combinations are known to work:

* autoconf 2.13, automake 1.4 and libtool 1.4.3

* autoconf 2.13, automake 1.5 and libtool 1.4.3

* autoconf 2.63, automake 1.11 and libtool 2.2.6 (with many warnings)

If you have multiple versions of autoconf installed on your computer, as
is common for many UNIXes, you can set the PHP_AUTOCONF and
PHP_AUTOHEADER variables when running buildconf to indicate which
versions it should use e.g.:

PHP_AUTOCONF=autoconf213 PHP_AUTOHEADER=autoheader213 ./buildconf

看来是我目前系统中的版本太高。需要降版本。——担心各种依赖 =。=

由于我是CentOS5.5的系统,一直勤快的使用yum update,因此,系统的软件包肯定是发行版中最新的。

故开始卸载:

[root@localhost.localdomain:/root/php/php-src-5.3/]
$ rpm -e autoconf-2.59-12
error: Failed dependencies:
        autoconf >= 2.58 is needed by (installed) automake-1.9.6-2.3.el5.noarch
        autoconf >= 2.50 is needed by (installed) libtool-1.5.22-7.el5_4.i386
        autoconf >= 2.54 is needed by (installed) automake17-1.7.9-7.el5.2.noarch
        autoconf is needed by (installed) php-devel-5.2.10-1.el5.centos.i386
[root@localhost.localdomain:/root/php/php-src-5.3/]
$ rpm -e autoconf-2.59-12 automake libtool
error: Failed dependencies:
        autoconf >= 2.54 is needed by (installed) automake17-1.7.9-7.el5.2.noarch
        autoconf is needed by (installed) php-devel-5.2.10-1.el5.centos.i386
        automake is needed by (installed) php-devel-5.2.10-1.el5.centos.i386
[root@localhost.localdomain:/root/php/php-src-5.3/]
$ rpm -e autoconf automake libtool
error: Failed dependencies:
        autoconf >= 2.54 is needed by (installed) automake17-1.7.9-7.el5.2.noarch
        autoconf is needed by (installed) php-devel-5.2.10-1.el5.centos.i386
        automake is needed by (installed) php-devel-5.2.10-1.el5.centos.i386
[root@localhost.localdomain:/root/php/php-src-5.3/]
$ rpm -e autoconf automake libtool automake17
error: Failed dependencies:
        autoconf is needed by (installed) php-devel-5.2.10-1.el5.centos.i386
        automake is needed by (installed) php-devel-5.2.10-1.el5.centos.i386
[root@localhost.localdomain:/root/php/php-src-5.3/]
$ rpm -e autoconf automake libtool automake17 php-devel libtool-libs
[root@localhost.localdomain:/root/php/php-src-5.3/]

libtool-libs 是对libtool包版本敏感的。卸载 libtool就必须修卸载libs包。故——干掉。

后期安装时,发现:

[root@localhost.localdomain:/root/php/tools/]
$ rpm -ivh *.rpm
warning: automake-1.4p5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
        file /usr/lib/libltdl.so.3 from install of libtool-libs-1.4.3-5.i386 conflicts with file from package libtool-ltdl-1.5.22-7.el5_4.i386
[root@localhost.localdomain:/root/php/tools/]
$ rpm -aq | grep libtool-ltdl
libtool-ltdl-1.5.22-7.el5_4
[root@localhost.localdomain:/root/php/tools/]
$ rpm -e libtool-ltdl
error: Failed dependencies:
        libltdl.so.3 is needed by (installed) guile-1.8.0-8.20060831cvs.i386
        libltdl.so.3 is needed by (installed) mysql-connector-odbc-3.51.26r1127-1.el5.i386
[root@localhost.localdomain:/root/php/tools/]
$ rpm -e --nodeps libtool-ltdl
[root@localhost.localdomain:/root/php/tools/]

终于,这个世界清静了。——这就是我为什么讨厌没有外网,没有Yum的原因。

下面找AutoTools相关的各种包。根据php官方的建议,找到这些古董版本的包:

[root@localhost.localdomain:/root/php/tools/]
$ ll
总计 1032
-rw-r--r-- 1 root root 229965 03-18 13:58 autoconf-2.13-5.noarch.rpm
-rw-r--r-- 1 root root 309067 03-18 14:02 automake-1.4p5-4.noarch.rpm
-rw-r--r-- 1 root root 477714 03-18 13:52 libtool-1.4.3-5.i386.rpm
-rw-r--r-- 1 root root  19472 03-18 13:55 libtool-libs-1.4.3-5.i386.rpm
[root@localhost.localdomain:/root/php/tools/]
$ rpm -ivh *.rpm
warning: automake-1.4p5-4.noarch.rpm: Header V3 DSA signature: NOKEY, key ID db42a60e
Preparing...                ########################################### [100%]
   1:automake               ########################################### [ 25%]
   2:autoconf               ########################################### [ 50%]
   3:libtool-libs           ########################################### [ 75%]
   4:libtool                ########################################### [100%]
[root@localhost.localdomain:/root/php/tools/]

淡定鸟。。。

继续编译php

[root@localhost.localdomain:/root/php/php-src-5.3/]
$ ./buildconf
buildconf: checking installation...
buildconf: autoconf version 2.13 (ok)
[root@localhost.localdomain:/root/php/php-src-5.3/]
./configure
...
...
...
此处省略1w字
...
...
...
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... no
checking whether to build static libraries... yes

creating libtool
appending configuration tag "CXX" to libtool

Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating main/php_config.h
config.status: executing default commands
[root@localhost.localdomain:/root/php/php-src-5.3/]

…..埋坑儿
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐