Wednesday, April 24, 2024

Nginx : Deploy Laravel

1.Install Laravel

2.Edit parament in Nginx configuration

server {
        server_name example.com;
        listen X.X.X.X;
        root /home/example/public_html/laravel/public; <- change the active laravel folder
        index index.php index.htm index.html;
        access_log /var/log/virtualmin/example.com_access_log;
        error_log /var/log/virtualmin/example.com_error_log;

        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 / {
                       index index.php index.html index.htm;
                       try_files $uri $uri/ /index.php$is_args$args;
        }

        location ~ "\.php(/|$)" {
            try_files $uri $fastcgi_script_name =404;
            default_type application/x-httpd-php;
            fastcgi_pass unix:/run/php-fpm/1713861882126181.sock;
        }

        fastcgi_split_path_info "^(.+\.php)(/.+)$";
        if ($host = example.com) {
            rewrite "^/(.*)$" "https://example.com/$1" redirect;
        }

        # SSL Certiticate
        listen X.X.X.X:443 ssl;
        ssl_certificate /home/example/ssl.cert;
        ssl_certificate_key /home/example/ssl.key;
        rewrite /awstats/awstats.pl /cgi-bin/awstats.pl;
    }
}

3.Test nginx configuration

#nginx -t 

4. Restart nginx services

#systemctl restart nginx

 

Related Posts:

0 comments:

Post a Comment