nginx,php安装时可能出现加载共享库libluajit-5.1.so.2,libiconv.so.2失败的解决及linux下php5.6的安装,php中.configure常用安装配置参数详解

一、nginx,php安装时可能出现加载共享库libluajit-5.1.so.2,libiconv.so.2失败的解决

    nginx安装成功后,执行检查和启动nginx时出现报错:error while loading shared libraries: libluajit-5.1.so.2 详细如下(publish:June 26, 2017 -Monday):

[dever@localhost conf]$ sudo /opt/modules/nginx/sbin/nginx 
/opt/modules/nginx/sbin/nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory
[dever@localhost conf]$ sudo /opt/modules/nginx/sbin/nginx -t
/opt/modules/nginx/sbin/nginx: error while loading shared libraries: libluajit-5.1.so.2: cannot open shared object file: No such file or directory

    因为luajit是刚安装的应用,执行updatedb后通过locate查看发现文件存在:

[webdev@localhost conf]$ locate libluajit-5.1.so
/usr/local/lib/libluajit-5.1.so
/usr/local/lib/libluajit-5.1.so.2
/usr/local/lib/libluajit-5.1.so.2.0.4

 

    可以看到动态装入器里未找到所需要的文件libluajit-5.1.so.2。但文件存在,可以通过修改ld.so.conf文件,也可以修改其引入的文件夹/etc/ld.so.conf.d/,增加一个文件。

sudo echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
sudo touch /etc/ld.so.conf.d/usr_local_lib.conf
sudo vim /etc/ld.so.conf.d/usr_local_lib.conf

     有可能提示:-bash: /etc/ld.so.conf.d/usr_local_lib.conf: Permission denied ,可以通过vim进行编辑修改。在安装PHP时也遇到报错:查找也一样有文件存在。和这个是一样的问题:

/opt/downloads/php-7.1.3/sapi/cli/php: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
[dever@localhost php-7.1.3]$ locate libiconv.so.2
/opt/downloads/libiconv-1.14/lib/.libs/libiconv.so.2
/opt/downloads/libiconv-1.14/lib/.libs/libiconv.so.2.5.1
/usr/local/lib/libiconv.so.2
/usr/local/lib/libiconv.so.2.5.1

    通过上面的方法一同可解决。本文中的问题主要是涉及Linux中负责将这些程序和所有必需的共享库一起装入的动态装入器(dynamic loader)加载动态库失败,更多内容可百度搜索动态装入器(dynamic loader),我们只要知道如果想加载共享库,需要有一个ldd清单ld.so.conf配置的内容及加载的目录,里面列出哪些目录下的文件可当做共享库进行加载。修改此文件后需执行ldconfig 命令更新清单。

要查看 ldconfig 可以“看到”的所有共享库,请输入:

# ldconfig -p | less

二、linux下php5.6的安装,php中 .configure常用安装配置参数详解

    只是做个笔记,方便以后还要安装,这是php5.6.30的安装,PHP不同的版本./configure后面的配置参数可能会有细微的变化。在安装PHP7的时候我也使用了--with-mysql=mysqlnd,但其实这项没有什么用,还有--with-zend-vm=GOTO项,在安装PHP7时可以不用。具体配置项可以通过./configure --help命令查看(publish:June 26, 2017 -Monday)。

cd /opt/downloads/
sudo wget http://cn2.php.net/get/php-5.6.30.tar.gz/from/this/mirror
sudo mv mirror php5.6.30.tar.gz
sudo tar zxvf php5.6.30.tar.gz 
sudo ./configure --prefix=/opt/modules/php/ --with-config-file-path=/opt/modules/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --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 --with-pear --with-gettext --enable-sysvshm --enable-exif --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-pdo-mysql=mysqlnd --with-zend-vm=GOTO --enable-opcache
sudo make ZEND_EXTRA_LIBS='-liconv' && sudo make install

php安装时.configure常用安装配置参数详解,更多参数请执行:./configure --help

--prefix=/usr/local/php                     #PHP安装目录
--with-config-file-path=/usr/local/php/etc  #指定php.ini位置
--with-mysql=/usr/local/mysql               #MySQL安装目录,对mysql的支持
--with-mysqli=/usr/local/mysql/bin/mysql_config     #mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定。
--with-apxs2=/usr/local/apache/bin/apxs     #整合 apache,apxs功能是使用mod_so中的LoadModule指令,加载指定模块到 apache,要求 apache 要打开SO模块
--with-iconv-dir=/usr/local                 #选项指令 --with-iconv-dir 用于 PHP 编译时指定 iconv 在系统里的路径,否则会扫描默认路径。
--with-freetype-dir     #打开对freetype字体库的支持 
--with-jpeg-dir         #打开对jpeg图片的支持 
--with-png-dir          #打开对png图片的支持 
--with-zlib-dir         #打开zlib库的支持,用于http压缩传输
--with-libxml-dir       #打开libxml2库的支持
--disable-rpath         #关闭额外的运行库文件 
--enable-bcmath         #打开图片大小调整,用到zabbix监控的时候用到了这个模块
--enable-shmop --enable-sysvsem  #这样就使得你的PHP系统可以处理相关的IPC函数了。
--enable-inline-optimization     #优化线程
--with-curl             #打开curl浏览工具的支持 
--with-curlwrappers     #运用curl工具打开url流 
--enable-mbregex
--enable-fpm            #打上PHP-fpm 补丁后才有这个参数,CGI方式安装的启动程序
--enable-mbstring       #多字节,字符串的支持 
--with-mcrypt           #mcrypt算法扩展
--with-mhash            #mhash算法扩展
--with-gd               #打开gd库的支持 
--enable-gd-native-ttf  #支持TrueType字符串函数库
--with-openssl          #openssl的支持,加密传输https时用到的
--enable-pcntl          #freeTDS需要用到的,可能是链接mssql 才用到
--enable-sockets        #打开 sockets 支持
--with-xmlrpc           #打开xml-rpc的C语言 
--enable-zip            #打开对zip的支持 
--enable-ftp            #打开ftp的支持 
--with-bz2              #打开对bz2文件的支持        
--without-iconv         #关闭iconv函数,字符集间的转换 
--with-ttf              #打开freetype1.*的支持,可以不加了 
--with-xsl              #打开XSLT 文件支持,扩展了libXML2库 ,需要libxslt软件 
--with-gettext          #打开gnu 的gettext 支持,编码库用到 
--with-pear             #打开pear命令的支持,PHP扩展用的 
--enable-calendar       #打开日历扩展功能
--enable-exif           #图片的元数据支持 
--enable-magic-quotes   #魔术引用的支持 
--disable-debug         #关闭调试模式 
--with-mime-magic=/usr/share/file/magic.mime      #魔术头文件位置

#CGI方式安装才用的参数
--enable-fastCGI            #支持fastcgi方式启动PHP
--enable-force-CGI-redirect #重定向方式启动PHP
--with-ncurses              #支持ncurses 屏幕绘制以及基于文本终端的图形互动功能的动态库
--with-gmp                  #应该是支持一种规范
--enable-dbase              #建立DBA 作为共享模块
--with-pcre-dir=/usr/local/bin/pcre-config      #perl的正则库案安装位置
--disable-dmalloc
--with-gdbm                 #dba的gdbm支持
--enable-sigchild
--enable-sysvshm
--enable-zend-multibyte     #支持zend的多字节
--enable-wddx
  • 15
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林戈的IT生涯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值