Guest User

Untitled

a guest
Apr 30th, 2025
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.10 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. read -p "Masukkan domain lokal (contoh: akuntansi.local): " DOMAIN
  4. read -p "Pilih jenis proyek (laravel/wordpress): " TYPE
  5.  
  6. PHPVER=8.3
  7. USER=$(whoami)
  8. ROOT="/var/www/$DOMAIN"
  9. NGINX_CONF="/etc/nginx/sites-available/$DOMAIN"
  10.  
  11. # Buat folder proyek
  12. sudo mkdir -p $ROOT
  13. sudo chown $USER:$USER $ROOT
  14. cd $ROOT
  15.  
  16. # Instalasi awal
  17. if [[ $TYPE == "laravel" ]]; then
  18. if ! command -v composer &> /dev/null; then
  19. echo "Composer tidak ditemukan. Mengunduh Composer..."
  20. curl -s https://getcomposer.org/installer | php
  21. sudo mv composer.phar /usr/local/bin/composer
  22. fi
  23. composer create-project laravel/laravel .
  24. mkdir -p storage/logs
  25. sudo chown -R www-data:www-data storage bootstrap/cache
  26. sudo chmod -R 775 storage bootstrap/cache
  27. elif [[ $TYPE == "wordpress" ]]; then
  28. cd /tmp
  29. curl -O https://wordpress.org/latest.tar.gz
  30. tar -xzf latest.tar.gz
  31. mv wordpress/* $ROOT
  32. cd $ROOT
  33. sudo chown -R $USER:$USER .
  34. sudo chmod -R 755 .
  35. else
  36. echo "Jenis proyek tidak valid: $TYPE"
  37. exit 1
  38. fi
  39.  
  40. # Buat konfigurasi NGINX
  41. ROOT_PATH=$ROOT
  42. [[ "$TYPE" == "laravel" ]] && ROOT_PATH="$ROOT/public"
  43.  
  44. sudo tee $NGINX_CONF > /dev/null <<EOF
  45. server {
  46. listen 80;
  47. server_name $DOMAIN;
  48. root $ROOT_PATH;
  49.  
  50. index index.php index.html index.htm;
  51. location / {
  52. try_files \$uri \$uri/ /index.php?\$args;
  53. }
  54.  
  55. location ~ \.php\$ {
  56. include snippets/fastcgi-php.conf;
  57. fastcgi_pass unix:/run/php/php$PHPVER-fpm.sock;
  58. fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
  59. include fastcgi_params;
  60. }
  61.  
  62. location ~ /\.ht {
  63. deny all;
  64. }
  65. }
  66. EOF
  67.  
  68. # Aktifkan site
  69. sudo ln -s $NGINX_CONF /etc/nginx/sites-enabled/
  70.  
  71. # Tambahkan domain ke /etc/hosts
  72. echo "127.0.0.1 $DOMAIN" | sudo tee -a /etc/hosts
  73.  
  74. # Restart service
  75. sudo systemctl restart nginx
  76. sudo systemctl restart php$PHPVER-fpm
  77.  
  78. # Atur agar user saat ini bisa akses folder
  79. sudo chown -R $USER:www-data $ROOT
  80. sudo chmod -R 775 $ROOT
  81.  
  82. echo "✅ Proyek $TYPE siap diakses di http://$DOMAIN"
  83.  
Advertisement
Add Comment
Please, Sign In to add comment