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'

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM