Configure Nginx

Create an Nginx Configuration File for Laravel:

sudo nano /etc/nginx/sites-available/laravel

Add the following content:  root /var/www/laravel-app/public;

server {
    listen 80;
    server_name your-domain.com;
    root /var/www/laravel-app/public;
    index index.php index.html;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
    location ~ /\.ht {
        deny all;
    }
}

Enable the Configuration:

sudo ln -s /etc/nginx/sites-available/laravel /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

 

Related Articles