Your Essential Queries
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:
- sudo nano /etc/nginx/sites-available/your_domain.com
3) Update 'try_file' Inside 'location' To Handle Laravel Routes:
- server {
- listen 80;
- server_name your_domain.com;
- root "/var/www/your_domain.com/public";
- index index.html index.htm index.php;
- client_max_body_size 10M;
- location / {
- try_files $uri $uri/ /index.php?$query_string;
- }
- location ~ \.php$ {
- include snippets/fastcgi-php.conf;
- fastcgi_pass unix:/run/php/php7.4-fpm.sock;
- }
- }
To Save :
press CTRL+x
press y
press Enter
4) Link New Configuration File
- sudo ln -s /etc/nginx/sites-available/your_domain.com /etc/nginx/sites-enabled/
5) Restart Nginx Server
- sudo systemctl restart nginx
Visit your_domain.com