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

编译安装php时 出现的问题总结

2016-10-26 18:18 671 查看
因为我是使用的编译安装,服务器没有外网。记录一下编译安装的可能会出现问题的

php-5.3.29 +mysql5.1.71

1、安装mysql.so 通过phpinfo 页面 发现无法加载so,查看httpd的error日志发现
failed to map segment from shared object: Permission denied in

<b>Warning</b>:  PHP Startup: Unable to load dynamic library '/etc/httpd/php/lib/php/extensions/no-debug-non-zts-20090626/mysql.so' - /etc/httpd/php/lib/php/extensions/no-debug-non-zts-20090626/mysql.so: failed to map segment from shared object: Permission
denied in <b>Unknown</b> on line <b>0</b><br />

解决方法:

chcon -R -h -t httpd_sys_script_exec_t  /etc/httpd/php/lib/php/extensions/no-debug-non-zts-20090626/mysql.so

2、编译mysql.so的时候 发现

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers

这不是一个告警 ,必须重新安装re2c 0.13.4 或者更高版本才可以

解决方法:
tar zxf re2c-0.13.5.tar.gz && cd re2c-0.13.5
./configure
make && make install

3、访问thinkphp首页 _STORAGE_WRITE_ERROR_:./Application/Runtime/Cache/User/788524be80db1959c132efbce25367a0.php

访问首页时 显示 Application/Runtime 不可编辑

解决方法:
rm -rf Runtime/*
chmod 777 %项目目录%

4、 编译安装pdo_msyql.so的时候
checking for MySQL UNIX socket location... /var/lib/mysql/mysql.sock
configure: error: Cannot find libmysqlclient under /usr.
Note that the MySQL client library is not bundled anymore!

64位的系统,libmysqlclient.so默认安装在/user/lib64/mysql 但是安装的时候 会去找/user/lib/mysql

解决方法:
先查看一下libmysqlclient.so 目录
find / -name libmysqlclient.so
可以增加软链解决;

ln -s /usr/lib64/mysql/libmysqlclient.so /usr/lib/libmysqlclient.so

5、 Undefined class constant 'MYSQL_ATTR_INIT_COMMAND'

需要编译安装mysql.so pdo_mysql

进行php源代码的ext中
/etc/httpd/php/bin/phpize   --/etc/httpd/php/bin 为php的bin目录
.configure
make && make install

然后需在php.ini中增加对应的配置

extension_dir = "/etc/httpd/php/lib/php/extensions/no-debug-non-zts-20090626/"
extension="pdo_mysql.so"  
extension="mysql.so"

6. configure时 Cannot find config.m4. 

Make sure that you run '/home/zhuyx/local/php-5.5.3/bin/phpize' in the top level source directory of the module

phpize扩展安装,源包需要有config.m4这个配置文件

解决方法:
比较粗暴的时 可以看下将config0.m4  将这个文件改成config.m4
mv config0.m4 config.m4

7 安装后 发现thinkphp 提示 
SQLSTATE[HY000] [2003] Can't connect to MySQL server on 'XXX' (13)

解决方法:
getsebool -a | grep httpd

找到一个 httpd_can_network_connect --> off

修改这个值
#setsebool httpd_can_network_connect 1

8.编译 mysql.so时

configure: error: Try adding --with-zlib-dir=

. Please check config.log for more information.

解决方法: 

    编译时configure 带上参数 --with-zlib-dir

9、访问时 HTTP 错误 403 - 禁止访问,即403 Forbidden:You don't have permission to access / on this server.

需要检查
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
由于配置了php后,此处“Deny from all”为拒绝一切连接。
把此行修改为 “Allow from all”,即可解决问题。

安装时候 由于把Root指定了目录,建议安装时默认的目录 
DocumentRoot "/var/www/html/"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  configure php