ssh root@your_server_ip
Update
sudo apt-get update
sudo apt-get upgrade -y
Kedepannya kita ga akan pernah login lagi sebagai root, tapi dengan user baru ini
adduser fadli
usermod -aG sudo fadli
Cek dulu setting yang ada:
ufw app list
ufw allow OpenSSH
ufw enable
ufw status
ssh fadli@your_server_ip
rsync --archive --chown=fadli:fadli ~/.ssh /home/fadli
ssh-keygen
Akan ada 2 file yang jadi:
- ~/.ssh/id_rsa: Private key. Jangan share ini.
- ~/.ssh/id_rsa.pub: Public key. Bisa di share.
C.2.1. Dengan SSH Copy ID
ssh-copy-id username@remote_host
C.2.2. Dengan Manual
cat ~/.ssh/id_rsa.pub
Copy value nya. Masuk ke server lagi. Buat folder SSH
mkdir -p ~/.ssh
Terus masukkan public key yang dicopy tadi
echo isi_public_key >> ~/.ssh/authorized_keys
sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/authorized_keys
ssh fadli@remote_host
sudo nano /etc/ssh/sshd_config
Cari baris PasswordAuthentication, comment nya dihapus, biar aktif
PasswordAuthentication no
Restart
sudo service ssh restart
atau
sudo systemctl restart ssh
Di local
nano ~/.ssh/config
Trus buat config nya
Host testhost
HostName your_domain
User demo
sudo nano /etc/ssh/sshd_config
Cari dan edit
AllowUsers user1 user2
Restart
sudo service ssh restart
sudo nano /etc/ssh/sshd_config
Cari dan edit
PermitRootLogin no
Restart
sudo service ssh restart
nano ~/.ssh/config
cari dan edit
Host *
ServerAliveInterval 120
sudo apt update
sudo apt install nginx
Enable Nginx
sudo systemctl start nginx
sudo systemctl enable nginx
sudo ufw app list
sudo ufw allow 'Nginx HTTP'
verifiy
sudo ufw status
systemctl status nginx
Buka ip address nya, kalau ga tau silahkan ketik di server:
curl -4 icanhazip.com
Stop web server:
sudo systemctl stop nginx
Start web server:
sudo systemctl start nginx
Stop and start web server:
sudo systemctl restart nginx
Configuration changes and reload web server:
sudo systemctl reload nginx
Disable startu automaticaly the server:
sudo systemctl disable nginx
Start at boot server:
sudo systemctl enable nginx
sudo apt install php8.1-fpm php8.1-sqlite3
verify
php -v
Cek Sqlite
sqlite3 --version
Multiple domain di /var/www/
Buat directory
sudo mkdir -p /var/www/your_domain
Kasih ownership access ke $USER environtment variable
sudo chown -R $USER:$USER /var/www/your_domain
permission
sudo chmod -R 755 /var/www/your_domain
setup configuration block
sudo nano /etc/nginx/sites-available/your_domain
configuration
server {
listen 80;
server_name your_domain www.your_domain;
root /var/www/your_domain;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
site enable
sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/
unlink
sudo unlink /etc/nginx/sites-enabled/default
prevent memory bucket problem
sudo nano /etc/nginx/nginx.conf
cari server_names_hash_bucket_size, uncomment
...
http {
...
server_names_hash_bucket_size 64;
...
}
...
Cek syntax error di config nginx
sudo nginx -t
kalau aman restart
sudo systemctl restart nginx
sudo snap install core; sudo snap refresh core
old
sudo apt remove certbot
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
link certbot command
sudo ln -s /snap/bin/certbot /usr/bin/certbot
Cek firewall
sudo ufw status
Tambah
sudo ufw allow 'Nginx Full'
sudo ufw delete allow 'Nginx HTTP'
Cek statusnya
sudo ufw status
sudo certbot --nginx -d example.com -d www.example.com
sudo systemctl status snap.certbot.renew.service
dryrun
sudo certbot renew --dry-run
Buat folder di /var/www/
sudo mkdir -p /var/www/your_domain
Kasih ownership access ke $USER environtment variable
sudo chown -R $USER:$USER /var/www/your_domain
permission
sudo chmod -R 755 /var/www/your_domain
setup configuration block
sudo nano /etc/nginx/sites-available/your_domain
configuration
server {
listen 80;
server_name your_domain www.your_domain;
root /var/www/your_domain;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
site enable
sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/
Cek syntax error di config nginx
sudo nginx -t
kalau aman restart
sudo systemctl restart nginx
sudo certbot --nginx -d example.com -d www.example.com
sudo systemctl status snap.certbot.renew.service
dryrun
sudo certbot renew --dry-run
git --version
Set Name on Git
git config --global user.name "Fadli Wilihandarwo"
git config --global user.email "fadli@wilihandarwo.com"
git config --global init.defaultBranch main
ssh-keygen -t ed25519 -C "your_email@example.com"
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub
Add key to SSH Key on Github
Go to the directory, and don't forget add dot . at the end to copy to current folder
git clone https://github.com/username/repo.git .
Copy deployer.php
nano deployer.php
create per site setting php
nano contohwebsite.php
create log file
nano contohwebsite.log
sudo chown -R www-data:www-data /var/www/contohwebsite.com
sudo chmod -R 750 /var/www/contohwebsite.com
sudo chown -R www-data:www-data /var/www/setupvps.com/deploy/contohwebsite.php
sudo chown -R www-data:www-data /var/www/setupvps.com/deploy/contohwebsite.log
sudo chown -R www-data:www-data /var/www/setupvps.com/deploy/deployer.php
sudo chmod -R 750 /var/www/setupvps.com/deploy/contohwebsite.php
sudo chmod -R 750 /var/www/setupvps.com/deploy/contohwebsite.log
sudo chmod -R 750 /var/www/setupvps.com/deploy/deployer.php
sudo mkdir .ssh
sudo chown -R www-data:www-data .ssh
sudo -u www-data -s /bin/bash
ssh-keygen -t ed25519 -C "fadli@wilihandarwo.com"
cat /var/www/.ssh/id_ed25519.pub
copy ke github ssh key setting
cd /var/www/contohwebsite.com/
git status
git pull
👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇👇
Buat folder di /var/www/
sudo mkdir -p /var/www/your_domain
Kasih ownership access ke $USER environtment variable
sudo chown -R $USER:$USER /var/www/your_domain
permission
sudo chmod -R 750 /var/www/your_domain
setup configuration block
sudo nano /etc/nginx/sites-available/your_domain
configuration
server {
listen 80;
server_name your_domain www.your_domain;
root /var/www/your_domain;
index index.html index.htm index.php;
location / {
try_files $uri $uri/ /index.php
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
site enable
sudo ln -s /etc/nginx/sites-available/your_domain /etc/nginx/sites-enabled/
Cek syntax error di config nginx
sudo nginx -t
kalau aman restart
sudo systemctl restart nginx
sudo certbot --nginx -d example.com -d www.example.com
sudo systemctl status snap.certbot.renew.service
dryrun
sudo certbot renew --dry-run
Go to the directory, and don't forget add dot . at the end to copy to current folder
git clone git@github.com:wilihandarwo/solofounder.id.git .
git status
git add .
git commit -m "test"
git pull
git config pull.rebase false
git push
go to folder /var/www/setupvps.com/deploy/ create per site setting php
nano contohwebsite.php
create log file
nano contohwebsite.log
sudo chown -R www-data:www-data /var/www/contohwebsite.com
sudo chmod -R 750 /var/www/contohwebsite.com
sudo chown -R www-data:www-data /var/www/setupvps.com/deploy/contohwebsite.php
sudo chown -R www-data:www-data /var/www/setupvps.com/deploy/contohwebsite.log
sudo chmod -R 750 /var/www/setupvps.com/deploy/contohwebsite.php
sudo chmod -R 750 /var/www/setupvps.com/deploy/contohwebsite.log
sudo -u www-data -s /bin/bash
cd /var/www/contohwebsite.com/
git status
git pull
Payload url: https://setupvps.com/deploy/iklanabadi.php Content Type: application/json Secret: