Last active
July 17, 2021 04:09
-
-
Save alexander-alegre/74227ff2d977edf0e00fc90317299da8 to your computer and use it in GitHub Desktop.
Server Setup Script (WIP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Setup firewall | |
echo "Setting up firewall..." | |
sudo ufw allow OpenSSH | |
sudo ufw enable | |
echo "Updating packages..." | |
## Update packages and Upgrade system | |
sudo apt-get update -y | |
## Install Linux, Nginx, MySQL, PHP | |
echo "Installing NGINX" | |
sudo apt install nginx -y | |
sudo ufw allow 'Nginx HTTP' | |
echo "Installing MySQL" | |
sudo apt install mysql-server -y | |
echo "PHP & basic NGINX" | |
sudo add-apt-repository universe | |
sudo apt install php-fpm php-mysql | |
echo "What is your server_name? ie. example.com" | |
read SERVER_NAME | |
sudo touch /etc/nginx/sites-available/${SERVER_NAME} | |
sudo echo " | |
server { | |
listen 80; | |
listen [::]:80; | |
root /var/www/first-project/public; | |
index index.php index.html index.htm index.nginx-debian.html; | |
server_name ${SERVER_NAME}; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~ \.php$ { | |
include snippets/fastcgi-php.conf; | |
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
}" > /etc/nginx/sites-available/${SERVER_NAME} | |
sudo ln -s /etc/nginx/sites-available/${SERVER_NAME} /etc/nginx/sites-enabled/ | |
sudo unlink /etc/nginx/sites-enabled/default | |
sudo systemctl reload nginx | |
echo "Done setting up NGINX" | |
echo "Setting up Laravel Ecosystem" | |
sudo apt-get install php7.4-mbstring php7.4-xml composer unzip | |
echo "Installing certbot" | |
sudo apt-get install certbot | |
sudo apt install python3-certbot-nginx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment