zoukankan      html  css  js  c++  java
  • lamp与lnmp的选择

    lnmp和lamp业务上的不同

    由于二者仅仅是区别在于web的选择,nginx更高效,占用资源更少,详情区别查看LNMP环境应用实践 

    lnmp和lamp安装上的不同

    生产环境中,可能会遇到lamp架构与lnmp架构都在同一台物理服务器的环境,此时
    若php版本高于5.4,则直接编译php支持mod方式和php-cgi方式,也就是我们在LNMP中编译安装的过程
    若php版本不高于5.4,就应该剔除enable-fpm模式,也就是我们在LAMP中编译的过程

    ,apapche是通过模块方式与php互通,而nginx是通过fastcgi互通,所以在php的编译安装上也是因为这层关系,编译参数上有些不同,apache的编译参数相比nginx编译参数缩减了

    --enable-fpm
    --with-fpm-user=www 
    --with-fpm-group=www

    增加了

    --with-apxs2=/application/apache/bin/apxs

    LNMP环境应用实践https://www.cnblogs.com/jokerbj/p/9168573.html (包含mysql安装

    LAMP环境应用实践https://www.cnblogs.com/jokerbj/p/9178156.html

    php编译参数参考

    ./configure # 编译参数
    --prefix=/application/php5.3.27
    # 指定php的安装路径为/application/php5.3.27
    --with-apxs2=/aaplication/apache/bin/apxs
    # 提供将module_php.so嵌入到apache的http.conf中,供静态与动态的沟通,nginx是通过fastcgi
    --with-mysql=/application/mysql/
    # 需要指定mysql的安装路径,安装PHP需要的My# QL相关内容。当然如果没有My# QL软件包,也可以不单独安装,这样的情况可使用--with-mysql=mysqlnd替代--with-mysql=/application/mysql,因为PHP软件里面已经自带连接My# QL的客户端工具。 
    --with-iconv-dir=/application/libiconv   # libiconv库,各种字符集间的转换,如果没有安装请参考前面
    --with-freetype-dir  # 打开对freetype字体库支持
    --with-jpeg-dir # 打开对jpeg图片的支持
    --with-png-dir # 打开对png图片的支持
    --with-zlib # 打开zlib库的支持,用于http压缩传输
    --with-libxml-dir=/usr # 打开libxml2库的支持
    --enable-xml  
    --disable-rpath # 关闭额外的运行库文件
    --enable-safe-mode # 打开安全模式
    --enable-bcmath # 打开图片大小调整,用zabbix监控时会用到该模块
    --enable-shmop 
    --enable-sysvsem # 使用sysv信号机制,则打开此选项
    --enable-inline-optimization # 优化线程
    --with-curl # 打开curl浏览工具的支持
    --with-curlwrappers # 运维curl工具打开url流
    --enable-mbregex 
    --enable-mbstring # 支持mbstring
    --with-mcrypt # 编码函数库
    --with-gd # 打开gd库的支持
    --enable-gd-native-ttf # 支持TrueType字符串函数库
    --with-openssl # openssl的支持,加密传输时用到
    --with-mhash # mhash算法的扩展
    --enable-pcntl # freeTD# 需要用到,可能是链接mssql
    --enable-sockets # 打开sockets支持
    --with-xmlrpc # 打开xml-rpc的c语言
    --enable-zip # 打开对zip的支持
    --enable-soap # soap模块的扩展
    --enable-short-tags # 开始和标记函数
    --enable-zend-multibyte # 支持zend的多字节
    --enable-static # 生成静态链接库
    --with-xsl # 打开X# LT文件支持,扩展libXML2库,需要libxslt软件
    --enable-ftp  # 打开ftp的支持
    --enable-fpm  # 表示激活PHP-FPM方式服务,即FactCGI方式运行PHP服务。
    --with-fpm-user=www  # 指定PHP-FPM进程管理的用户为www,此处最好和Nginx服务用户统一。
    --with-fpm-group=www # 指定PHP-FPM进程管理用户组为www,此处最好和Nginx服务用户组统一。

    PHP安装错误指南,红色是遇到过的

    安装 PHP 5.4.3 报 configure error xml2-config not found. please check your libxml2 installation 错误
    检查是否安装了libxm包
    [root@rh-linux software]# rpm -qa |grep  libxml2
    libxml2-2.6.26-2.1.12
    libxml2-python-2.6.26-2.1.12
    重新安装libxml2和libxml2-devel包, yum安装的时候发现新版本会提示更新,需要更新的可以更新,不要跳过就行了。
    [root@rh-linux /]# yum install libxml2
    [root@rh-linux /]# yum install libxml2-devel -y
    安装完之后查找xml2-config文件是否存在
    [root@rh-linux /] # find / -name "xml2-config"
    /usr/bin/xml2-config
     
    如果存在的话重新安装php
    [root@rh-linux  php-5.4.3]# ./configure
    [root@rh-linux  php-5.4.3]# make
    [root@rh-linux  php-5.4.3]# make install
    安装好php后别忘了配置下php.ini 文件, 
    [root@rh-linux php-5.4.3]# cp php.ini-production /usr/local/lib/php.ini
    也可以直接在 make install 后面加一个编译参数 --with-config-file-path=/usr/local/php/etc 指定自己的php.ini路径 然后从源码里面 cp过去php.ini 源码里面有个php.ini-development和php.ini-production 如果不是本地调试模式的 选择后者
    
     
    [libiconv_open]collect2: ld returned 1 exit status make: *** [sapi/cgi/php-cgi] 错误 1
     
    编译php时出现错误
    
    xmlrpc/libxmlrpc/encodings.c:73: undefined reference to `libiconv_open'
    xmlrpc/libxmlrpc/encodings.c:81: undefined reference to `libiconv'
    xmlrpc/libxmlrpc/encodings.c:101: undefined reference to `libiconv_close'
    collect2: ld returned 1 exit status
    make: *** [sapi/cgi/php-cgi] 错误 1
    
    是由于没有安装 libiconv包,又没有yum源,无法通过yum直接安装,还需要自己手动来。
    先安装libiconv:
    wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
    tar-zxvf libiconv-1.14.tar.gz
    cdlibiconv-1.14
    ./configure--prefix=/usr/local
    make
    sudomakeinstall
    然后重新configure php,再make就ok..
    
    Example
    1
    2
    3
    ./configure--with-iconv=/usr/local
    makeclean
    make
    配置如果“configure:error: libpng.(a|so) not found.”错误。
    
     
    
    解决方法:
    
    根据报错发现是因为libpng.so和libpng.a找不到,检查libpng的相关软件是否已经安装,如果已安装,需要将“/usr/lib64/libpng*”库文件拷贝到“/usr/lib”下。执行如下命令:
    
    1
    [root@web /]#cp -frp /usr/lib64/libpng* /usr/libyuanyi
    原因:因为configure一般的搜索编译路径为/usr/lib/下,而x64位的系统默认在“/usr/lib64”下,因此需要拷贝到“/usr/lib”目录下。
    
    如果报configure: error: libjpeg.(a|so) not found错误解决方法和上面的解决方法类似
     
    
    安装PHP出现make: *** [sapi/cli/php] Error 1 解决办法
     
    
    ext/iconv/.libs/iconv.o: In function `php_iconv_stream_filter_ctor’:
    /home/king/php-5.2.13/ext/iconv/iconv.c:2491: undefined reference to `libiconv_open’
    collect2: ld returned 1 exit status
    make: *** [sapi/cli/php] Error 1
    [root@test php-5.2.13]# vi Makefile
    
    
    在安裝 PHP 到系统中时要是发生「undefined reference to libiconv_open’」之类的错误信息,那表示在「./configure 」沒抓好一些环境变数值。错误发生点在建立「-o sapi/cli/php」是出错,没給到要 link 的 iconv 函式库参数。 解决方法:编辑Makefile 大约77 行左右的地方: EXTRA_LIBS = ….. -lcrypt 在最后加上 -liconv,例如: EXTRA_LIBS = ….. -lcrypt -liconv 然后重新再次 make 即可。
    
    
    或者用另一种办法
    
    make ZEND_EXTRA_LIBS=’-liconv’
    
    ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/
    
    注:加上 -liconv,需要确认已安装libiconv
    
    libiconv安装
    
    http://www.gnu.org/software/libiconv/
    
    # tar -zxvf  libiconv-1.9.2.tar.gz
    # cd libiconv-1.9.2
    # ./configure –prefix=/usr/local
    
    # make
    # make install
    # make clean
    
    再次安装 PHP时又报错
    ext/standard/info.o: In function `php_info_print_request_uri’:
    /root/php-5.4.16/ext/standard/info.c:97: undefined reference to `sapi_globals’
    ext/standard/info.o: In function `php_print_gpcse_array’:
    /root/php-5.4.16/ext/standard/info.c:209: undefined reference to `executor_globals’
    ext/standard/info.o: In function `php_print_info’:
    /root/php-5.4.16/ext/standard/info.c:874: undefined reference to `executor_globals’
    /root/php-5.4.16/ext/standard/info.c:877: undefined reference to `executor_globals’
    /root/php-5.4.16/ext/standard/info.c:880: undefined reference to `executor_globals’
    /root/php-5.4.16/ext/standard/info.c:883: undefined reference to `executor_globals’
    collect2: ld returned 1 exit status
    make: *** [sapi/cli/php] 错误 1
    
    出现这样的错误信息可能是以前用不同的参数编译过PHP。
    
    解决方法:执行make clean删除上次的编译结果,然后再重新编译就OK了。
    
    make ZEND_EXTRA_LIBS=’-liconv’
    
     /libxmlrpc/encoding.c:101:undefined reference to 'libiconv_close'
      collect2: ld returned 1 exit status
      make:*** [sapi/fpm/php-fpm] Error 1
      解决方法:
      #make ZEND_EXTRA_LIBS='-liconv'
      错误一、编译php出错
      /php-5.3.2/ext/fileinfo/libmagic/apprentice.c:147:internal compiler error:Segmentation fault
      Please submit a full bug report,
      with preprocessed source if appropriate.
      See <URL:http://bugzilla.redhat.com/bugzilla> for instructions.
      The bug is not reproducible,so it is likely a hardware or OS problem.
      make:*** [ext/fileinfo/libmagic/apprentice.lo] Error 1
      解决方法:内存大于1G即可,这是php5.3.2的一个bug
      --------------------------------------------------------------------
      错误二、重新构造configure文件出错
      ./buildconf --force
      Forcing 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.
      Can't figure out your VCS, not cleaning.
      解决方法:编译安装autoconf-2.13
      再将autoconf-2.13的auotconf文件至/usr/local/autoconf
      --------------------------------------------------------------------
      错误三、编译时缺少库
      configure: error: libXpm.(a|so) not found.
      解决方法:yum install libXpm-devel
      --------------------------------------------------------------------
      错误四、编译时缺少gmp.h文件
      configure: error: Unable to locate gmp.h
      解决方法:yum install gmp-devel
      --------------------------------------------------------------------
      错误五
      Configure: error: xml2-config not found. Please check your libxml2 installation.
      解决方法:
      #yum install libxml2 libxml2-devel (For Redhat & Fedora)
      # aptitude install libxml2-dev      (For ubuntu)
      --------------------------------------------------------------------
      错误六
      Checking for pkg-config… /usr/bin/pkg-config
      configure: error: Cannot find OpenSSL’s <evp.h>
      解决方法:
      #yum install openssl openssl-devel
      --------------------------------------------------------------------
      错误七
      Configure: error: Please reinstall the BZip2 distribution
      解决方法:
      # yum install bzip2 bzip2-devel
      --------------------------------------------------------------------
      错误八
      Configure: error: Please reinstall the libcurl distribution -
      easy.h should be in <curl-dir>/include/curl/
      解决方法:
      # yum install curl curl-devel   (For Redhat & Fedora)
      # install libcurl4-gnutls-dev    (For Ubuntu)
      --------------------------------------------------------------------
      错误九:
      Configure: error: libjpeg.(also) not found.
      解决方法:
      # yum install libjpeg libjpeg-devel
      --------------------------------------------------------------------
      错误十
      Configure: error: libpng.(also) not found.
      --------------------------------------------------------------------
      解决方法:
      # yum install libpng libpng-devel
      --------------------------------------------------------------------
      错误十一
      Configure: error: freetype.h not found.
      解决方法:
      #yum install freetype-devel
      --------------------------------------------------------------------
      错误十二
      Configure: error: Unable to locate gmp.h
      解决方法:
      # yum install gmp-devel
      --------------------------------------------------------------------
      错误十三
      Configure: error: Cannot find MySQL header files under /usr.
      Note that the MySQL client library is not bundled anymore!
      解决方法:
      # yum install mysql-devel            (For Redhat & Fedora)
      # apt-get install libmysql++-dev      (For Ubuntu)
      --------------------------------------------------------------------
      错误十四
      Configure: error: Please reinstall the ncurses distribution
      解决方法:
      # yum install ncurses ncurses-devel
      --------------------------------------------------------------------
      错误十五
      Checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!
      解决方法:
      # yum install unixODBC-devel
      --------------------------------------------------------------------
      错误十六
      Configure: error: Cannot find pspell
      解决方法:
      # yum install pspell-devel
      --------------------------------------------------------------------
      错误十七
      configure: error: mcrypt.h not found. Please reinstall libmcrypt.
      解决方法:
      # yum install libmcrypt libmcrypt-devel    (For Redhat & Fedora)
      # apt-get install libmcrypt-dev
      --------------------------------------------------------------------
      错误十八
      Configure: error: snmp.h not found. Check your SNMP installation.
      解决方法:
      # yum install net-snmp net-snmp-devel
      --------------------------------------------------------------------
      错误十九
      configure:error:Cannot find ldap.h
      解决方法:
      #yum install openldap-devel openldap
      错误二十
      configure:error:xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
      解决方法:
      #yum install libxslt libxslt-devel
      错误二十一
      checking for libevent >=1.4.11 install prefix… configure: error: Could not find libevent >=1.4.11 in /usr/local/php
      解决方法:
      安装libevent-1.4.11以上版本至/usr/local
      tar xzvf libevent-1.4.14-stable.tar.gz
      cd libevent-1.4.14-stable
      ./configure --prefix=/usr/local
      make&&make install
      在编译。/configure时添加--with-libevent-dir=/usr/local即可
      错误二十二
      cc1: out of memory allocating 2036 bytes after a total of 81846272 bytes
      make: *** [ext/date/lib/parse_date.lo] Error 1
      报错:
      /usr/bin/ld: cannot find -lltdl
      collect2: ld returned 1 exit status
      make:*** [sapi/fpm/php-fpm] Error 1
      解决方法:
      安装ltdl
      #cd /libmcrypt-2.5.7/libltdl/     # 可以通过 yum install libtool-ltdl-devel  解决
      #./configure --enable-ltdl-install
      #ldconfig
      #cd php-5.3.6
      #make ZEND_EXTRA_LIBS='-liconv'
  • 相关阅读:
    poj 3528 (三维几何求凸包+凸包表面积)
    dijkstra模板(好像是斐波那契额堆优化,但我为什么看起来像优先队列优化,和spfa一样)
    最大空凸包模板
    ICPC 2017–2018, NEERC, Northern Subregional Contest St Petersburg, November 4, 2017 I题
    hdu 5248 序列变换
    hdu 2063(二分图模板测试)
    组合数
    85. Maximal Rectangle 由1拼出的最大矩形
    750. Number Of Corner Rectangles四周是点的矩形个数
    801. Minimum Swaps To Make Sequences Increasing 为使两个数组严格递增,所需要的最小交换次数
  • 原文地址:https://www.cnblogs.com/jokerbj/p/9178181.html
Copyright © 2011-2022 走看看