This repository contains multiple shell scripts to help you quickly set up a new Ubuntu server with essential tools, security configurations, Python/Django environment, and Docker images.
- Introduction
- Basic Setup
- Security Setup
- Python and Django Setup
- Docker Setup
- How to Use
- Command Assistance
These scripts are designed to automate the initial setup of a new Ubuntu server by installing necessary packages and performing essential configurations. Each script focuses on a specific aspect of server setup:
- Basic Setup – Installs commonly used utilities.
- Security Setup – Configures basic security settings (SSH, firewall, Fail2Ban, etc.).
- Python and Django Setup – Installs Python, PostgreSQL, and sets up an environment for Django applications.
- Docker Setup – Installs Docker and lets you choose which popular Docker images to download.
The basic_setup.sh
script installs a set of essential tools and utilities that are commonly needed on a fresh Ubuntu server.
curl
,wget
,build-essential
,software-properties-common
vim
(text editor)git
(version control)tmux
(terminal multiplexer)fish
(user-friendly shell)htop
(system monitor)
To run this script:
chmod +x basic_setup.sh
./basic_setup.sh
The security_setup.sh
script focuses on configuring security-related settings for the server. It does the following:
- Creates a new non-root user with sudo privileges.
- Configures SSH for key-based authentication and disables password login.
- Installs and configures UFW (firewall) and Fail2Ban to protect against brute-force attacks.
To run this script:
chmod +x security_setup.sh
./security_setup.sh
The python_django_setup.sh
script installs the necessary packages and dependencies for running Python and Django applications on your server. It installs:
- Python 3, pip, and virtualenv.
- PostgreSQL database and libraries required for connecting Django to PostgreSQL.
- Nginx and Gunicorn for serving Django applications.
To run this script:
chmod +x python_django_setup.sh
./python_django_setup.sh
The docker_setup.sh
script installs Docker, Docker Compose, and allows you to pull popular Docker images based on your needs. After installation, you can choose from a set of common Docker images to download.
- PostgreSQL
- MongoDB
- MySQL
- Redis
- Nginx
- Python
- Node.js
To run this script:
chmod +x docker_setup.sh
./docker_setup.sh
Once the script asks, simply input the names of the images you'd like to pull, separated by spaces. For example:
Options: postgres mongo redis nginx
- Clone this repository to your Ubuntu server:
git clone https://github.com/mr-fact/linux-setup.git
cd linux-setup
- Make sure the scripts are executable:
chmod +x *.sh
- Run the scripts in the order you need, depending on your setup requirements. For example, to start with the basic setup:
./basic_setup.sh
- Follow the instructions provided by each script. You may need to input some data (like a username) or make configuration choices along the way.
Feel free to fork this repository and make improvements or add additional setup scripts. Pull requests are welcome!
# Create a New Server Block
sudo nano /etc/nginx/sites-available/example.com
# Create the Document Root
sudo mkdir -p /var/www/example.com/
sudo chown -R $USER:$USER /var/www/example.com/
# Enable the Server Block
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/
# Test and Reload Nginx
sudo nginx -t
sudo systemctl reload nginx
# Install Certbot
sudo apt update
sudo apt install certbot python3-certbot-nginx
# Obtain an SSL Certificate
sudo certbot --nginx -d example.com -d www.example.com
# Set Up Automatic Renewal
sudo certbot renew --dry-run
# Check Nginx Configuration
sudo nano /etc/nginx/sites-available/example.com
# server {
# listen 80;
# server_name example.com www.example.com;
# return 301 https://$host$request_uri;
# }
# server {
# listen 443 ssl;
# server_name example.com www.example.com;
#
# ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
#
# ...
# }