Prepare MySQL-Database for pushjet
# mysql -u root -p CREATE USER 'pushjet'@'localhost' IDENTIFIED WITH mysql_native_password AS '***'; GRANT USAGE ON *.* TO 'pushjet'@'localhost' REQUIRE NONE WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0; CREATE DATABASE IF NOT EXISTS `pushjet`; GRANT ALL PRIVILEGES ON `pushjet`.* TO 'pushjet'@'localhost'
Install gunicorn and pushjet via Shell
sudo su apt-get install gunicorn python-pip libmysqlclient-dev cd /opt wget https://github.com/Pushjet/Pushjet-Server-Api/archive/master.zip unzip master.zip rm master.zip mv Pushjet-Server-Api-master/ pushjet cd pushjet pip install -r requirements.txt cp config{.example,}.py cat database.sql | mysql -uroot -p{insert root password} -D pushjet
Create gunicorn config for pushjet /etc/gunicorn.d/pushjet
CONFIG = { 'mode': 'wsgi', 'working_dir': '/opt/pushjet/', 'python': '/usr/bin/python2', 'args': ( '--bind=0.0.0.0:8080', '--workers=2', '--timeout=30', 'application:app', ), }
Modify pushjet config /opt/pushjet/config.py
# Must be a mysql database! database_uri = 'mysql://pushjet:password@localhost/pushjet' # Google Cloud Messaging configuration (required for android!) google_api_key = 'ABCDEF....XYZ' # Change this to your FCM server key google_gcm_sender_id = 512345678900 # Change this to your GCM sender id
How to create the required key and id is documented here.
Create apache site config
/etc/apache2/sites-available/pushjet.conf
<VirtualHost *:443> SSLEngine On SSLCertificateFile /path/to/fullchain.pem SSLCertificateKeyFile /path/to/privkey.pem ServerAdmin root@my-push-domain.org ServerName my-push-domain.org ServerAlias my-push-domain.org RequestHeader set Front-End-Https "On" Header edit Location "^http:(.*)$" "https:$1" ProxyPass / unix:/var/run/gunicorn/pushjet.sock|http://localhost/ RedirectMatch ^/$ http://my-push-domain.org/ </VirtualHost>
Alternatively you can also publish pushjet as sub directory
<Location /pushjet> ProxyPass unix:/var/run/gunicorn/pushjet.sock|http://localhost/ </Location>
Enable the apache site and restart gunicorn and apache
sudo a2ensite pushjet.conf systemctl restart gunicorn systemctl restart apache2.service
Test it
To test it just go to https://my-push-domain.org/gcm
The result should look like this:
{ "sender_id": 512345678900 }
Configure Pushjet Client
Open the pushjet settings:
Server URL: http://my-push-domain.org/
Custom Sender ID: 512345678900