Deploy Laravel To Shared Hosting The Easy Way

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] Navis one on guys in this video I'm going to show you how to deploy a laravel application to a shared web hosting account the absolute easiest way possible all right now I'm not going to say that this is the fastest or the best way but it is definitely the easiest because we're just going to use FTP we're not going to use the shell or anything like that I will probably make a video separately on using those methods because we can use the shell in in many with many shared hosting accounts now it's important to mention with shared hosting you basically have everything set up for you have a cPanel account where you can you know create emails and databases and all that you already have PHP installed Apache MySQL all that stuff now the hosting company that I'm using is in motion hosting which I've used for years I would definitely recommend them to just about anybody there's an affiliate link in the description if you guys do decide to purchase a package please use that link you can see they offer I do have a VPS account they offer dedicated servers but we're going to be dealing with the cheapest the business hosting here which is the cheapest shared hosting account so like $5.99 per month all right now I already have an account set up and this is my cPanel for that account you can see it's using the domain code skelet com so if I go to code skillet com you'll see that it's just an empty directory okay but this is where we want our laravel application to live all right now the application we're going to be deploying is the one we built in the laravel from scratch series on YouTube if you haven't watched that series I highly suggest going back and watching that I think it's 12 videos so we basically just have a website here with some pages but we also have a blogging platform now I've deleted all of the posts and all of the users from the database we just have the table set up but there's full crud functionality for posters authentication system we can register we can log in I'm not going to go through it here because I already know that it works everything works on my local machine we'll go ahead and test it when we upload to our hosts alright now we're going to need to create a database on code skill of comm so this is the cPanel and they make it very very easy if we go under databases you'll see MySQL database wizard so let's click that and by the way if you're not using in motion and you're using something like Hostgator the cPanel interface is pretty much identical to this all right now it's going to prefix our database name with your account name in my case it's going to be code skill underscore and then I'm going to call this database LS app alright and then I'm going to give the user the same name ok so we're going to create a user give them a password it has to be a certain strength or if it won't let you and then let's say create user we're going to select all privileges for this user and now if we go back to my SQL databases you'll see we have the database created as well as the user and they're connected so that's all set now we're going to have to bring in our tables from our local machines so if you've been following along then you should have PHP myadmin setup and you can see in our database which is called LS app we have our tables there's nothing in the users and posts I cleared everything out but we do need to export the whole data structure so what we'll do is make sure you're looking at the correct database and then click export and then go and we're going to download a file called whatever your database is called SQL alright and if you look in the github repository for this application you'll see that I have a folder called underscore SQL and that has this file in it ok if you guys haven't been following along with the whole thing so now that we have that let's go back to our cPanel and we're going to click on PHP myadmin here which will take us to the remote version of our PHP myadmin and we already created the database it's right here code skill LS app click on that and then we're going to import and then click Choose file and we're going to grab C where did I put it I put on my desktop I think I did yeah Ella's a SQL so I'm going to grab that and then click go and that's going to import the database and it shouldn't take long because it's very small all right so that's successful so if we look in our date remote database now you can see we have all of our tables alright so that's all set now what we need to do is bring the files on to our remote servers so for that I'm going to open up FileZilla which is an FTP client just sorry if you don't have it just search for FileZilla client download alright and then we can connect to it using the cPanel details so the host is going to be code skillet comm username is code skillet and then my password click OK and then that's going to bring us into our account now if if for some reason your cPanel login doesn't work here you can actually create more FTP accounts if you go to right here FTP accounts and you can create them here and you'll be able to use those in FileZilla alright so no matter how you're doing this whether you're using FTP or your your cloning to get repository through the three years shell through your terminal you need to basically put your whole application let me just open up the local version of the app which is in my htdocs LS app so we want to put everything here in to not not into the public HTML but into a separate folder that we're going to create so I'm going to call it LS app all right now you want everything here in there but the public folder right here all these these need to go into public HTML ok so what we'll do is first go into LS app and we're going to bring everything here and we don't need the public folder in LS app so except for that we'll bring everything over all right now that's going to take quite a while it could take you know ten to fifteen minutes depending on your connection and that's one thing that really talks about FTP it's slow it's also not encrypted but again it is it is the easiest for beginners and that's what this tutorial is focused on alright so what I'm going to do is just pause this and wait for everything to upload and then I'll be back alright guys so everything is uploaded to LS app now we need the public so we're going to go into public HTML and we're going to go over here and grab everything that's in our public folder and bring that over here and I will be back when that's done alright guys so that's all set now we have all of our public folders now what I'm going to do is go back to the browser here and go back to code skillet comm and reload and you're going to see these errors here so this is happening because we need to tell it to look inside of that LS app folder that we uploaded so we need to actually edit one of these files so in the public HTML folder there is an index.php file so we need to edit that let me just delete these real quick so I'm going to bring the index.php file outside onto my local machine and we're going to just open that up I'll just use sublime text and we need to just change these two lines okay this one and this one and we want to go right before boot the bootstrap and say LS Apps slash same thing right here and let's app slash so it knows to look in there and then we'll save it and let's go ahead and reload it all right now if we go and we check out code skillet comm and reload you'll see that now it works all right now the about page is going to work services is going to work blog however is not because it's actually looking for the database tables but the credentials for the database are not correct they're still set to the local stuff so what we need to do is go back into our FTP and go to our LS app folder and then dot ENB I'm going to bring that out and then we're going to go ahead and edit that and we need to add the correct credentials so you can see I just have a marked is xxx but we're going to change this to code skill underscore LS dot because that's what we call the database we also called the user that same thing and then the password put that in here as well and then we'll save it and then let's reload it all right so now we'll go back and reload and now the post page works and we should be able to register we should be able to upload posts the only thing that's left is the image symlink because right now if we try to upload an image it's going to go to the storage folder but if you remember we actually created the sim link to the public storage folder and we need to recreate that on our host now we could do it through the shell but since this is for you know absolute beginners what I'm going to do is create a new PHP file and we're going to do it through there so let's create a file called we'll just call it sim link create dot PHP alright and then we're going to open that up whoops I want to open that with sublime okay and then we just need to put a line of code in here which is really simple so we just need our PHP tag and we're going to call the sim link function and we want to put in first the directory we want to create the sim link from which is going to be home slash and then whatever you are cPanel account name lines code skillet and then LS app storage slash app slash public okay and that's where the images get uploaded now we want to create a sim link to our public HTML storage folder so that's going to be home code skillett slash public underscore HTML slash storage alright and that's it so let's save it we're going to upload it now to our public HTML folder so we can run it in the browser here alright and then we'll go to our browser and let's go to code skillet comm slash create symlink I think that's what I called it dot PHP no it's not what I called it simply create okay so that ran now if we look in our FTP and we reload the public HTML folder you'll see we have a storage symlink so everything should be all set let's just make sure we delete to the sim link create file alright and now let's go back to code skillet comm and we should be deployed so let's go ahead and register a user register okay so now we're logged in let's go ahead and create a post so we'll say test post one this is a test and let's upload an image so I'll just grab my C I'll grab my desktop background image click Submit and there we go post created you can see the image went through since we're logged in and this is our post we have the edit and delete buttons we can also go to the dashboard and we can edit let's just test it out we'll change it to the number one and submit and you can see that changed and that should be good alright so we now have a deployed laravel application and we didn't even have to touch the terminal or the ssh alright and if you guys want me to do another video showing you a better faster way to do it but more complicated I can do that as well up to set up our SSH keys and so on now the last thing I want to mention to you guys is I just wrapped up a ten project laravel course so there's projects that range in different technologies for instance in one project we use view j s on the front end in another we use postgrads for our database so there's there's mixed in technologies that really give you a good overview of building laravel projects all right now there's an affiliate link in the description I would HIGHLY appreciate if you could use that link and also use the code traversée if you want to get 50% off it's only 49 bucks 50% off you're only going to pay around $25 for a 10 project course so I would definitely suggest that guys and I would appreciate it and that's it thanks for watching and I will see you in the next video
Info
Channel: Traversy Media
Views: 378,208
Rating: undefined out of 5
Keywords: laravel deploy, deploy laravel, laravel hosting, laravel shared hosting, laravel, host laravel, laravel server, laravel ftp, laravel cpanel, inmotion hosting
Id: 6g8G3YQtQt4
Channel Id: undefined
Length: 13min 41sec (821 seconds)
Published: Sun Jun 18 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.