{"id":5312,"date":"2020-01-09T13:01:14","date_gmt":"2020-01-09T07:31:14","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=5312"},"modified":"2020-01-09T13:01:21","modified_gmt":"2020-01-09T07:31:21","slug":"keystone-js-deployment-on-ubuntu-16-04-18-04","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/keystone-js-deployment-on-ubuntu-16-04-18-04\/","title":{"rendered":"Keystone js deployment on Ubuntu 16.04\/18.04"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Keystone js deployment on Ubuntu 16.04\/18.04<\/h4>\n\n\n\n<h4 class=\"wp-block-heading\">Date : 07-Jan-2020<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Let us see how to deploy Keystone js on Ubuntu 16.04\/18.04<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 1: Install Nginx webserver<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Install nginx webserver in your Ubuntu machine using the following command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> <code>apt-get install nginx <\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Post installation, you can check the status of the webserver using the command,  <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>systemctl status nginx<\/code> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> To confirm that the software is running properly through your IP address, give the following url. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>http:\/\/server_ip_address<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It will access the default nginx landing page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Setup your domain<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Create a directory for your domain name in \/var\/www\/<br>Ex. \/var\/www\/domainname.com\/html<\/li><li>Assign the ownership of the directory.<br> chown -R $USER:$USER \/var\/www\/domainname.com\/html <\/li><li>Make sure the permission of the directory created is 755.<br> chmod -R 755 \/var\/www\/domainname.com<\/li><li>Create a sample html page(index.html) in  \/var\/www\/domainname.com\/html<\/li><\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Configure your domain<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Create a domainname.conf file in  \/etc\/nginx\/sites-available<\/li><li>In  \/etc\/nginx\/sites-available\/domainname.conf, paste the following contents.<br><code> server {<br>              listen 80;<br>              listen [::]:80;<br>              root \/var\/www\/example.com\/html;<br>              index index.html index.htm index.nginx-debian.html;<br>              server_name example.com www.example.com;<br>              location \/ {<br>                                try_files $uri $uri\/ =404;<br>              }<br>}<\/code><\/li><li>Enable the file by creating a link from it to the sites-enabled directory.<br> ln -s \/etc\/nginx\/sites-available\/domainname.com \/etc\/nginx\/sites-enabled\/ <\/li><li>Test the syntax by giving the command,  <code>nginx -t<\/code> <\/li><li>Restart nginx to enable the changes.<br> <code> systemctl restart nginx <\/code><\/li><li>Now nginx should serve your domain name. Test it out by giving the url as <code>http:\/\/domainname<\/code>. <\/li><li>The site should load with the sample html page created.<\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Step 2: Install Ruby<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Install curl and git packages.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt update<br>apt install curl git<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> Then run the commands below to add Node.js and Yarn repositories and keys to your system. Then install some core packages to get your environment going. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -sL https:\/\/deb.nodesource.com\/setup_8.x | sudo -E bash -\ncurl -sS https:\/\/dl.yarnpkg.com\/debian\/pubkey.gpg | sudo apt-key add -\necho \"deb https:\/\/dl.yarnpkg.com\/debian\/ stable main\" | sudo tee \/etc\/apt\/sources.list.d\/yarn.list\n\napt-get update\napt-get install nodejs yarn zlib1g-dev build-essential libpq-dev libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common libffi-dev<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After adding the repositories and installing necessary&nbsp;packages above, install Ruby with your local profile settings using&nbsp;<strong>rbenv\u2026&nbsp;<\/strong>you\u2019ll then use rbenv to install ruby-build\u2026 <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">cd ~\/\ngit clone https:\/\/github.com\/rbenv\/rbenv.git ~\/.rbenv\necho 'export PATH=\"$HOME\/.rbenv\/bin:$PATH\"' &gt;&gt; ~\/.bashrc\necho 'eval \"$(rbenv init -)\"' &gt;&gt; ~\/.bashrc\nexec $SHELL\n\ngit clone https:\/\/github.com\/rbenv\/ruby-build.git ~\/.rbenv\/plugins\/ruby-build\necho 'export PATH=\"$HOME\/.rbenv\/plugins\/ruby-build\/bin:$PATH\"' &gt;&gt; ~\/.bashrc\nexec $SHELL<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> After setting up your local profile\u2026 run the commands below to install Ruby version&nbsp;<strong>2.5.3<\/strong>\u2026 If a newer version is available, replace the version number to that.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note: You can check the latest version of Ruby in the following link.<br> <a href=\"https:\/\/www.ruby-lang.org\/en\/downloads\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.ruby-lang.org\/en\/downloads\/<\/a> <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">rbenv install 2.5.3\nrbenv global 2.5.3<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"> To verify that Ruby is installed, run the commands below: <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> ruby -v <\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It will display the ruby version installed.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 3: Install Nodejs-8<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Install Node.js using the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">curl -sL https:\/\/deb.nodesource.com\/setup_8.x | sudo -E bash -<br>apt-get install -y nodejs<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Step 4: Install MongoDB<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Install MongoDB using the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">apt install mongodb\nnpm install mongodb --save<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Once MongoDB server is installed, open a new terminal and start an interactive mongo prompt by typing the following command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code> mongo<\/code> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Press ctrl+c to exit.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Step 5: Install dotenv, pm2<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">npm install dotenv<br>npm install pm2@latest -g<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Step 6:  Install KeystoneJS (along with Yoeman)<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">npm install imagemagick\nnpm install -g generator-keystone\nnpm install -g yo<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To start the server, run the below command<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> node keystone <\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Step 7: Run the service using pm2<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">You can run the service using pm2 command.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Go to the directory where you have installed the app. Then run the following command.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"> pm2 start keystone.js <\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">You can watch logs using the command,  <strong>\u201cpm2 logs\u201d <\/strong>\nYou can see the app status using the command, <strong>\u201cpm2 status\u201d<\/strong><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Thats it!! Your project is successfully running as you can see the logs response without any errors. The app port is 3000. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> Now open your browser and browse to the hostname follow by port&nbsp;<strong># 3000<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong> http:\/\/localhost:3000 <\/strong> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you !!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Keystone js deployment on Ubuntu 16.04\/18.04 Date : 07-Jan-2020 Let us see how to deploy Keystone js on Ubuntu 16.04\/18.04 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[741,740,522],"class_list":["post-5312","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-deployment","tag-keystone-js","tag-ubuntu-18-0-4","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1nG","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5312","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=5312"}],"version-history":[{"count":0,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/5312\/revisions"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=5312"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=5312"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=5312"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}