در حال بارگذاری ...

Project and Git Setup0:00

In this series, you'll learn how to build and configure a staging server with Laravel, Laravel Forge, and Cloudflare. Now I've quickly generated a new project for Laravel screencasts, and if we run that, it's all you get. We don't care about this. It's just something to represent a site that we need a staging server for. Okay, so if I run git log, you can see I've initialized git and run that first commit. That's the only prep we've done. So we'll call this Laravel screencast demo. Let's create that.

Pushing Repo to GitHub0:29

So we'll call this Laravel screencast demo. Let's create that. And then I already have an existing repo, so I will run this command, or these two commands. There we go. So if I come back and give this a refresh, it's now on GitHub. Great. The next step is to push this regular site live, and then we'll set up a staging server for it. And I like to use Laravel Forge for that. forge.laravel.com.

Provisioning Forge Server0:51

And I like to use Laravel Forge for that. forge.laravel.com. Now I already have an account, but you can start a free trial if you want. Now I can either add this to my existing server, or we can set up one from scratch. Why don't we do that, just to be safe. Okay, so I have the server credentials. I will also receive an email, but of course, these are going to be blurred out. So if I switch back to my dashboard, you can see right now that server is still building. And this will probably take a few minutes, so let's go ahead and fast forward. Okay, so after five minutes or so, we have our new server.

Adding Site and Domain1:22

And this will probably take a few minutes, so let's go ahead and fast forward. Okay, so after five minutes or so, we have our new server. And now you'll see we have our default site, but you know what? Let's go ahead and remove it, and then add my official one. So I called this laravelscreencast because, as it turns out, I own that domain. And it actually redirects to Laracast, but for the purposes of this series alone, we'll separate it. Okay, so it's called laravelscreencast.com. Again, I own this domain, and it is a Laravel project. Okay, so let's add the site, and then we will pull it in through Git.

Again, I own this domain, and it is a Laravel project. Okay, so let's add the site, and then we will pull it in through Git. Okay, Git repository, and it is laracasts/laravelscreencast-demo. Again, I'm just grabbing that from right here. So clone that, and then install any Composer dependencies. Next, you can see the default deploy script here. We cd to the root of the project. We pull in the latest changes. We run a composer install. We reload PHP to reflect any cache changes, and then we'll run a migrate.

Configuring Deploy and SSH2:20

We run a composer install. We reload PHP to reflect any cache changes, and then we'll run a php artisan migrate. So I will enable quick deploy, which means every time I push to Git, we will automatically trigger the script. Okay, next, I'll go back to my main server section, and let's set up the SSH key. I'll just call it what I'm on right now, my iMac, and I do need a public key. Now I'll show you how to generate one from scratch. You can do ssh-keygen, and we need the name of the file. You can stick with a default. If you don't have one, but in this case, I'll call it demo, and passphrase, and there

Here's the IP address. So we'll say SSH. The user is forge at this IP address, and our permission is within that SSH directory, and again, we called it demo RSA, and we're in, great. So you'll see there's our Laravel screencast directory, and all of our files. If I run a git log, there's the commit we made. Okay, finally, let's connect to our database. I'll do this through SQL Pro. We're going to connect through SSH. We'll call it Laravel screencasts.

So I can find that in my home directory. It's SSH and demo. Okay, let's test the connection, and it seems to be successful. So I will add it to my favorites and connect. All right, so we have that forge directory. You'll see it hasn't yet been migrated. Now we can either do that by triggering a deploy, or of course, you can just manually run php artisan migrate from the server. So let's call deploy now. There's not going to be any new code, but it will trigger the deploy script, which we'll

So let's call deploy now. There's not going to be any new code, but it will trigger the deploy script, which we'll call php artisan migrate. All right, so now if we give this a refresh, there you go. You have those default tables. So now that I've created a server through DigitalOcean, and of course, by the way, you would need to register on that end, and then hook up your API key to forge. But this isn't really a forge series, so I will leave that part to you. But anyways, we then created a new site in that server. The only remaining step is I want to get it on the page.

Updating DNS A Records4:59

But anyways, we then created a new site in that server. The only remaining step is I want to get it on the page. So if I try to run this, you'll see at the moment, Hover lets us know I've purchased it, but we haven't connected it. That's the next step. I'll go to hover.com, go to my account and domains. I will configure Laravel Screencasts, visit my DNS, and we'll get rid of these A records here and create a new one. So as you see here, an A record will point your domain to a given IP address. And once it hits your server, it will figure out, okay, you want to load the Laravel Screencasts.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟