- create droplet and choose root password
- login to server using the ssh password
ssh root@ip - upgrade os packages
apt updateapt list --upgradableapt upgrade
- add new user
adduser usernameusermod -aG sudo usernameto add user to the sudo group- to test/login user
su - username
- setup local ssh
cd ~/.ssh(for mac)ssh-keygen -t ecdsa -b 521- enter key starts with
id_then leave the password empty ssh-copy-id username@ip
- disable root access (from here onward, you can use the new user you created - that's why it has sudo on all of the commands)
sudo nano /etc/ssh/sshd_configand set the following valuesPermitRootLogin noPubkeyAuthentication yes- uncomment
AuthorizedKeysFile PasswordAuthentication no- uncomment
PermitEmptyPasswords no
- restart the ssh server
sudo systemctl restart ssh
- create config file inside ~/.ssh
cd ~/.sshnano config
User username
Hostname ip
IdentityFile ~/.ssh/id_username
-
install php, nginx, mysql, nodejs and certbot
sudo add-apt-repository ppa:ondrej/phpsudo apt install php8.3-clisudo apt install php8.3-common php8.3-bcmath php8.3-mbstring php8.3-xml php8.3-curl php8.3-gd php8.3-zip php8.3-mysql php8.3-fpm php8.3-sqlite3 php8.3-intlsudo apt install composersudo apt install mysql-serversudo mysql_secure_installation- answer yes to all and for the password, choose (2 = STRONG)
sudo mysqland create a databaseCREATE DATABASE dbname;CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';and make sure password is a bit more complexGRANT ALL PRIVILEGES ON dbname.* TO 'username'@'localhost';FLUSH PRIVILEGES;
sudo apt install nginx- to test, open the ip address in you browser and should see nginx page
- go to https://github.com/nvm-sh/nvm and copy on of the installation command
- follow the 2nd instruction for cloning the script for nvm
nvm install --lts
-
clone project
- take ownership of the directory first
sudo chown -R username:username /var/www/html/
- use ssh for cloning
- generate ssh key pair for github
- in the server
cd ~/.ssh - generate a new ssh key as before
ssh-keygen -t ecdsa -b 521 - use id like
id_github cat id_github.puband copy the value shown- paste the value in github https://github.com/settings/keys
- check if ssh agent is running
eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_github- test connection
ssh -T git@github.com
- in the server
- clone the project now using SSH :)
- take ownership of the directory first
-
change ownership of files
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/cachesudo chmod -R ug+rwx storage bootstrap/cache
-
setup nginx
cd /etc/nginx/sites-availablesudo nano domain.comthen paste the suggested settings from laravel docs - https://laravel.com/docs/11.x/deployment#nginx- enable server block
sudo ln -s /etc/nginx/sites-available/domain.com /etc/nginx/sites-enabled - go to project folder and run
sudo nginx -tto test configuration sudo systemctl restart nginx- make user
php8.4-fpmis installed if having 502 error
-
if needed to build using vite
sudo chmod +x ./node_modules/.bin/vitesudo chmod +x /var/www/html/projectfolder/node_modules/@esbuild/linux-x64/bin/esbuildsudo chown -R your_username:your_username /var/www/html/projectfolder/node_modulesrm -rf node_modules && npm i
-
install certbot
sudo apt install certbot python3-certbot-nginxsudo certbot --nginx -d domain.com
-
if having problem cloning using git, do this coz agent might stopped working
cd ~/.sshnano configthen own the filesudo chown username config
Hostname github.com
IdentityFile ~/.ssh/id_github
TCPKeepAlive yes
IdentitiesOnly yes
ServerAliveInterval 60