Categories: Laravel Tutorial: Step by Step Guide to Building Your First Laravel Application - Techanical-Atom

How To Deploy Laravel Project On Server2 min read

Deploy Laravel
Reading Time: 2 minutes

The very basic question that comes into the mind when you finished building your project on localhost is How To Deploy Laravel Project On Server ? Now to answer this question and to move your project to production you have to amke sure certain things forehand . In this article we are going to cover some of these starting points so that your project start runnung smoothly on the shared hosting or any other server.

How To Deploy Laravel Project On Server

Suppose you are deploying your project on the nginx then you start with the configuration file . You have enter the following code into the nginx’s configuration file .

# – Deploy Laravel Project On Nginx

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;
}
}

Now apart from this Laravel offers you a great tool which take away your hassel yes that’s right.You can use laravel’s own tool that is Laravel forge.

Read More :- How To Install Laravel Step By Step Guide

# – Deploy Laravel Project On Apache

Starting with Apache , deploying any peoject on the apache server is the easiest task that one can think of . Just go to your public html folder and upload the laravel project there . After that ensures that .htaccess and .env files are there are not sometimes while transferring the peoject these got misplaced .

If these files are in place then open your .env file and change the app_url to your domain name and change database connection if need to . And Boom that’s it you have an up and running laravel project on your apache server .

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 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.

If you like this article gives us a thumbs up and keep visiting for more such article on Techanical-Atom , Techanical Gyaan For All .

All Rights Reserved @ Techanical-Atom
%d bloggers like this: