Home >PHP Framework >Laravel >what is laravel forge

what is laravel forge

青灯夜游
青灯夜游Original
2022-06-27 19:37:363583browse

laravel forge is a tool that makes PHP deployment a breeze, it allows users to use Git and some popular server providers to launch cloud servers and handle the deployment process. Laravel Forge has a lot of features and an easy-to-use UI that allows users to easily create and configure servers and deploy applications; after configuring the service provider, there is a high possibility that users can manage the server again without accessing the AWS console.

what is laravel forge

The operating environment of this tutorial: Windows 7 system, Laravel 9 version, DELL G3 computer.

What is laravel forge

Laravel Forge is a tool that makes PHP deployment a breeze. It has tons of features and an easy-to-use UI that allows you to easily create and configure servers and deploy applications. After configuring the service provider, there is a good chance that you will be able to manage the server again without accessing the AWS console.

Laravel Forge allows you to use Git and some popular server providers to launch cloud servers and handle the deployment process. The process is explained below:

First, you need to connect AWS or any other cloud provider to your Forge account. Next, link your source control (such as GitHub) to Forge. You can now create the server. Install the source control repository on the server. Finally, press the deploy button. Easy enough?

Server configured with Laravel Forge comes with the following stack:

  • Ubuntu 16.06

  • Nginx

  • PHP 7.2/7.1/7.0/5.6

  • MySQL/MariaDB/Postgres

  • Redis

  • Memcached

After creating the server, you can configure it further.

When you sign up, you can choose from the different plans they offer. I chose the $12/month Basic plan; however, you get a free trial with access to everything on the list for five days.

After logging in, you will see the following content.

what is laravel forge

You can choose Digital Ocean, AWS, Linode and Vultr for service providers. Alternatively, you can use Forge and a custom VPC. As for source code control, Forge supports GitHub, GitLab, and Bitbucket. In this tutorial, I will discuss the basics of configuring AWS to use Forge and GitHub for source code management. Once completed, you will be able to create and configure any number of servers.

If you are using another service provider on the list, you can skip this step and contact us later after we configure AWS and Laravel Forge.

Setting up Laravel Forge and AWS

To set up Forge and AWS, you need to perform the following steps.

1. Log in to Laravel Forge

Log in to Laravel Forge and select AWS as the service provider. You will be asked to enter the Key ID (Key) and Key Access Key (Key). You need to create a specific IAM user with a policy that provides sufficient access to Laravel Forge. IAM is Amazon's way of mapping permissions for each user, so if any issues arise, you can revoke access.

2. Create a new IAM user

Log in to the AWS Console and create a new IAM user.

what is laravel forge

# Give the user a meaningful name and check the Programmatic Access box.

3. Select the correct policy

Set the correct permissions for the laravel-forge IAM user. Create a new user group as user groups are ideal for managing permissions. Now the natural question is, "What policies should the fake user have access to?" While you could use AdministratorAccess to provide it, you shouldn't.

what is laravel forge

If you need Forge to create and configure servers on your behalf, you need to add two policies:

  • AmazonEC2FullAccess

  • AmazonVPCFulAccess

4. Save the credentials and confirm

Confirm the IAM account, on the next page you will Find the access key and password.

what is laravel forge

Go to the Laravel Forge page and paste it there. That’s all.

5. Link your GitHub account to Forge

If you haven’t done so already, connect your GitHub/Bitbucket account to Forge. Forge will add the public key to your account when you create the server. If you need to add new service providers and/or update source control, you can add these options in your profile.

Deploy now and deploy quickly

To deploy, you can deploy manually using the "Deploy Now" button. Alternatively, you can enable the Quick Deployment option, which automatically deploys your project when you push your code to the master branch of your chosen GitHub repository.

Deployment script

The default deployment script pulls the code from the repository, installs dependencies, starts the server, and deploys the application every time when running the migration. This is the actual deployment script.

cd /home/forge/redmonark.com
git pull origin laravelapi
composer install --no-interaction --prefer-dist --optimize-autoloader
echo "" | sudo -S service php7.2-fpm reload
 
if [ -f artisan ]
then
    php artisan migrate --force
fi

If you need to tweak it and add extra stuff, you can.

[Related recommendations: laravel video tutorial]

The above is the detailed content of what is laravel forge. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn