標籤:php zabbix
公司共有幾十台伺服器,已經架起了cacti整合nagios架構的監控系統,為了可以對比監控的資料的準確性,準備搭建zabbix的監控平台。伺服器已經沒多少閒置了,就在一台IBM的機器上虛擬化的幾台虛擬機器,使用其中的一台虛擬機器搭建zabbix監控平台。
按照了搭建zabbix的方法,使用RPM包的方式大家愛你LAMP平台,從網上下載php-bcmath和php-mbstring RPM包安裝,出現了錯誤的提示,提示是系統架構不同,使用命令uname -m 查看機器的硬體架構,輸出的不是熟知的x86_64、x64,而是ppc64,由於使用的php-bcmath和php-mbstring都是x86_64平台下。網上在各個RPM包網站中搜查,都沒有找到適合的版本,決定採用php源碼包的安裝,而apache和mysql保留使用系統內建的RPM包。
作業系統:RedHat 6.4
PHP版本:php-5.4.19.tar.gz
用到的軟體包:fontconfig-2.4.2.tar.gz、freetype-2.3.5.tar.gz、gd-2.0.33.tar.gz、jpegsrc.v6b.tar.gz、libpng-1.2.18.tar.gz、libxml2-2.6.32.tar.gz、zlib-1.2.3.tar.gz
一、安裝php前置包,支援GD庫
1、安裝 zlib
tar zlib-1.2.3.tar.gz
cd zlib-1.2.3
CFLAGS="-O3 -fPIC" ./configure //一行命令,必須加前面的編譯環境參數編譯,不然報錯
make
make install
2、安裝 libpng
tar zxvf libpng-1.2.18.tar.tar
cd libpng-1.2.18
./configure --prefix=/usr/local/libpng
make
make install
3、安裝jpeg
mkdir /usr/local/jpeg
mkdir /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir /usr/local/jpeg/man
mkdir /usr/local/jpeg/man/man1
tar zxf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local/jpeg --enable-shared --enable-static
make
make install
make可能會報錯
./libtool --mode=compile gcc -O2 -I. -c ./jcapimin.c
make: ./libtool:命令未找到
make: *** [jcapimin.lo] 錯誤 127
解決方案:
首先看有沒有安裝 及 libtool-ltdl-devel
rpm -qa | grep libtool
有網路yum源的直接用yum安裝 yum -y install libtool-ltdl-devel,無網路yum源的,由於系統內建的rpm包中無這個包,使用源碼安裝的方式:
tar zxf libtool-2.2.6a.tar.gz
cd libtool-2.2.6
./configure
make
make install
然後進入jpeg-6b的源碼目錄,然後執行以下步驟,切記!COPY到目前的目錄注意後面的點(.)
cp /usr/local/share/libtool/config/config.sub .
cp /usr/local/share/libtool/config/config.guess .
也就是把config裡面的兩個設定檔拿來覆蓋掉jpeg-6b目錄下的對應檔案
make clean 再重新configure
沒有許可權的時候先建立對應的檔案夾,再次make install就行了
4、 安裝 freetype
tar zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure --prefix=/usr/local/freetype
make
make install
5、安裝libxml2
tar –zxvf libxml2-2.6.32.tar.gz
cd libxml2-2.6.32
./configure
make
make install
6、安裝 Fontconfig
vim /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
source /etc/profile
tar -zxvf fontconfig-2.4.2.tar.gz
cd fontconfig-2.4.2
./configure --with-freetype-config=/usr/local/freetype/bin/freetype-config
make
make install
6、安裝GD
tar -zxvf gd-2.0.34.tar.gz
cd gd-2.0.34
./configure --with-png=/usr/local/libpng/ --with-freetype=/usr/local/freetype/ --with-jpeg=/usr/local/jpeg/
必須是顯示是這些資訊:
** Configuration summary for gd 2.0.33:
Support for PNG library: yes
Support for JPEG library: yes
Support for Freetype 2.x library: yes
Support for Fontconfig library: yes
Support for Xpm library: no
Support for pthreads: yes
make
make install
make出錯顯示沒有找到libpng.h標頭檔
方法:
解決辦法:
vi gd_png.c
將
#include “png.h”
替換成:
#include “/usr/local/libpng/include/png.h”
然後再make就可以了
二、安裝PHP
1、為了是源碼包安裝的PHP可以適應RPM包安裝的apache和mysql,使用了RPM安裝LAMP平台,然後擷取PHP的編譯參數的方法。
yum -y install httpd mysql-server mysql php php-mysql php-pdo
然後啟動apache和mysql,在html目錄下建立一個以.php為尾碼檔案,寫入如下內容:
<?php
phpinfo();
?>
在相應的機器上輸入http://IP地址/檔案名稱,根據輸出的PHP資訊,在configuration欄複製配置資訊,注意去掉但引號。根據版本支援的配置命令和自己的需要改寫配置參數,由於之前已經做了修改,所以直接進行下一步。
2、安裝php
yum -y install httpd mysql-server mysql
tar zxf php-5.4.19.tar.gz -C /usr/src/
cd /usr/src/php-5.4.19/
php編譯參數:
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php --disable-debug --with-pic --disable-rpath --without-pear --with-bz2 --enable-gd-native-ttf --without-gdbm --with-gettext --with-gmp --with-iconv --with-openssl --with-zlib --enable-exif --enable-ftp --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --with-kerberos --enable-shmop --enable-calendar --enable-xml --with-apxs2=/usr/sbin/apxs --without-mysql --without-gd --disable-dom --disable-dba --without-unixODBC --enable-pdo --disable-xmlreader --disable-xmlwriter --disable-phar --disable-fileinfo --disable-json --without-pspell --disable-wddx --without-curl --disable-posix --disable-sysvmsg --disable-sysvshm --disable-sysvsem --enable-mbstring --enable-bcmath --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-gd=/usr/local/ --enable-gd-native-ttf --enable-gd-jis-conv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-zlib-dir=/usr/local/ --enable-xmlwriter --enable-xmlreader
配置出現的錯誤:
./configure: line 8410: /usr/sbin/apxs: No such file or directory
yum install -y httpd-devel
configure: error: Cannot find OpenSSL‘s <evp.h>
yum -y install openssl-devel
onfigure: error: Please reinstall the BZip2 distribution
yum install bzip2-devel
configure: error: Unable to locate gmp.h
yum install gmp-devel
make
make install
make時5.4版本有一個BUG:
/usr/src/php-5.4.19/ext/gd/gd_ctx.c: 在函數‘_php_image_stream_ctxfree’中:
/usr/src/php-5.4.19/ext/gd/gd_ctx.c:67: 錯誤:‘struct gdIOCtx’沒有名為‘data’的成員
/usr/src/php-5.4.19/ext/gd/gd_ctx.c:68: 錯誤:‘struct gdIOCtx’沒有名為‘data’的成員
/usr/src/php-5.4.19/ext/gd/gd_ctx.c:69: 錯誤:‘struct gdIOCtx’沒有名為‘data’的成員
In file included from /usr/src/php-5.4.19/ext/gd/gd.c:103:
/usr/src/php-5.4.19/ext/gd/gd_ctx.c: 在函數‘_php_image_output_ctx’中:
/usr/src/php-5.4.19/ext/gd/gd_ctx.c:153: 錯誤:‘gdIOCtx’沒有名為‘data’的成員
make: *** [ext/gd/gd.lo] 錯誤 1
修複:
vim /usr/local/include/gd_io.h
/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
int (*seek) (struct gdIOCtx *, const int);
long (*tell) (struct gdIOCtx *);
void (*gd_free) (struct gdIOCtx *);
void (*data);//增加這句
}
gdIOCtx;
安裝PHP後為使用方便增加這個命令:
ln –s /usr/local/php/bin/* /usr/local/bin/
3、配置apache,並啟動apache、mysql
vim /etc/httpd/conf/httpd.conf
AddHandler php5-script .php
AddType text/html .php
DirectoryIndex index.php
service httpd start
service mysqld start
chkconfig --level 35 httpd on
chkconfig --level 35 mysqld on
4、測試php
vim /var/www/html/test1.php
<?php
phpinfo();
?>
輸出php 5.4的資訊,表示php 5.4能被apache調用
vim /var/www/html/test2.php
<?php
$link=mysql_connect(‘127.0.0.1‘,‘test‘,‘‘);
if($link) echo "恭喜你,資料庫連接成功啦 !!";
mysql_close();
不過把127.0.0.1替換成localhost後,資料庫就串連失敗,沒找到解決的方法。
這樣LAMP平台就搭建好了,解決的RPM包安裝PHP時缺少必要的主件,可以放心的安裝zabbix軟體了。
本文出自 “霧擬” 部落格,請務必保留此出處http://chenlz.blog.51cto.com/5069563/1585280
ppc64架構上源碼編譯php