LoginSignup
0
0

More than 3 years have passed since last update.

CentOS6 (PHP5.3.3)環境でmosquittoとmosquitto-phpを動かす

Last updated at Posted at 2020-05-20

いまさらとは思うですが、必要になったので・・・。

CentOS6の標準のリポジトリにはmosquittoなどは入っていないので、別のリポジトリを使えるようにします。

sudo rpm --import http://wiki.psychotic.ninja/RPM-GPG-KEY-psychotic
sudo rpm -ivh http://packages.psychotic.ninja/6/base/x86_64/RPMS/psychotic-release-1.0.0-1.el6.psychotic.noarch.rpm

mosquittoと、mosquitto-develをインストールします。

sudo yum --enablerepo psychotic install mosquitto mosquitto-devel

次に、mosquitto-phpをインストールしますが、PHP5.3.3環境だとスムーズに行かないので、ソースからビルドします。(PHPのバージョンを上げようというツッコミはさておき)

wget https://github.com/mgdm/Mosquitto-PHP/archive/master.zip
mv master.zip Mosquitto-PHP.zip
unzip Mosquitto-PHP.zip 
cd Mosquitto-PHP-master/

PHP5.3.3環境ではソースを少しだけイジります。mosquitto.cとmosquitto_message.cの2つのファイルの先頭に、下記のコードを追記します。

#ifndef PHP_FE_END
#define PHP_FE_END {NULL, NULL, NULL}
#endif PHP_FE_END

あとは下記のとおりビルドして、インストール。

sudo yum install php-devel
phpize
./configure --with-mosquitto=/usr/lib64/libmosquitto.so
make
sudo make install

これで、/usr/lib64/php/modules/にmosquitto.soがインストールされるので、/etc/php.iniの適当な場所に下記を追記します。

extension=mosquitto.so

最後に、Apacheを再起動しましょう。

参考

こちらの記事を参考にしました。
https://yoya.hatenadiary.jp/entry/20130501/php

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0