Skip to content

Instantly share code, notes, and snippets.

@KROSF
Last active March 17, 2021 18:47
Show Gist options
  • Save KROSF/c27e2260324ec5e3f761c55a061f078e to your computer and use it in GitHub Desktop.
Save KROSF/c27e2260324ec5e3f761c55a061f078e to your computer and use it in GitHub Desktop.
Nginx wildcard
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
sudo add-apt-repository ppa:ondrej/nginx
sudo apt install nginx php7.4-fpm php7.4-common php7.4-intl php7.4-mysql php7.4-xml php7.4-xmlrpc php7.4-curl php7.4-gd php7.4-imagick php7.4-cli php7.4-dev php7.4-imap php7.4-mbstring php7.4-soap php7.4-zip php7.4-bcmath -y
server {
listen 80;
server_name ~^(www\.)?(?<sname>.+?).example.com$;
root /home/user/sites/$sname/public;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log /var/log/nginx/$sname-access.log;
error_log /var/log/nginx/wildcard-error.log debug;
error_page 404 /index.php;
sendfile off;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment