KenoKivabe

Your Essential Queries

Author
Md Mojahedul Islam
06 Aug, 2022

How To Host Laravel Application In Nginx Server


We'll See How To Host Laravel Application In Nginx Server:

1) Open Terminal

2) Create Nginx Configuration File:

  1. sudo nano /etc/nginx/sites-available/your_domain.com   

3) Update 'try_file' Inside 'location' To Handle Laravel Routes:

  1. server {  
  2.     listen 80;  
  3.     server_name your_domain.com;  
  4.     root "/var/www/your_domain.com/public";  
  5.   
  6.     index index.html index.htm index.php;  
  7.       
  8.     client_max_body_size 10M;  
  9.   
  10.     location / {  
  11.        try_files $uri $uri/ /index.php?$query_string;  
  12.     }  
  13.   
  14.     location ~ \.php$ {  
  15.         include snippets/fastcgi-php.conf;  
  16.         fastcgi_pass unix:/run/php/php7.4-fpm.sock;  
  17.     }  

To Save :

      press CTRL+x
      press y
      press Enter

4) Link New Configuration File

  1. sudo ln -s /etc/nginx/sites-available/your_domain.com /etc/nginx/sites-enabled/  

5) Restart Nginx Server

  1. sudo systemctl restart nginx 

Visit your_domain.com

Share: