Mqtt Server install and Mqtt PHP extension install

install mosquitto at ubuntu

sudo apt-get install software-properties-common python-software-properties // 有些环境没有安装 repository
sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
apt-get install mosquitto
apt-get install mosquitto-clients

test it

mosquitto_sub -v -t test
mosquitto_pub -t test -m 12

注意, 需要在两个不同的 shell 下测试

install php extension

sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
apt-get update
apt-get install libmosquitto-dev
apt-get install re2c

cd /usr/local/src/
git clone https://github.com/mgdm/Mosquitto-PHP
cd Mosquitto-PHP
phpize
./configure
make
make install

### php5-fpm 版本
touch /etc/php5/mods-available/mosquitto.ini
ln -s /etc/php5/mods-available/mosquitto.ini /etc/php5/fpm/conf.d/20-mosquitto.ini
ln -s /etc/php5/mods-available/mosquitto.ini /etc/php5/cli/conf.d/20-mosquitto.ini

### apache 版本
echo extension=mosquitto.so >> /etc/php5/conf.d/mosquitto.ini
添加新评论