ラベル PHP の投稿を表示しています。 すべての投稿を表示
ラベル PHP の投稿を表示しています。 すべての投稿を表示

2012年9月26日水曜日

PHP 5.4でZabbixが文字化け?

Twitterでつぶやいていた人がいらっしゃったので確認してみた。

自分でPHPをconfigureからやってもいいのですが、他人に詳細を説
明するのが面倒なので、標準で5.4が利用できるFedora 17を選択。
Zabbixのバージョンは、2.0.2を利用。

----------
結論:
----------
 全く問題なくメニューやグラフにも日本語が表示できる。

----------
障害原因の予測:
----------
・必要なPHPのライブラリがインストールされていない。

 MySQLを利用しているなら、

  # yum install php-bcmath php-gd php-mbstring php-xml php-common php-pdo php-mysql

 とインストールしておけばOK。
 独自にPHPをconfigureから実施したのであれば、何らかの引数が
 不足していると思われる。

・日本語表示可能なフォントが配置及び設定されていない。

 ZabbixのPHPファイル群を配置したfontsディレクトリに、日本語
 が表示可能なTureTypeフォントを配置して、

  include/defines.inc.php

 内の「ZBX_GRAPH_FONT_NAME」「ZBX_FONT_NAME」に配置したフォ
 ントの拡張子を除いた文字列を設定する。

 Fedora 17なら、vlgothic-p-fontsというパッケージに含まれる
 「/usr/share/fonts/vlgothic/VL-PGothic-Regular.ttf」を利用
 して、先ほどの変数には「VL-PGothic-Regular」を指定するとい
 い感じに表示してくれる。

2012年2月28日火曜日

CentOS 6標準phpのConfigureコマンド

情報提供用の書き込みです。

CentOS 6のphpのphpinfo()の出力の一部です。

Configure Command => './configure' '--build=i686-pc-linux-gnu' '--host=i686-pc-linux-gnu' '--target=i686-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--with-kerberos' '--enable-ucd-snmp-hack' '--enable-shmop' '--enable-calendar' '--without-sqlite' '--with-libxml-dir=/usr' '--enable-xml' '--with-system-tzdata' '--enable-force-cgi-redirect' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbregex' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/bin/mysql_config' '--enable-dom=shared' '--with-pgsql=shared' '--enable-wddx=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--with-curl=shared,/usr' '--enable-fastcgi' '--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr' '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr' '--with-sqlite3=shared,/usr' '--enable-json=shared' '--enable-zip=shared' '--without-readline' '--with-libedit' '--with-pspell=shared' '--enable-phar=shared' '--with-tidy=shared,/usr' '--enable-sysvmsg=shared' '--enable-sysvshm=shared' '--enable-sysvsem=shared' '--enable-posix=shared' '--with-unixODBC=shared,/usr' '--enable-fileinfo=shared' '--enable-intl=shared' '--with-icu-dir=/usr' '--with-enchant=shared,/usr' '--with-recode=shared,/usr'

2010年11月27日土曜日

CentOS 5.5 + MySQL 5.1.53 + Zabbix 1.8.3

CentOS 5.5上にMySQL 5.1.53をインストールし、さらにそのサーバ上でZabbix 1.8.3を稼働させます。

CentOS 5.5標準のMySQLではバージョンが古いため、新しいバージョンで実装された機能を利用することができません。
ZABBIX-JPのフォーラムを見ていて、MySQL 5.1.53でInnoDB Pluginを利用した環境を構築したいという要望が挙っていたので、どうすれば簡単に構築できるか検証してみました。
極力標準のRPMそのままか、共存できることを意識して構築を進めることとします。

InnoDB Pluginを利用するメリットに関しては、検索すればすぐ出てくるので検索してみてください。

ただし、以下の手順は十分な試験を行っていませんので、ご自身で責任を持ってトライしてください。

----------
1.MySQL 5.1.53のインストール

MySQLのパッケージを
 http://dev.mysql.com/downloads/mysql/
からダウンロードします。

ダウンロードするのは、

 MySQL-server-community-5.1.53-1.rhel5.x86_64.rpm
 MySQL-client-community-5.1.53-1.rhel5.x86_64.rpm
 MySQL-devel-community-5.1.53-1.rhel5.x86_64.rpm

です。
この後の手順で、MySQLのライブラリを利用したコンパイルを行うので、develパッケージも必要です。

ダウンロードしたら、これらのパッケージをインストールします。

 # rpm -ivh MySQL-server-community-5.1.53-1.rhel5.x86_64.rpm MySQL-client-community-5.1.53-1.rhel5.x86_64.rpm MySQL-devel-community-5.1.53-1.rhel5.x86_64.rpm

インストール後、MySQLの設定を変更するため、一度サービスを停止します。

 # service mysql stop

InnoDBのエンジンとしてInnoDB Pluginを利用するため、ベースとなる設定ファイルに変更します。

 # cp /usr/share/mysql/my-small.cnf /etc/my.cnf

/etc/my.cnfのmysqldセクションに、以下のような設定を追加します。

---
[mysqld]
...
ignore-builtin-innodb
plugin-load=innodb=ha_innodb_plugin.so
default-character-set=utf8
innodb_file_per_table
...
---

設定追加後、サービスを起動します。

 # service mysql start

確認方法は、mysqlコマンドで接続してshow pluginsコマンドを実行すると以下のように表示されます。

---
mysql> show plugins;
+------------+----------+----------------+---------------------+---------+
| Name | Status | Type | Library | License |
+------------+----------+----------------+---------------------+---------+
| binlog | ACTIVE | STORAGE ENGINE | NULL | GPL |
| partition | ACTIVE | STORAGE ENGINE | NULL | GPL |
| ARCHIVE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| BLACKHOLE | ACTIVE | STORAGE ENGINE | NULL | GPL |
| CSV | ACTIVE | STORAGE ENGINE | NULL | GPL |
| FEDERATED | DISABLED | STORAGE ENGINE | NULL | GPL |
| MEMORY | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MyISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| MRG_MYISAM | ACTIVE | STORAGE ENGINE | NULL | GPL |
| InnoDB | ACTIVE | STORAGE ENGINE | ha_innodb_plugin.so | GPL |
+------------+----------+----------------+---------------------+---------+
10 rows in set (0.01 sec)

mysql>
---


----------
2.phpパッケージの作成

事前に、MySQLのライブラリを利用したビルドができるよう、リンクを作成しておきます。

 # ln -s /usr/bin/mysql_config /usr/lib64/mysql/

RPM作成用のアカウントを作成して、そのアカウントでRPMを作成するためのディレクトリを作成します。

 $ mkdir -p ~/rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS}

次に、~/.rpmmacrosを作成して、以下の記述を行います。

---
%_topdir /home/ユーザー名/rpm
%_builddir %{_topdir}/BUILD
%_rpmdir %{_topdir}/RPMS
%_sourcedir %{_topdir}/SOURCES
%_specdir %{_topdir}/SPECS
%_srcrpmdir %{_topdir}/SRPMS
---

CentOSのミラーサイトから、phpのSRPMをダウンロードし、RPM作成用のアカウントでインストールします。

 $ rpm -ivh php-5.1.6-27.el5.src.rpm

そのままでは、コンパイル時にエラーとなってしまうので、ソースのtarball内のソースの一部を書き換えて、またもとのtarballに作成し直して置き換えます。

 $ cd ~/rpm/SOURCES/
 $ tar zxvf php-5.1.6.tar.gz
 $ cd php-5.1.6/ext/mysqli

mysqli_api.c内の「gtpr」を「char*」に変更します。

 $ cd ~/rpm/SOURCES/
 $ mv php-5.1.6.tar.gz php-5.1.6.tar.gz.org
 $ tar zcvf php-5.1.6.tar.gz php-5.1.6

置き換えたら、RPMのビルドを実行します。
足らないビルド用のRPMが不足していたら随時インストールします。

 # yum install bzip2-devel curl-devel db4-devel expat-devel gmp-devel aspell-devel httpd-devel libjpeg-devel libpng-devel pam-devel openssl-devel sqlite-devel zlib-devel pcre-devel krb5-devel libc-client-devel cyrus-sasl-devel openldap-devel postgresql-devel unixODBC-devel libxml2-devel net-snmp-devel libxslt-devel libxml2-devel ncurses-devel gd-devel freetype-devel

 $ cd ~/rpm/SPECS/
 $ rpmbuild -bb --define 'dist .el5' php.spec


----------
3.Zabbixパッケージの作成

Zabbixのパッケージを作成するために必要なパッケージをインストールします。

 # yum install gnutls-devel OpenIPMI-devel

以下のパッケージに関しては、ZABBIX-JPが公開しているRPMをダウンロードしてインストールしておきます。

 # wget http://www.zabbix.jp/binaries/relatedpkgs/rhel5/x86_64/fping-2.4b2-16.el5.JP.x86_64.rpm
 # wget http://www.zabbix.jp/binaries/relatedpkgs/rhel5/x86_64/iksemel-1.2-13.el5.JP.x86_64.rpm
 # wget http://www.zabbix.jp/binaries/relatedpkgs/rhel5/x86_64/iksemel-devel-1.2-13.el5.JP.x86_64.rpm
 # wget http://www.zabbix.jp/binaries/relatedpkgs/rhel5/x86_64/libssh2-1.2.5-1.el5.JP.x86_64.rpm
 # wget http://www.zabbix.jp/binaries/relatedpkgs/rhel5/x86_64/libssh2-devel-1.2.5-1.el5.JP.x86_64.rpm
 # rpm -ivh fping-2.4b2-16.el5.JP.x86_64.rpm iksemel-1.2-13.el5.JP.x86_64.rpm iksemel-devel-1.2-13.el5.JP.x86_64.rpm libssh2-1.2.5-1.el5.JP.x86_64.rpm libssh2-devel-1.2.5-1.el5.JP.x86_64.rpm

RPM作成用のユーザでZabbixのSRPMをインストールしてビルドを実行します。

 $ rpm -ivh zabbix-1.8.3-1.el5.JP.src.rpm
 $ cd ~/rpm/SPECS/
 $ rpmbuild -bb --define 'dist .el5' zabbix.spec


----------
4.Zabbixのインストール

Zabbixをインストールするために必要なパッケージを事前にインストールします。

 # yum install php php-bcmath php-gd php-mbstring php-xml php-common php-pdo

独自に作成したphp-mysqlをインストールします。

 # cd ~RPM作成用ユーザ/rpm/RPMS/x86_64/
 # rpm -ivh php-mysql-5.1.6-27.el5.x86_64.rpm

Zabbixをインストールします。

 # rpm -ivh zabbix-1.8.3-1.el5.x86_64.rpm zabbix-agent-1.8.3-1.el5.x86_64.rpm zabbix-server-1.8.3-1.el5.x86_64.rpm zabbix-server-mysql-1.8.3-1.el5.x86_64.rpm zabbix-web-1.8.3-1.el5.x86_64.rpm zabbix-web-mysql-1.8.3-1.el5.x86_64.rpm

以降、DBの作成などは通常のZabbixのインストールと同様です。

----------