Update sistem
Lakukan update sistem terlebih dahulu menggunakan apt update dan apt upgrade
#sudo apt update && sudo apt upgrade -y
Install PDO php Mysql
#apt install -y php-pdo-mysql
Install Nginx, PHP dan Git
Secara default, versi PHP yang digunakan adalah 8.1 dan versi PHP yang dibutuhkan oleh Laravel 9 juga 8.1, sehingga kita bisa langsung install php.
#sudo apt install php php-mysql php-cli php-fpm php-mbstring php-xml php-bcmath php-curl php-json php-tokenizer php-common php-cli unzip nginx git
Run this command:
php -i
Output shows:
PDO
PDO support => enabled
PDO drivers => mysql
Install Mariadb-Server dan Client
#sudo apt install mariadb-server mariadb-client
Setting Secure Mysql
#mysql_secure_installation
cek masing-masing versi
#nginx -v
#php --version
#git --version
#mysql --version
Setting php.ini
#nano /etc/php/8.1/fpm/php.ini
Uncoment ;extension=pdo_mysql
#/etc/init.d/nginx restart
#/etc/init.d/php8.1-fpm restart
Install Composer
Versi composer untuk Laravel 9 ini minimal adalah versi 2.x, untuk installasi jalankan perintah berikut.
#curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
#sudo php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer
setelah itu cek versi composer dengan perintah
#composer --version
Ubah file default didalam folder /etc/nginx/sites-available/
#sudo nano /etc/nginx/sites-available/default
kemudian sesuaikan seperti dibawah ini
server {
listen 80;
listen [::]:80;
server_name example.com;
root /var/www/html/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index 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.1-fpm.sock;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
Setelah itu lakukan restart nginx
#sudo systemctl restart nginx
Composer project Laravel
Masuk ke folder root website, dalam contoh ini ada di /var/www/html/
#cd /var/www/html/
kemudian lakukan composer project
#composer create-project laravel/laravel .
Setting Permission
chown -R www-data:www-data
"project foldername"
chown -R www-data:www-data
project_foldername/storage
chmod -R 777
project_foldername/storage
Install certbot
Jalankan perintah berikut untuk installasi certbot
#sudo snap install core; sudo snap refresh core
#sudo snap install --classic certbot
#sudo ln -s /snap/bin/certbot /usr/bin/certbot
silahkan install ssl untuk web
#sudo certbot --nginx
Jika sudah selesai, maka halaman web otomatis redirect ke https
0 Comments