Lewati ke konten utama

how-to-deploy-pondokmbodo

Membuat SSH dulu​

cd C:\Users\kaesa/.ssh
ssh-keygen -t rsa -b 2048 -C "gitlab.com/lyrihkaesa"
ssh kaesa@ip-address-server

Update dulu VPS Ubuntunya​

sudo apt update -Y && sudo apt upgrade -Y
sudo apt update
sudo apt upgrade

Check Firewall dengan UFW​

ufw: uncomplicated firewall

sudo apt install ufw
sudo ufw app list
sudo ufw allow OpenSSH
sudo ufw status
sudo ufw enable
// Y for confirm
sudo ufw allow 'Nginx HTTP'

Add new User Ubuntu​

adduser lyrih
// enter password

Install PHP​

sudo add-apt-repository ppa:ondrej/php -y
sudo apt search php8.3 | more
sudo apt install php8.3 php8.3-cli php8.3-common php8.3-curl php8.3-pgsql php8.3-fpm php8.3-gd php8.3-imap php8.3-intl php8.3-mbstring php8.3-mysql php8.3-opcache php8.3-readline php8.3-soap php8.3-xml php8.3-zip php8.3-sqlite3
php -v

Install nvm​

sudo apt update
cd ~
sudo su
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source ~/.bashrc
nvm list-remote
nvm install --lts

Install Composer​

sudo apt update
cd ~
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
HASH=`curl -sS https://composer.github.io/installer.sig`
php -r "if (hash_file('SHA384', '/tmp/composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer

Install nginx​

sudo apt install nginx
sudo systemctl status nginx
cd /etc/nginx
cd sites-available
sudo nano charapon.conf
server {
listen 80;
listen [::]:80;
server_name charapon.my.id;
root /var/www/pondokmbodo/public;

# add_header X-Frame-Options "SAMEORIGIN";
# add_header X-Content-Type-Options "nosniff";

index index.html index.php;

charset utf-8;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

# location = /favicon.ico { access_log off; log_not_found off; }
# location = /robots.txt { access_log off; log_not_found off; }

error_page 404 /index.php;

location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}

location ~ /\.(?!well-known).* {
deny all;
}
}
cd ..
cd sites-enabled
sudo ln -s /etc/nginx/sites-available/charapon.conf /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Project Laravel​

cd /var/www
sudo mkdir pondokmbodo #or
git clone -b dev https://github.com/lyrihkaesa/laravel-pondok-mbodo.git pondokmbodo
cd pondokmbodo
composer install
npm install
npm run build
cp .env.example .env
sudo nano .env
php artisan key:generate
php artisan storage:link
sudo chmod -R 775 /var/www/pondokmbodo/storage
sudo chown -R www-data:www-data /var/www/pondokmbodo/storage
php artisan icons:cache

Install PostgreSQL​

sudo apt update
sudo apt install postgresql postgresql-contrib
sudo systemctl start postgresql.service
sudo -i -u postgres
psql
CREATE USER pondokmbodo WITH PASSWORD 'rahasia';
ALTER USER pondokmbodo WITH PASSWORD 'password_baru';
CREATE DATABASE pondokmbodo OWNER pondokmbodo;
CREATE USER kaesa;

GRANT ALL PRIVILEGES ON DATABASE pondokmbodo TO kaesa;
exit
CREATE DATABASE pondokmbodonas OWNER pondokmbodo;

Other​

ls -la

[email protected]