Install Nginx
Install Nginx
apt install -y nginx
systemctl enable nginx
ufw allow http
chown www-data:www-data /usr/share/nginx/html -R
rm /etc/nginx/sites-enabled/default
nano /etc/nginx/conf.d/default.conf
server {
listen 80;
listen [::]:80;
server_name _;
root /usr/share/nginx/html/;
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;
}
}
nginx -t
systemctl reload nginx
mkdir -p /etc/systemd/system/nginx.service.d/
nano /etc/systemd/system/nginx.service.d/restart.conf
[Service]
Restart=always
RestartSec=5s
systemctl daemon-reload
No Comments