diff --git a/aapanel_deploy.sh b/aapanel_deploy.sh index 1614be5..6f8a8a0 100644 --- a/aapanel_deploy.sh +++ b/aapanel_deploy.sh @@ -54,8 +54,20 @@ fi # 4. Set Permissions echo "Step 4: Setting permissions..." chown -R www:www . +chmod -R 755 . chmod +x mivo chmod -R 755 public + +# Ensure Database directory is writable +if [ ! -d "app/Database" ]; then + mkdir -p app/Database + chown www:www app/Database +fi +chmod 775 app/Database +if [ -f "app/Database/database.sqlite" ]; then + chmod 664 app/Database/database.sqlite +fi + # If there's a storage directory (MVC style usually has one) if [ -d "storage" ]; then chmod -R 775 storage diff --git a/app/Controllers/InstallController.php b/app/Controllers/InstallController.php index 6a331f2..2a843ab 100644 --- a/app/Controllers/InstallController.php +++ b/app/Controllers/InstallController.php @@ -15,8 +15,12 @@ class InstallController extends Controller { header('Location: /login'); exit; } + + $permissions = $this->checkPermissions(); - return $this->view('install'); + return $this->view('install', [ + 'permissions' => $permissions + ]); } public function process() { @@ -25,6 +29,13 @@ class InstallController extends Controller { exit; } + $permissions = $this->checkPermissions(); + if (!$permissions['db_writable'] || !$permissions['root_writable']) { + \App\Helpers\FlashHelper::set('error', 'Izin Ditolak', 'Pastikan folder app/Database dan root direktori dapat ditulis oleh server web.'); + header('Location: /install'); + exit; + } + $username = $_POST['username'] ?? 'admin'; $password = $_POST['password'] ?? 'admin'; @@ -63,6 +74,17 @@ class InstallController extends Controller { } } + private function checkPermissions() { + $dbDir = ROOT . '/app/Database'; + $envFile = ROOT . '/.env'; + + return [ + 'db_writable' => is_writable($dbDir), + 'env_writable' => file_exists($envFile) ? is_writable($envFile) : is_writable(ROOT), + 'root_writable' => is_writable(ROOT) + ]; + } + private function isInstalled() { // Check if .env exists and APP_KEY is set to something other than the default/example $envPath = ROOT . '/.env'; diff --git a/app/Database/.gitkeep b/app/Database/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/app/Views/install.php b/app/Views/install.php index 070412a..ae2f2e4 100644 --- a/app/Views/install.php +++ b/app/Views/install.php @@ -20,6 +20,26 @@
+ +
+
+ +

Peringatan Izin Direktori

+
+ +

+ Silakan perbaiki izin folder di server Anda sebelum melanjutkan. +

+
+ +