{"id":358,"date":"2017-01-07T20:05:32","date_gmt":"2017-01-07T19:05:32","guid":{"rendered":"https:\/\/ms07.de\/blog\/?p=358"},"modified":"2018-02-09T21:53:56","modified_gmt":"2018-02-09T20:53:56","slug":"hosting-pushjet-with-apache","status":"publish","type":"post","link":"https:\/\/ms07.de\/blog\/?p=358","title":{"rendered":"Hosting Pushjet with Apache"},"content":{"rendered":"<h1>Prepare MySQL-Database for pushjet<\/h1>\n<pre class=\"brush: sql; title: ; notranslate\" title=\"\"># mysql -u root -p\r\nCREATE USER 'pushjet'@'localhost' IDENTIFIED WITH mysql_native_password AS '***';\r\nGRANT 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;\r\nCREATE DATABASE IF NOT EXISTS `pushjet`;\r\nGRANT ALL PRIVILEGES ON `pushjet`.* TO 'pushjet'@'localhost'<\/pre>\n<h1>Install gunicorn and pushjet via Shell<\/h1>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo su\r\napt-get install gunicorn python-pip libmysqlclient-dev\r\ncd \/opt\r\nwget https:\/\/github.com\/Pushjet\/Pushjet-Server-Api\/archive\/master.zip\r\nunzip master.zip\r\nrm master.zip\r\nmv Pushjet-Server-Api-master\/ pushjet\r\ncd pushjet\r\npip install -r requirements.txt\r\ncp config{.example,}.py\r\ncat database.sql | mysql -uroot -p{insert root password} -D pushjet<\/pre>\n<h1 class=\"cm-s-neo\" data-mode=\"shell\">Create gunicorn config for pushjet \/etc\/gunicorn.d\/pushjet<\/h1>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">CONFIG = {\r\n  'mode': 'wsgi',\r\n  'working_dir': '\/opt\/pushjet\/',\r\n  'python': '\/usr\/bin\/python2',\r\n  'args': (\r\n    '--bind=0.0.0.0:8080',\r\n    '--workers=2',\r\n    '--timeout=30',\r\n    'application:app',\r\n  ),\r\n}<\/pre>\n<h1 class=\"cm-s-neo\" data-mode=\"shell\">Modify pushjet config \/opt\/pushjet\/config.py<\/h1>\n<pre class=\"brush: plain; auto-links: false; title: ; notranslate\" title=\"\"># Must be a mysql database!\r\ndatabase_uri = 'mysql:\/\/pushjet:password@localhost\/pushjet'\r\n# Google Cloud Messaging configuration (required for android!)\r\ngoogle_api_key = 'ABCDEF....XYZ' \r\n# Change this to your FCM server key\r\ngoogle_gcm_sender_id = 512345678900 \r\n# Change this to your GCM sender id<\/pre>\n<p>How to create the required key and id is documented <a href=\"http:\/\/dev.tapjoy.com\/faq\/how-to-find-sender-id-and-api-key-for-gcm\/\">here<\/a>.<\/p>\n<h1>Create apache site config<br \/>\n\/etc\/apache2\/sites-available\/pushjet.conf<\/h1>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;VirtualHost *:443&gt;\r\n    SSLEngine On\r\n    SSLCertificateFile \/path\/to\/fullchain.pem\r\n    SSLCertificateKeyFile \/path\/to\/privkey.pem\r\n    ServerAdmin root@my-push-domain.org\r\n    ServerName my-push-domain.org\r\n    ServerAlias my-push-domain.org\r\n    RequestHeader set Front-End-Https &quot;On&quot;\r\n    Header edit Location &quot;^http:(.*)$&quot; &quot;https:$1&quot;\r\n    ProxyPass \/ unix:\/var\/run\/gunicorn\/pushjet.sock|http:\/\/localhost\/\r\n    RedirectMatch ^\/$ http:\/\/my-push-domain.org\/\r\n&lt;\/VirtualHost&gt;<\/pre>\n<p><span lang=\"en\">Alternatively you can also<\/span> publish pushjet as sub directory<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">&lt;Location \/pushjet&gt; \r\n    ProxyPass unix:\/var\/run\/gunicorn\/pushjet.sock|http:\/\/localhost\/\r\n&lt;\/Location&gt;<\/pre>\n<h1>Enable the apache site and restart gunicorn and apache<\/h1>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo a2ensite pushjet.conf\r\nsystemctl restart gunicorn\r\nsystemctl restart apache2.service<\/pre>\n<h1>Test it<\/h1>\n<p>To test it just go to https:\/\/my-push-domain.org\/gcm<br \/>\nThe result should look like this:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">{\r\n  &quot;sender_id&quot;: 512345678900\r\n}<\/pre>\n<h1>Configure Pushjet Client<\/h1>\n<p>Open the pushjet settings:<br \/>\nServer URL: http:\/\/my-push-domain.org\/<br \/>\nCustom Sender ID: 512345678900<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Prepare MySQL-Database for pushjet # mysql -u root -p CREATE USER &#8218;pushjet&#8217;@&#8217;localhost&#8216; IDENTIFIED WITH mysql_native_password AS &#8218;***&#8216;; GRANT USAGE ON *.* TO &#8218;pushjet&#8217;@&#8217;localhost&#8216; 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 &#8218;pushjet&#8217;@&#8217;localhost&#8216; Install gunicorn and pushjet via Shell sudo su [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[],"class_list":["post-358","post","type-post","status-publish","format-standard","hentry","category-it","category-linux"],"_links":{"self":[{"href":"https:\/\/ms07.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/358","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ms07.de\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ms07.de\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ms07.de\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ms07.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=358"}],"version-history":[{"count":24,"href":"https:\/\/ms07.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/358\/revisions"}],"predecessor-version":[{"id":388,"href":"https:\/\/ms07.de\/blog\/index.php?rest_route=\/wp\/v2\/posts\/358\/revisions\/388"}],"wp:attachment":[{"href":"https:\/\/ms07.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=358"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ms07.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=358"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ms07.de\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=358"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}