linux安装php 出现Sorry, I cannot run apxs

tar -zxvf php-5.6.40.tar.gz

cd php-5.6.40.tar.gz

./configure --prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc \

--with-apxs2=/usr/local/httpd/bin/apxs \

--with-mysql=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-freetype-dir=/usr/local/freetype \

--with-gd \

--with-curl \

--with-zip \

--with-zlib --with-libxml-dir=/usr/local/libxml2 \

--with-jpeg-dir=/usr/local/jpeg \

--with-png-dir \

--enable-mbstring=all \

--enable-mbregex \

--enable-shared \

--with-openssl \

--enable-soap \

--enable-fpm \

--enable-sockets \

--with-xpm-dir=/usr/lib64

linux安装php 出现Sorry, I cannot run apxs_第1张图片

*** 注: 在configure过程中, 可能会遇到下面的错误! Sorry, I cannot run apxs. ***

Sorry, I cannot run apxs. Possible reasons follow:

1. Perl is not installed

2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs

3. Apache was not built using --enable-so (the apxs usage page is displayed)

可按照提示一步步处理

#yum install -y perl*

#yum install -y httpd-devel

#find / -name apxs 得到的路径是:/usr/local/httpd/bin/apxs

于是修改--with-apsx2=/usr/local/httpd/bin/apxs指定到正确路径

如果这样处理后还是有问题。那我们就看看这个apxs文件是否正常?

OK, 下面我说明一下我是如何解决这个问题的:

首先, 通过错误提示, 我们得知"I cannot run apxs". 我一直以为是apxs安装有问题, 但找了很久仍未得到合理的解释和解决方法.

于是我直接运行"/usr/local/apache/bin/apxs"这个脚本, 得到下面的错误提示:

bash: ./apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory

哦, 给人的感觉很像仍然是apxs程序有问题, 但问题在哪里呢? "interpreter"是什么呢? interpreter是"解释程序"!

嗯, 看来我们接近答案了, 运行"head -1 /usr/local/apache/bin/apxs"得到下面内容:

#!/replace/with/path/to/perl/interpreter -w

天啊, 这里没有指明正确的perl执行程序的位置! 原来这就才是真正的问题原因所在!!!

把这一行更改为"#!/usr/bin/perl -w". 再运行php的configure, 一切正常!

至此, 问题已解决.

*** Sorry, I cannot run apxs. ***

linux安装php 出现Sorry, I cannot run apxs_第2张图片

 

观注快乐程序员公众号,每日分享一点小知识。爱编程,爱生活!

 

你可能感兴趣的:(php)