-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3.cofig_nginx
51 lines (38 loc) · 1.55 KB
/
3.cofig_nginx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//===========================
// Configuring Nginx to serve our Laravel application for all requests coming to the server through
its IP address.
//===========================
// go to nginx directory
> cd /etc/nginx
// To configure Nginx to serve our Laravel application,
// we need to create an Nginx configuration block.
// Create a new file in the /etc/nginx/sites-available directory and paste the init configuration block
> cd sites-available
> sudo nano project_name
// Save the file and create a symbolic link between the block file that's inside the sites-available
directory into the sites-enabled directory
> sudo ln -s /etc/nginx/sites-available/project_name /etc/nginx/sites-enabled/
// delete default config for nginx that exist in sites-available
> sudo rm default
// go to sites-enabled and delete the sym link as well
> sudo rm default
// Finally, reload Nginx
> sudo service nginx reload
// init configuration block
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /var/www/laracast/public;
# Add index.php to the list if you are using PHP
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; # Replace with the path to your PHP-FPM socket
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}