User Tools

Site Tools


virtual-block

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
virtual-block [2020/10/22 11:05] – created gwsadminvirtual-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 /etc/nginx/conf.d if you have been following with this wiki. All commented parts are where you add your domain/path to disk.** 
 + 
 +**Firsty open up a blank file** 
 +<code bash> 
 +sudo nano /etc/nginx/conf.d/example.conf 
 + 
 +</code> 
 +  * Where 'example.conf ' is, add your domain name eg guildfordwebservices.conf 
 +  * Add this to the blank file 
 + 
 +<code bash> 
 +server { 
 +  listen 80; 
 +  listen [::]:80; 
 +  server_name example.com; #CHANGE THIS TO YOUR DOMAIN/SUB DOMAIN 
 +  root /add/path/where/your/webdata/is/; #CHANGE THIS TO WHERE YOUR WEB FILES ARE 
 +  index index.php index.html index.htm index.nginx-debian.html; 
 + 
 +  location / { 
 +    try_files $uri $uri/ /index.php; 
 +  } 
 + 
 +  location ~ \.php$ { 
 +    fastcgi_pass unix:/run/php/php7.4-fpm.sock; 
 +    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
 +    include fastcgi_params; 
 +    include snippets/fastcgi-php.conf; 
 +  } 
 + 
 + # 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)$ { 
 +       access_log        off; 
 +       log_not_found     off; 
 +       expires           360d; 
 +  } 
 + 
 +  # disable access to hidden files 
 +  location ~ /\.ht { 
 +      access_log off; 
 +      log_not_found off; 
 +      deny all; 
 +  } 
 +
 + 
 +</code> 
 + 
 +Run //**Nginx -t **// to check for no errors, then reload Nginx '//**sudo systemctl restart nginx'** // 
 + 
 +If that is successfull, run Certbot to secrue the site running '//**sudo certbot --nginx' **//
  
  
virtual-block.1603364725.txt.gz · Last modified: 2023/05/17 22:52 (external edit)