Skip to content

Commands and NGINX default config file

Notifications You must be signed in to change notification settings

oketafred/server-setup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Here's a concise blog post based on the provided code for setting up a Digital Ocean droplet:

Setting Up a Digital Ocean Droplet: A Step-by-Step Guide

Setting up a Digital Ocean droplet can be a great way to host your web applications. Here's a quick guide to get you started:

1. User Management

First, create a sudo user:

adduser username
usermod -aG sudo username

2. SSH Key Setup

Generate an SSH key pair for secure access:

ssh-keygen -t ecdsa -b 521

3. PHP Installation

Install PHP 8.3 and necessary extensions:

sudo apt update
sudo add-apt-repository ppa:ondrej/php
sudo apt install php8.3-cli php8.3-common php8.3-bcmath php8.3-mbstring php8.3-xml php8.3-curl php8.3-gd php8.3-zip php8.3-mysql

Verify installation:

php8.3 -m

4. Composer Installation

sudo apt install composer

5. MySQL Setup

Install and secure MySQL:

sudo apt install mysql-server
sudo mysql_secure_installation

Create a database and user:

CREATE DATABASE yourdatabase;
CREATE USER 'your-username'@'localhost' IDENTIFIED BY 'your-password';
GRANT ALL PRIVILEGES ON yourdatabase.* TO 'your-username'@'localhost';
FLUSH PRIVILEGES;

6. Node.js Installation

Install NVM and Node.js:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install --lts

7. File Permissions

Set proper ownership and permissions:

sudo chown -R $USER:www-data .
sudo find . -type f -exec chmod 664 {} \;
sudo find . -type d -exec chmod 775 {} \;
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache

8. SSL Certificate

Install Certbot and obtain an SSL certificate:

sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d yourdomain.com

9. SSH Configuration

Add this to your SSH config file to keep the ssh-agent active:

User git
Hostname github.com
IdentityFile ~/.ssh/id_github
TCPKeepAlive yes
IdentitiesOnly yes
ServerAliveInterval 60

By following these steps, you'll have a well-configured Digital Ocean droplet ready for your web applications. Remember to adjust usernames, passwords, and domain names as needed.

About

Commands and NGINX default config file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published