Server Deployment
- Download PuTTY https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
- Daftar VPS (via Private Cloud IDCloudHost)
- Daftar ke IDCloudHost Console (Bisa pake Login with Google) https://console.idcloudhost.com/hub/login
- Topup untuk bisa buat VPS Private Cloud (atau bisa apply free credit, informasi cek link paling bawah)
- Klik Compute lalu klik New
- Isi sesuai form
- Masuk ke Server
- Informasi SSH dapat diakses di bagian kiri, lalu di klik, akan muncul seperti ini
- Gunakan Public IP untuk dapat masuk ke server dengan menggunakan PuTTY
- Masukkan username dan password
- Masuk sebagai root sudo su
- Mengatur Firewall Referensi: https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-18-04
- ufw app list
- ufw allow OpenSSH
- ufw enable
- ufw status
- Install LEMP Referensi: https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04
- Install Nginx
- sudo apt update
- sudo apt install nginx
- sudo ufw allow ‘Nginx HTTP’
- sudo ufw status
- Buka IP kamu, harusnya muncul seperti ini
- Install MySQL
- sudo apt install mysql-server
- sudo mysql_secure_installation
- Setting security sesuaikan dengan keinginan kalian
- Ganti ke metode password
- sudo mysql
- SELECT user,authentication_string,plugin,host FROM mysql.user;
- ALTER USER ‘root’@’localhost’ IDENTIFIED WITH mysql_native_password BY ‘password’;
- Nanti masuknya pake: mysql -u root -p
- Install PHP
- sudo apt install php-fpm php-mysql
- Tes PHP
- sudo nano /etc/nginx/sites-available/default
- Ubah ke:
index index.php index.html index.htm index.nginx-debian.html;
- Tambahin lagi :
location ~ \\.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; } location ~ /\\.ht { deny all; }
- sudo nano /var/www/html/info.php
- Isi code didalemnya
<?php phpinfo();
- sudo nginx -t
- sudo systemctl reload nginx
- Buka URL http://IP_SERVER_ANDA/info.php
- Install Composer
- sudo apt update
- sudo apt install curl php-cli php-mbstring git unzip
- cd ~
- curl -sS https://getcomposer.org/installer -o composer-setup.php
- HASH=xxx Copy hash dari sini https://composer.github.io/pubkeys.html
- php -r “if (hash_file(‘SHA384’, ‘composer-setup.php’) === ‘$HASH’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”
- sudo php composer-setup.php –install-dir=/usr/local/bin –filename=composer
- composer
- Install modul PHP
- sudo apt update
- sudo apt install php-mbstring php-xml php-bcmath
- Install Nginx
- Buat Database
- mysql -u root -p
- CREATE DATABASE bwastore;
- GRANT ALL ON bwastore. TO ‘bwastore’@’localhost’ IDENTIFIED BY ‘nasigorenglimaribu’ WITH GRANT OPTION;*
- exit
- Setup aplikasi
- sudo su
- Masuk ke folder
cd /var/www
- Pull project kalian dari github
git clone URL_GITHUB_KALIAN NAMA_DOMAIN_KALIAN
ls
lalucd NAMA_DOMAIN_KALIAN
composer install
nano .env
- Copas konfigurasi kalian dari local, ganti bagian database
- Ganti bagian
APP_DEBUG=false
danAPP_ENV=production
biar kalau error ga muncul (mengamankan coding) php artisan storage:link
- Setting nginx
sudo chown -R www-data.www-data /var/www/NAMA_DOMAIN_KALIAN/storage
sudo chown -R www-data.www-data /var/www/NAMA_DOMAIN_KALIAN/bootstrap/cache
sudo nano /etc/nginx/sites-available/NAMA_DOMAIN_KALIAN
server { listen 80; server_name NAMA_DOMAIN_KALIAN; root /var/www/NAMA_DOMAIN_KALIAN/public; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; index index.html index.htm 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/php7.2-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; } location ~ /\\.(?!well-known).* { deny all; } }
- Ganti bagian server_name jadi
NAMA_DOMAIN_KALIAN
- Ganti bagian root jadi
/var/www/NAMA_DOMAIN_KALIAN/public;
- Save filenya
sudo ln -s /etc/nginx/sites-available/NAMA_DOMAIN_KALIAN/ etc/nginx/sites-enabled/
sudo nginx -t
- Harus muncul kayak gini:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
- sudo systemctl reload nginx
- Setting Database dan Migration
cd /var/www/NAMA_DOMAIN_KALIAN/
php artisan migrate
- Setting domain kalian
- Masuk ke panel hosting kalian (contoh disini pakai IDCloudHost)
- Masuk manage DNS
- Tambah Add Record
- Namenya isi
NAMA_DOMAIN_KALIAN.
Depannya pakai titik - Type nya ganti A
- Isi selanjutnya (RDATA / IP Address) masukin nama IP server kalian (bisa dicek di dashboard nya)
- Add Record / Save
- Kurang lebih seperti ini:
- Buka website kalian sesuai
NAMA_DOMAIN_KALIAN
- Belum muncul? Sabar tunggu dulu mungkin belum propagasi. Tinggalin minum kopi dulu
- Install PHPMyAdmin (opsional)
- Referensi dari sini https://linuxize.com/post/how-to-install-phpmyadmin-with-nginx-on-ubuntu-18-04/
sudo apt install phpmyadmin
- Skip dua pilihan, pilih OK (pakai TAB terus ENTER)
- Pilih yes
- Masukin password phpmyadmin
mysql
-u root -pCREATE USER 'padmin'@'localhost' IDENTIFIED BY 'PASSWORD_SQL_PHPMYADMINYA';
GRANT ALL PRIVILEGES ON *.* TO 'padmin'@'localhost' WITH GRANT OPTION;
exit
sudo nano /etc/nginx/snippets/phpmyadmin.conf
- Copas ini :
location /phpmyadmin { root /usr/share/; index index.php index.html index.htm; location ~ ^/phpmyadmin/(.+\\.php)$ { try_files $uri =404; root /usr/share/; fastcgi_pass unix:/run/php/php7.2-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include /etc/nginx/fastcgi_params; } location ~* ^/phpmyadmin/(.+\\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/; } }
nano /etc/nginx/sites-available/default
- Masukkan
include snippets/phpmyadmin.conf;
didalam blockserver{}
sudo nginx -t
sudo systemctl reload nginx
- Masuk ke
http://IP_SERVER_KALIAN/phpmyadmin/
- Kalau nemu error, jalanin ini :
sudo sed -i "s/|\\s*\\((count(\\$analyzed_sql_results\\['select_expr'\\]\\)/| (\\1)/g" /usr/share/phpmyadmin/libraries/sql.lib.php
Petiknya jangan dicopas ketik manual
credit to bwa class
Server Deployment
Reviewed by ilman
on
4:21 AM
Rating:
No comments