Skip to content

Instantly share code, notes, and snippets.

@vmfunc
Created June 24, 2021 07:30
Show Gist options
  • Save vmfunc/d723a1c463d239a8c759a02fb3d621fb to your computer and use it in GitHub Desktop.
Save vmfunc/d723a1c463d239a8c759a02fb3d621fb to your computer and use it in GitHub Desktop.
Script to setup easily a server (Debian 10)
#!/bin/sh
username=qt
password=CHANGE-THIS-OR-GESHI-WILL-BE-SAD
adduser --gecos "" --disabled-password $username
chpasswd <<<"$username:$password"
usermod -aG sudo qt
apt -y update
apt -y install ufw
ufw allow OpenSSH
sudo ufw --force enable
sudo apt -y update
sudo apt -y upgrade
sudo apt -y install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
sudo ufw allow http
sudo chown www-data:www-data /usr/share/nginx/html/ -R
sudo apt -y install mariadb-server mariadb-client
sudo systemctl start mariadb
sudo systemctl enable mariadb
mysql -e "UPDATE mysql.user SET Password = PASSWORD('CHANGETHISLMFAO') WHERE User = 'root'"
mysql -e "DROP USER ''@'localhost'"
mysql -e "DROP USER ''@'$(hostname)'"
mysql -e "DROP DATABASE test"
mysql -e "FLUSH PRIVILEGES"
sudo apt -y install php7.3 php7.3-fpm php7.3-mysql php-common php7.3-cli php7.3-common php7.3-json php7.3-opcache php7.3-readline
sudo systemctl start php7.3-fpm
sudo systemctl enable php7.3-fpm
sudo rm /etc/nginx/sites-enabled/default
printf "server {\n listen 80;\n listen [::]:80;\n server_name _;\n root /usr/share/nginx/html/;\n index index.php index.html index.htm index.nginx-debian.html;\n\n location / {\n try_files $uri $uri/ /index.php;\n }\n\n location ~ \.php$ {\n fastcgi_pass unix:/run/php/php7.3-fpm.sock;\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n include fastcgi_params;\n include snippets/fastcgi-php.conf;\n }\n\n # A long browser cache lifetime can speed up repeat visits to your page\n location ~* \.(jpg|jpeg|gif|png|webp|svg|woff|woff2|ttf|css|js|ico|xml)$ {\n access_log off;\n log_not_found off;\n expires 360d;\n }\n\n # disable access to hidden files\n location ~ /\.ht {\n access_log off;\n log_not_found off;\n deny all;\n }\n}" > /etc/nginx/conf.d/default.conf
echo "Fuu~ Setup complete !"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment