{"_id":"55985a44ec869d0d0008c1a0","user":"555f9a010758330d000d531a","version":{"_id":"555f9bf814d68e0d0096658a","project":"555f9bf814d68e0d00966587","__v":9,"createdAt":"2015-05-22T21:13:28.470Z","releaseDate":"2015-05-22T21:13:28.470Z","categories":["555f9bf814d68e0d0096658b","555f9e9ed7777119003acfee","555fa040d7777119003acffd","555fa344d7777119003ad00b","555fa3e6d7777119003ad00f","555fb694336c041700a9b86e","555fb779336c041700a9b86f","555fb86bd7777119003ad039","555fbf1a336c041700a9b87f"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"__v":15,"category":{"_id":"555f9bf814d68e0d0096658b","pages":["555f9bf914d68e0d0096658d","55985a44ec869d0d0008c1a0"],"project":"555f9bf814d68e0d00966587","version":"555f9bf814d68e0d0096658a","__v":2,"sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-05-22T21:13:28.983Z","from_sync":false,"order":0,"slug":"documentation","title":"Documentation"},"parentDoc":null,"project":"555f9bf814d68e0d00966587","updates":["568db9a06b3c3c0d00838c22","568dd82970ca1f0d00357fc7","568ddb21d74a0d0d00905e5d","56f7a3c06267401700faf659","5903d344a807d22700b60aba","59552f913e9508001b480971"],"next":{"pages":[],"description":""},"createdAt":"2015-07-04T22:12:20.584Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"Pushjet currently has no automated installation process. This might change in the future though. The Pushjet server is split into multiple components; [api](https://github.com/Pushjet/Pushjet-Server-Api), [broker](https://github.com/Pushjet/Pushjet-Server-Broker) and [connectors](https://github.com/Pushjet/Pushjet-Connectors).\n\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Setting up the API\"\n}\n[/block]\nThis will go through how to set up Pushjet using gunicorn + nginx. \n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"# Assuming mysql and nginx are already installed\\n\\n# First a folder that will contain the application needs to be \\n# created. Personally I prefer `/srv/http/api.pushjet.io` but \\n# this is up to personal preference. \\nmkdir -pv /srv/http\\nchown www-data:www-data /srv/http\\nchmod g+s /srv/http\\n\\n# Clone the api source into this directory. \\ngit clone https://github.com/Pushjet/Pushjet-Server-Api/ /srv/http/api.pushjet.io\\ncd /srv/http/api.pushjet.io\\nchown www-data:www-data . -R\\nchmod g+s . -R\\n\\n# Create the database\\necho 'CREATE DATABASE pushjet_api;'\\ncat database.sql | mysql -uroot -p{insert root password} -D pushjet_api\\n\\n# Edit the config\\ncp config{.example,}.py\\nnano config.py\\n\\n# Install gunicorn\\napt-get install gunicorn\\n\\n# Copy the basic configuration to /etc/gunicorn.d/pushjet-api\\n# See the basic gunicorn configuration on this page\\ntouch /etc/gunicorn.d/pushjet-api\\nnano /etc/gunicorn.d/pushjet-api\\n\\n# Copy the basic nginx configuration\\n# See the basic nginx configuration on this page\\ntouch /etc/nginx/sites-available/pushjet-api\\nnano  /etc/nginx/sites-available/pushjet-api\\nln -s /etc/nginx/sites-{available,enabled}/pushjet-api\\n\\n# Start the api\\nservice gunicorn restart\\nservice nginx reload\",\n      \"language\": \"shell\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Basic Gunicorn configuration\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"CONFIG = {\\n    'mode': 'wsgi',\\n    'working_dir': '/srv/http/api.pushjet.io/',\\n    'python': '/usr/bin/python2',\\n    'args': (\\n        '--bind=unix:/var/run/gunicorn/pushjet-api.sock',\\n        '--workers=2',\\n        '--timeout=30',\\n        'wsgi',\\n    ),\\n}\\n\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Basic Nginx configuration\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"server {\\n        listen 80;\\n        server_name api.pushjet.io;\\n        access_log /var/log/nginx/pushjet-api.access.log;\\n        error_log  /var/log/nginx/pushjet-api.error.log;\\n\\n        location / {\\n                proxy_pass http://unix:/var/run/gunicorn/pushjet-api.sock;\\n                proxy_set_header Host $host;\\n                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\\n        }\\n\\n        # Websocket passthru\\n        # location /ws {\\n        #         proxy_pass http://127.0.0.1:8181;\\n        #         proxy_http_version 1.1;\\n        #         proxy_buffering off;\\n        # \\n        #         proxy_set_header Upgrade $http_upgrade;\\n        #         proxy_set_header Connection 'upgrade';\\n        # }\\n}\",\n      \"language\": \"text\"\n    }\n  ]\n}\n[/block]","excerpt":"","slug":"hosting-pushjet","type":"basic","title":"Hosting Pushjet with Nginx"}

Hosting Pushjet with Nginx


Pushjet currently has no automated installation process. This might change in the future though. The Pushjet server is split into multiple components; [api](https://github.com/Pushjet/Pushjet-Server-Api), [broker](https://github.com/Pushjet/Pushjet-Server-Broker) and [connectors](https://github.com/Pushjet/Pushjet-Connectors). [block:api-header] { "type": "basic", "title": "Setting up the API" } [/block] This will go through how to set up Pushjet using gunicorn + nginx. [block:code] { "codes": [ { "code": "# Assuming mysql and nginx are already installed\n\n# First a folder that will contain the application needs to be \n# created. Personally I prefer `/srv/http/api.pushjet.io` but \n# this is up to personal preference. \nmkdir -pv /srv/http\nchown www-data:www-data /srv/http\nchmod g+s /srv/http\n\n# Clone the api source into this directory. \ngit clone https://github.com/Pushjet/Pushjet-Server-Api/ /srv/http/api.pushjet.io\ncd /srv/http/api.pushjet.io\nchown www-data:www-data . -R\nchmod g+s . -R\n\n# Create the database\necho 'CREATE DATABASE pushjet_api;'\ncat database.sql | mysql -uroot -p{insert root password} -D pushjet_api\n\n# Edit the config\ncp config{.example,}.py\nnano config.py\n\n# Install gunicorn\napt-get install gunicorn\n\n# Copy the basic configuration to /etc/gunicorn.d/pushjet-api\n# See the basic gunicorn configuration on this page\ntouch /etc/gunicorn.d/pushjet-api\nnano /etc/gunicorn.d/pushjet-api\n\n# Copy the basic nginx configuration\n# See the basic nginx configuration on this page\ntouch /etc/nginx/sites-available/pushjet-api\nnano /etc/nginx/sites-available/pushjet-api\nln -s /etc/nginx/sites-{available,enabled}/pushjet-api\n\n# Start the api\nservice gunicorn restart\nservice nginx reload", "language": "shell" } ] } [/block] [block:api-header] { "type": "basic", "title": "Basic Gunicorn configuration" } [/block] [block:code] { "codes": [ { "code": "CONFIG = {\n 'mode': 'wsgi',\n 'working_dir': '/srv/http/api.pushjet.io/',\n 'python': '/usr/bin/python2',\n 'args': (\n '--bind=unix:/var/run/gunicorn/pushjet-api.sock',\n '--workers=2',\n '--timeout=30',\n 'wsgi',\n ),\n}\n", "language": "text" } ] } [/block] [block:api-header] { "type": "basic", "title": "Basic Nginx configuration" } [/block] [block:code] { "codes": [ { "code": "server {\n listen 80;\n server_name api.pushjet.io;\n access_log /var/log/nginx/pushjet-api.access.log;\n error_log /var/log/nginx/pushjet-api.error.log;\n\n location / {\n proxy_pass http://unix:/var/run/gunicorn/pushjet-api.sock;\n proxy_set_header Host $host;\n proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n }\n\n # Websocket passthru\n # location /ws {\n # proxy_pass http://127.0.0.1:8181;\n # proxy_http_version 1.1;\n # proxy_buffering off;\n # \n # proxy_set_header Upgrade $http_upgrade;\n # proxy_set_header Connection 'upgrade';\n # }\n}", "language": "text" } ] } [/block]