Last active
November 3, 2019 13:11
-
-
Save davinderpalrehal/dd8892255905f3b7cc5db4d38f01cf2d to your computer and use it in GitHub Desktop.
Nginx configuration to work with PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
# Using port 8080 only for testing purposes | |
listen 8080 default_server; | |
listen [::]:8080 default_server; | |
# Where are the files that are being served | |
root /srv/www/html; | |
# Default Index file being served, have added `index.php` | |
index index.php index.html index.htm index.nginx-debian.html; | |
server_name _; | |
location / { | |
# Added support for PHP routers | |
try_files $uri $uri/ /index.php?args =404; | |
} | |
# Adding support for PHP7.3 | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/var/run/php/php7.3-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
# Adding environmental variables for this website | |
include /srv/config/default.nginx.conf; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment