-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New translations deployment.md (Spanish)
- Loading branch information
1 parent
8ce08f9
commit 5027165
Showing
1 changed file
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
# Deployment | ||
|
||
- [Introduction](#introduction) | ||
- [Server Configuration](#server-configuration) | ||
- [Nginx](#nginx) | ||
- [Optimization](#optimization) | ||
- [Autoloader Optimization](#autoloader-optimization) | ||
- [Optimizing Configuration Loading](#optimizing-configuration-loading) | ||
- [Optimizing Route Loading](#optimizing-route-loading) | ||
- [Deploying With Forge](#deploying-with-forge) | ||
|
||
<a name="introduction"></a> | ||
|
||
## Introduction | ||
|
||
When you're ready to deploy your Laravel application to production, there are some important things you can do to make sure your application is running as efficiently as possible. In this document, we'll cover some great starting points for making sure your Laravel application is deployed properly. | ||
|
||
<a name="server-configuration"></a> | ||
|
||
## Server Configuration | ||
|
||
<a name="nginx"></a> | ||
|
||
### Nginx | ||
|
||
If you are deploying your application to a server that is running Nginx, you may use the following configuration file as a starting point for configuring your web server. Most likely, this file will need to be customized depending on your server's configuration. If you would like assistance in managing your server, consider using a service such as [Laravel Forge](https://forge.laravel.com): | ||
|
||
server { | ||
listen 80; | ||
server_name example.com; | ||
root /example.com/public; | ||
|
||
add_header X-Frame-Options "SAMEORIGIN"; | ||
add_header X-XSS-Protection "1; mode=block"; | ||
add_header X-Content-Type-Options "nosniff"; | ||
|
||
index index.html index.htm index.php; | ||
|
||
charset utf-8; | ||
|
||
location / { | ||
try_files $uri $uri/ /index.php?$query_string; | ||
} | ||
|
||
location = /favicon.ico { access_log off; log_not_found off; } | ||
location = /robots.txt { access_log off; log_not_found off; } | ||
|
||
error_page 404 /index.php; | ||
|
||
location ~ \.php$ { | ||
fastcgi_split_path_info ^(.+\.php)(/.+)$; | ||
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; | ||
fastcgi_index index.php; | ||
include fastcgi_params; | ||
} | ||
|
||
location ~ /\.(?!well-known).* { | ||
deny all; | ||
} | ||
} | ||
|
||
|
||
<a name="optimization"></a> | ||
|
||
## Optimization | ||
|
||
<a name="autoloader-optimization"></a> | ||
|
||
### Autoloader Optimization | ||
|
||
When deploying to production, make sure that you are optimizing Composer's class autoloader map so Composer can quickly find the proper file to load for a given class: | ||
|
||
composer install --optimize-autoloader | ||
|
||
|
||
> {tip} In addition to optimizing the autoloader, you should always be sure to include a `composer.lock` file in your project's source control repository. Your project's dependencies can be installed much faster when a `composer.lock` file is present. | ||
<a name="optimizing-configuration-loading"></a> | ||
|
||
### Optimizing Configuration Loading | ||
|
||
When deploying your application to production, you should make sure that you run the `config:cache` Artisan command during your deployment process: | ||
|
||
php artisan config:cache | ||
|
||
|
||
This command will combine all of Laravel's configuration files into a single, cached file, which greatly reduces the number of trips the framework must make to the filesystem when loading your configuration values. | ||
|
||
<a name="optimizing-route-loading"></a> | ||
|
||
### Optimizing Route Loading | ||
|
||
If you are building a large application with many routes, you should make sure that you are running the `route:cache` Artisan command during your deployment process: | ||
|
||
php artisan route:cache | ||
|
||
|
||
This command reduces all of your route registrations into a single method call within a cached file, improving the performance of route registration when registering hundreds of routes. | ||
|
||
> {note} Since this feature uses PHP serialization, you may only cache the routes for applications that exclusively use controller based routes. PHP is not able to serialize Closures. | ||
<a name="deploying-with-forge"></a> | ||
|
||
## Deploying With Forge | ||
|
||
If you aren't quite ready to manage your own server configuration or aren't comfortable configuring all of the various services needed to run a robust Laravel application, [Laravel Forge](https://forge.laravel.com) is a wonderful alternative. | ||
|
||
Laravel Forge can create servers on various infrastructure providers such as DigitalOcean, Linode, AWS, and more. In addition, Forge installs and manages all of the tools needed to build robust Laravel applications, such as Nginx, MySQL, Redis, Memcached, Beanstalk, and more. |