Sigma Hosting
Menu
In this video course we will:
– Buy a domain for $0.88 on Namecheap
– Sign up for Codeanywhere online code editor
– Install Rails on Codeanywhere
– Signup for Heroku and Bitbucket
– Learn how to perform some basic tasks in Codeanywhere such as restarting the container and showing our container info
– Add an SSH key to Bitbucket
– Push Cloudanywhere code and see how to deal with problems when the code on our remote (Bitbucket) conflicts with code on our local environment (Codeanywhere environment)
– Install Heroku toolbelt on Codeanywhere
– Log into Heroku via command line using toolbelt and run the heroku create command
– Bundle install without production
– Deploy our app to a heroku subdomain with a custom index page
– Add a TLD (top-level domain) to our Heroku dashboard
– Update the CNAME record on Namecheap
– Successfuly complete the deployment of our Rails app to a TLD (top-level domain)
Commands to use are available on the actual course page:
https://www.udemy.com/build-an-html5-and-css3-website-in-35-minutes
all right so let’s begin by visiting namecheap.com and I already have an account if you don’t have it you can sign up so you need to click the sign up link and fill out your information once you do you’d be creating a new account so it’s as simple as that since I already have an account I’ll just enter my credentials here and I’ll sign in of course I have an additional layer of security because I’ve enabled two factor authentication so I’ll
just get my coat on my phone all right so six four seven three zero six was the code that I received and let’s submit it it’s time for me to buy a domain and buying the main is simple we’ll just click the main name search here I’ll try to find one of those cheap domains so let’s just choose some simple name like my rails and let’s see my rails us subtotal is 88 cents will click on view cart and now I’ll just confirm the order now I’ll click
select other payment options and I’ll choose secured card payment next I’ll click continue and I’ll click pay now now registered my domain I can click manage to see the dashboard details since I’ve got a lot of the mains I’ll just search and see what I get I’ll click manage here and at this stage even though it’s a bit early I’m just gonna set up my advanced DNS ahead of time so let’s click here and we’re gonna change this section a bit first I
need to change the details here so I’ll type www.ilga.gov coup DNS calm and I’ll keep everything else the same maybe I can switch to automatic here and click the Save Changes and we’re done with namecheap part for the time being next we’re going to register or actually there’s one more thing I’m going to be using the email that I get for this domain and a name cheap you can get free email file for two months so let’s see what we get here to try
out an email package free for two months simply select two months billing cycle from the drop-down so I’m going to click here and click two months free trial and as to cart user domain I own with namecheap and I’m going to paste in the domain that I had I’ll select it click continue and I can choose the address here so just gonna be admin at my rails dot US Add to Cart and confirm the order I’ll click pay now of course I need to approve the terms
so click here and click pay now again and now I can click manage and find my domain again and click manage on the domain itself which brings me back to the screen that I was on and now I can add a mailbox so finally we can click here change password and let’s say that my new password is going to be just some random passwords that I need to make a bit stronger so I just alright so I also have to fill in the name Chee password so I’ll quickly do
that click Save Changes and now I can actually open my webmail and I’ll type my private email password I’m gonna skip the tour and that’s my email right here next I’m going to sign up to code anywhere so let’s click sign up verify that we’re human that should be it and I’ll click register before we start using code anywhere we need to verify our account so I’ll go back here alright so we’ve got a new email from code anywhere team and this is the
verification email so let’s open this link and now our account is verified so we can go to the editor and wait for it to open we will call our new container rails for my rails us and we will choose a blank development stack running Ubuntu 14.04 now our container is being deployed so we’ve got our copy/paste notice which says that we can select text to the mouse and copy to the clipboard you just using ctrl C and ctrl shift V to paste so that’s
good to know we’ll keep this link because we’re going to need information from it and back in here we’re going to have to run a number of commands to setup rails 5.2 on this machine so basically this is a virtual Ubuntu machine it’s a boon to a container running on this online IDE so let’s first look at the commands that we’re gonna have to use all right so here we’ve got commands that we’re gonna use so let’s start by copy pasting the first one
and we’re gonna have to do this several times and this process takes a while so we’re gonna speed things up in some sections of this video basically what we’re doing here is we are setting up all the dependencies and everything that we need to be able to update our rails version two rails 5.2 and to also be able to run it successfully so what we’re gonna do is we’re gonna have a virtual environment called RB and which is going to allow was to
utilize different versions of rails on this machine so now we can check for the Ruby version we’ve got installed on our system and we see it’s two point five point O so we’re going to make it a global environment and next we’re gonna double check that we’re still using this version even though this step is not really necessary but we’re gonna get some more information here so now we’ll install the bundler and finally we’re gonna check the version
of node that we’re running and we’ll make sure to install rails with the newest version which is 5.2 now we can install rails however since I left my clothes anywhere here open for a couple of hours I basically lost access to my SSH so to my sage console so in order to open it I’ll simply right click on the container name and click terminal and this will open a new terminal for me sometimes you can do this also if you need to use two terminals
you simply open another one anyway we need the only one now so I’ll simply check that I’ve got the correct rails worsen and that’s a good response that I was expecting so now I can install rails with rails new and I give it a name of my project and this name will actually be a folder name and that folder is going to be inside my container so I’m gonna right click here and click refresh which will make a simple folder appear here if I open it I
can see all the contents of a rails project so this is a default rails project right here so now I can go CD change directory into the simple folder and finally I can run rails s command which runs the rails server and now I can finally use this tab here that I mentioned the previous video needs to be open so we can have access to this link here so I’m just gonna go right click here open link in new tab and I need to append calling 3000 to the
end because that’s the port that rails my rails app is being served on so I press enter and we’ve got rails running on code anywhere let’s sign up for bid bucket and Heroku so we will visit bid box.org ever gonna get started for free our email address is admin at Mario’s dot us so click continue my full name and over verify that I’m not a robot and finally I’ll click continue all we need to do now is verify the email so I’ll go to Heroku quickly
and sign up for free here I filled out my form with my first name last name email address row country and primary development language finally I’ll verify the capture and create my free account so now I need to verify the email for Heroku as well and I’m going back to my inbox and refresh the page so let’s verify the apply seein account and a test of lesson is the parent company of bitbucket now I can pick my user name and click continue and
while this is being processed I can go back here actually back here and make sure to verify my Heroku accounts as well so now I’ll set my password and login so now I’ve successfully logged into Heroku and bitbucket after not using the IDE of code anywhere for a couple of hours or four day or to the environment shuts down so to restart it you can right click here and click turn on the environment you can also turn it off and one important thing
once this happens when the environment gets turned off you of course lose all the tabs that you had open including the info tab has all the links for work to load the project and so on so you simply right click on your container and click info and that will give you the information of where you can open your app so that’s a quick little note to keep in mind in this video we’ll look at how to create or get the SSH key from code anywhere and
connect it with big buckets so I’m gonna right click here click SSH terminal we need to get one level up so we’ll go CD dot dot and here I’ll type cat dot SSH /id RSA dot pad and that’s the public key that I need to copy so I’ll just copy the whole thing and close it and I’ll go back to bitbucket click on the user icon click bitbucket settings and here I’ll click SSH keys I’ll add my key paste it right here and save a label and click Add key now
that I have my key I’ll go to repositories here and I’ll connect an existing repository with this one here without which we still don’t have so I’ll go here right click as a sage terminal CD into the simple directory but inspect what we’ve got here I was a chalet so we do have the gift folder so I say get status get in it get status get you add that – all let’s clear the console and so it’s better easier to see from the top and I’ll go get commit
– and then you should commit clear and now we’ll be adding our remote so we’ll create our repo repository name is going to be my rails us create repository now we’ll copy the gift ssh URL but we can clone and pressing the copy button and now back in code anywhere I can run get status get walk and now I’ll type git remote add origin and I’ll paste in with shift insert keyboard shortcut the get SSH URL now press Enter of course I need to remove
this beautiful arm section so I’ll just stay with git remote add origin and now I’ll type git push origin master – you this section right here that says permanently added bitbucket to the list of known hosts works because I’ve previously connected everything with SSH keys in this video we’ll install Heroku toolbelt so that we can do a similar kind of integration that we did in the previous videos that is we had integration with bitbucket and now
we’re also going to integrate with Heroku so let’s type wget – – and this is letter O not zero HTTP found slash slash toolbelt dot roku calm slash install – i’m going to dot s h pipe sh and this command will install Heroku for us Heroku toolbelt that is to be specific and what Heroku Tobit allows us to do is we can use Roku’s CLI which basically allows us to work from code anywhere environment and send our updates updates of our code and updates
to our app to Heroku as well what that’s gonna do is publish we will be able to publish a new app on Heroku subdomain and since we already did connection or Namecheap with a top-level domain with Heroku that will actually allow us to publish our site on a top-level domain now that we have Heroku toolbelt installed we will simply type Heroku login and it’ll ask us for our credentials assault-type admin at my rails dot us and I’ll type my password
as well now that we’ve logged in I’m gonna clear the console so it’s easier to read and I’ll type Heroku create now we’ve got a link to our app so let’s just click here and it will open a new window and we’ve got our welcome to our new add message however we still need to deploy our app to Heroku so I’ll try to get push Heroku master and this is basically going to sink our files to the Heroku environment of course here it says that it failed
install gems via bundler because is the test detected sqlite3 gem which is not supported on Heroku so we’re going to have to go in our gem file and make some changes to the way this works so basically we need to comment out the SQLite gem and we also need to add the PG or Postgres gem because that’s what Heroku uses it uses the Postgres database and not the SQLite database now that we’ve commented out our SQLite gem you’ll go right here and add
production group so for production we’re going to be using the post-race gem we’re gonna file save all and we’re gonna open another as a sage terminal and we’re gonna see it into simple and we’re gonna run bundle install there – without production and 77 gems are now installed so we can run save all and now we’ll go you add that – Pau it’s commit – pam commit messages should always be present tense git push origin master we’re and now we can get
push Heroku master and now our app has been deployed to Heroku on this length so let’s click it to open it and it says the page you’re looking for doesn’t exist however this is a great message because as you’ll learn later on this is actually rails own 404 message now we can fix the 404 error that we had on our rails page published by Roku and in order to do that it will be useful to visit this link right here getting started with rails create a
welcome page and as it says right here else five no longer has a static index page in production so there won’t be any root pages in production so we’ll need to create one in order to do that we’ll create a welcome controller so it’s simply copy this command right here go to our code and inside our simple directory run this generated controller welcome next we’ll add an index page in app use welcome index.html RB e RB I will copy this code right
here the reason why we got this error message is because we still need to add another gem to our development and that gem sqlite3 we’re gonna save our file go back here and run that command again which will fix the air now and I just make sure that everything still works so run bundle install so that works as well now we’ll run file save all of course we need to be outside of the terminal in order for the save all command to be available and
finally back in here I’ll run git add there – all git commit dash and update sq white 3 in development get push origin master get push Oroku master we can see that our app successfully deployed so that’s the strategy that we used here by making both our development and production use different gems and also by running bundle install without production with a flag without production we avoided all the issues with the PG gem so we are now sure that
this works and it’s very important and we can go back to following this instruction right here so we’ll copy this and go to app views welcome index.html TRB so app use welcome welcome is empty so we’ll create file index dot HTML dot GRB where er be means embedded Ruby just in case you weren’t familiar with the term so paste that code go file save all back in here we also need to make rails routes for this section so be able to configure outs RB
copy config routes and right here we’ll paste our route go file save all back in here we’ll go get add that – all get commit – and update welcome page git push origin master and get push Hiroki master and now a rat is successfully deployed to Heroku so let’s go back here hit refresh and we’ve got the hello world message with the time stamped so that shows us that our app was successfully deployed and now the last thing to do is make sure that
it’s also deployed on the top-level domain of Mario’s that us in this video will look at adding our top-level domain so I’m basically in my Heroku dashboard clicking on my custom subdomain and I’m adding my top-level domain right here I’ll simply type dub dub dot my rails dot US click Save Changes however it’s asking for my credit card so I’m gonna have to add one you know back to here account settings billing and I’ll add my credit card right
here now that I’ve updated my credit card I can go back to my dashboard right here clicking on these dots and then the dashboard back to shrouded waters and back to settings right here and I’m gonna add my domain and I’m gonna save changes and now my domain top-level domain is set up so finally we can go and make sure that it works I’m getting my name cheap domain page there is one last piece of the puzzle that we need to complete and that is the
name cheap settings of my DNS so I’m going to advanced DNS and here I’m going to update the cname record with the following information dub dub dub dot my race dot u s dot Roku DNS calm we’ll make it as quick as possible and here I just removed this from at and keep Mario’s dot us will save changes on both of those and that’s basically it and in a couple of hours we should have our top level domain serving our rails at finally after a couple of
hours have passed I’ve opened my rails dot us web page and when i refresh it i get the app served on a top-level domain so that’s that set up for you and having a domain set up like this is a great way to actually start working on your project and learning rails as you go