This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
virtual-block [2020/10/22 11:05] – created gwsadmin | virtual-block [2023/05/17 22:52] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Add a custom server block to nginx ====== | + | ====== Add a custom server block to Nginx ====== |
- | Coming soon | + | **All your server blocks should be saved in the folder / |
+ | |||
+ | **Firsty open up a blank file** | ||
+ | <code bash> | ||
+ | sudo nano / | ||
+ | |||
+ | </ | ||
+ | * Where ' | ||
+ | * Add this to the blank file | ||
+ | |||
+ | <code bash> | ||
+ | server { | ||
+ | listen 80; | ||
+ | listen [::]:80; | ||
+ | server_name example.com; | ||
+ | root / | ||
+ | index index.php index.html index.htm index.nginx-debian.html; | ||
+ | |||
+ | location / { | ||
+ | try_files $uri $uri/ / | ||
+ | } | ||
+ | |||
+ | location ~ \.php$ { | ||
+ | fastcgi_pass unix:/ | ||
+ | fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
+ | include fastcgi_params; | ||
+ | include snippets/ | ||
+ | } | ||
+ | |||
+ | # A long browser cache lifetime can speed up repeat visits to your page | ||
+ | location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ { | ||
+ | | ||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | # disable access to hidden files | ||
+ | location ~ /\.ht { | ||
+ | access_log off; | ||
+ | log_not_found off; | ||
+ | deny all; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | Run //**Nginx -t **// to check for no errors, then reload Nginx '// | ||
+ | |||
+ | If that is successfull, | ||