{"id":3039,"date":"2015-01-20T17:15:45","date_gmt":"2015-01-20T15:15:45","guid":{"rendered":"http:\/\/supportex.net\/blog\/?p=3039"},"modified":"2019-05-10T13:24:18","modified_gmt":"2019-05-10T11:24:18","slug":"installing-rabbitmq-ubuntu-server","status":"publish","type":"post","link":"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/","title":{"rendered":"Installing RabbitMQ on Ubuntu server"},"content":{"rendered":"<p><a href=\"https:\/\/www.rabbitmq.com\">RabbitMQ<\/a> is a messaging broker. It means it can \u00a0be used as a transport layer to communicate between some applications by sending and receding messages. Sounds quite simple but actually it&#8217;s not that simple and has a lot of features. For instance, unlike some other message broker it supports\u00a0persistence . \u00a0RabbitMQ is an Erlang application.<\/p>\n<p>1. To install it we need to add the following to the sources configuration to let apt-get know where it should get the server:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">echo \"deb http:\/\/www.rabbitmq.com\/debian\/ testing main\" &gt; \/etc\/apt\/sources.list.d\/rabbitmq.list<\/code><\/p>\n<p>You can also <a href=\"https:\/\/www.rabbitmq.com\/download.html\">download deb package<\/a> the from website but this way seems easier and better.<\/p>\n<p>2. Add a signing key:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">wget http:\/\/www.rabbitmq.com\/rabbitmq-signing-key-public.asc apt-key add rabbitmq-signing-key-public.asc<\/code><\/p>\n<p>3. Update apt cache:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">apt-get update<\/code><\/p>\n<p>4. Install. apt-get will handle all Erlang related dependencies:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">apt-get install rabbitmq-server<\/code><\/p>\n<p>At this point RabbitMQ should be already running. We can check it:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmqctl status<\/code><\/p>\n<p>5. If everything is ok, enable the management plugin:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmq-plugins enable rabbitmq_management<\/code><\/p>\n<p>6. Add admin account:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmqctl add_user admin password<\/code><\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmqctl set_user_tags admin administrator<br \/>\n<\/code><\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmqctl set_permissions -p \/ admin \".*\" \".*\" \".*\"<\/code><\/p>\n<p>Note that for security reasons it would be better not to use &#8216;admin&#8217; as a username, you are free to use any you want.<\/p>\n<p>7. We also don&#8217;t need default pre-created user &#8216;guest&#8217;.<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmqctl delete_user guest<\/code><\/p>\n<p>8. Enable auto-start on boot:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">update-rc.d rabbitmq-server defaults<\/code><\/p>\n<p>At this point you can start using the admin area:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">http:\/\/your_IP_address:15672<\/code><\/p>\n<p>Log in with your admin creantials.<\/p>\n<p>9. Let&#8217;s create user for your application:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmqctl add_vhost \/<br \/>\n<\/code><\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmqctl add_user iamauser mypassword<br \/>\n<\/code><\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmqctl set_permissions -p \/ iamauser \".*\" \".*\" \".*\"<br \/>\n<\/code><\/p>\n<p>You can specify some other virtual host, which is better if you&#8217;d like to have more than one applicatio to use RabbitMQ.<\/p>\n<p>10. To get a list of all users run:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmqctl list_users<\/code><\/p>\n<p>11. To check permissions:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">rabbitmqctl list_user_permissions iamauser<\/code><\/p>\n<p>By default RabbitMQ listens all network interfaces so you might need to restrict ports with the firewall. In general case you would need to restrict ports:<\/p>\n<ul>\n<li>4369 for epmd which is a name server for Erlang applications;<\/li>\n<li>25672 for clustering;<\/li>\n<li>5672 (AMQP), your app will connect to this port;<\/li>\n<li>15672 is open if the management plugin is enabled, web panel.<\/li>\n<\/ul>\n<p>RabbitMQ binding are accessible for the most common languages like Python, Ruby or Go. We will try to test our message \u00a0broker with dummy Python application. We would need <a href=\"https:\/\/github.com\/pika\/pika\">pika<\/a> library installed:<\/p>\n<p><code class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">pip install pika<\/code><\/p>\n<p>This is <em>sender.py<\/em>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">import pika\ncredentials = pika.PlainCredentials('iamauser', 'mypassword')\nparameters = pika.ConnectionParameters(host='myhost', credentials=credentials)\nconnection = pika.BlockingConnection(pika.ConnectionParameters(host='myhost', credentials=credentials))\n\nchannel = connection.channel()\n\nchannel.queue_declare(queue='hello')\n\nchannel.basic_publish(exchange='',\nrouting_key='hello',\nbody='Hello World!')\nprint \" [x] Sent 'Hello World!'\"\nconnection.close()\n\n<\/pre>\n<p>This one is a <em>consumer.py<\/em>. It gets a message:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">#!\/usr\/bin\/env python\nimport pika\n\ncredentials = pika.PlainCredentials('iamauser', 'mypassword')\nparameters = pika.ConnectionParameters(host='myhost', credentials=credentials)\nconnection = pika.BlockingConnection(pika.ConnectionParameters(host='myhost', credentials=credentials))\n\nchannel = connection.channel()\nchannel.queue_declare(queue='hello')\n\nprint ' [*] Waiting for messages. To exit press CTRL+C'\n\ndef callback(ch, method, properties, body):\n    print \" [x] Received %r\" % (body,)\n\nchannel.basic_consume(callback,\n                      queue='hello',\n                      no_ack=True)\n\nchannel.start_consuming()\n<\/pre>\n<p>Let&#8217;s test.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\">[root@runrabbitrun ~]# python sender.py\n[x] Sent 'Hello World!'\n[root@runrabbitrun ~]#\n\n[root@runrabbitrun ~]# python consumer.py\n[*] Waiting for messages. To exit press CTRL+C\n[x] Received 'Hello World!'\n^\\Quit\n[root@runrabbitrun ~]#\n\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>RabbitMQ is a messaging broker. It means it can \u00a0be used as a transport layer to communicate between some applications by sending and receding messages. Sounds quite simple but actually it&#8217;s not that simple and has a lot of features. For instance, unlike some other message broker it supports\u00a0persistence . \u00a0RabbitMQ is an Erlang application.&hellip; <\/p>\n<div class=\"readmore-wrapper\"><a href=\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/\" class=\"more-link\">Read <\/a><\/div>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[152],"tags":[271,273,272,247],"class_list":["post-3039","post","type-post","status-publish","format-standard","hentry","category-linux","tag-amqp","tag-pika","tag-rabbitmq","tag-ubuntu-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Installing RabbitMQ on Ubuntu server &#8211; Supportex.NET blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Installing RabbitMQ on Ubuntu server &#8211; Supportex.NET blog\" \/>\n<meta property=\"og:description\" content=\"RabbitMQ is a messaging broker. It means it can \u00a0be used as a transport layer to communicate between some applications by sending and receding messages. Sounds quite simple but actually it&#8217;s not that simple and has a lot of features. For instance, unlike some other message broker it supports\u00a0persistence . \u00a0RabbitMQ is an Erlang application.&hellip; Read\" \/>\n<meta property=\"og:url\" content=\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Supportex.NET blog\" \/>\n<meta property=\"article:published_time\" content=\"2015-01-20T15:15:45+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-05-10T11:24:18+00:00\" \/>\n<meta name=\"author\" content=\"Oleksii Tykhonov\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Oleksii Tykhonov\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/\"},\"author\":{\"name\":\"Oleksii Tykhonov\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\"},\"headline\":\"Installing RabbitMQ on Ubuntu server\",\"datePublished\":\"2015-01-20T15:15:45+00:00\",\"dateModified\":\"2019-05-10T11:24:18+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/\"},\"wordCount\":337,\"commentCount\":0,\"keywords\":[\"amqp\",\"pika\",\"rabbitmq\",\"Ubuntu\"],\"articleSection\":[\"linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/\",\"url\":\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/\",\"name\":\"Installing RabbitMQ on Ubuntu server &#8211; Supportex.NET blog\",\"isPartOf\":{\"@id\":\"https:\/\/supportex.net\/blog\/en\/#website\"},\"datePublished\":\"2015-01-20T15:15:45+00:00\",\"dateModified\":\"2019-05-10T11:24:18+00:00\",\"author\":{\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\"},\"breadcrumb\":{\"@id\":\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/supportex.net\/blog\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Installing RabbitMQ on Ubuntu server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#website\",\"url\":\"https:\/\/supportex.net\/blog\/en\/\",\"name\":\"Supportex.NET blog\",\"description\":\"Server and network management company\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/supportex.net\/blog\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251\",\"name\":\"Oleksii Tykhonov\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g\",\"caption\":\"Oleksii Tykhonov\"},\"url\":\"https:\/\/supportex.net\/blog\/author\/oleksiitykhonov\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Installing RabbitMQ on Ubuntu server &#8211; Supportex.NET blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/","og_locale":"en_US","og_type":"article","og_title":"Installing RabbitMQ on Ubuntu server &#8211; Supportex.NET blog","og_description":"RabbitMQ is a messaging broker. It means it can \u00a0be used as a transport layer to communicate between some applications by sending and receding messages. Sounds quite simple but actually it&#8217;s not that simple and has a lot of features. For instance, unlike some other message broker it supports\u00a0persistence . \u00a0RabbitMQ is an Erlang application.&hellip; Read","og_url":"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/","og_site_name":"Supportex.NET blog","article_published_time":"2015-01-20T15:15:45+00:00","article_modified_time":"2019-05-10T11:24:18+00:00","author":"Oleksii Tykhonov","twitter_misc":{"Written by":"Oleksii Tykhonov","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/#article","isPartOf":{"@id":"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/"},"author":{"name":"Oleksii Tykhonov","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251"},"headline":"Installing RabbitMQ on Ubuntu server","datePublished":"2015-01-20T15:15:45+00:00","dateModified":"2019-05-10T11:24:18+00:00","mainEntityOfPage":{"@id":"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/"},"wordCount":337,"commentCount":0,"keywords":["amqp","pika","rabbitmq","Ubuntu"],"articleSection":["linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/","url":"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/","name":"Installing RabbitMQ on Ubuntu server &#8211; Supportex.NET blog","isPartOf":{"@id":"https:\/\/supportex.net\/blog\/en\/#website"},"datePublished":"2015-01-20T15:15:45+00:00","dateModified":"2019-05-10T11:24:18+00:00","author":{"@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251"},"breadcrumb":{"@id":"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/supportex.net\/blog\/2015\/01\/installing-rabbitmq-ubuntu-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/supportex.net\/blog\/en\/"},{"@type":"ListItem","position":2,"name":"Installing RabbitMQ on Ubuntu server"}]},{"@type":"WebSite","@id":"https:\/\/supportex.net\/blog\/en\/#website","url":"https:\/\/supportex.net\/blog\/en\/","name":"Supportex.NET blog","description":"Server and network management company","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/supportex.net\/blog\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/0690c26a0266603129fc15eae6243251","name":"Oleksii Tykhonov","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/supportex.net\/blog\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4fd5f58002717075c88963469b9babef?s=96&d=mm&r=g","caption":"Oleksii Tykhonov"},"url":"https:\/\/supportex.net\/blog\/author\/oleksiitykhonov\/"}]}},"_links":{"self":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/3039","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/comments?post=3039"}],"version-history":[{"count":8,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/3039\/revisions"}],"predecessor-version":[{"id":3112,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/posts\/3039\/revisions\/3112"}],"wp:attachment":[{"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/media?parent=3039"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/categories?post=3039"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/supportex.net\/blog\/wp-json\/wp\/v2\/tags?post=3039"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}