Bubka / 2FAuth

A Web app to manage your Two-Factor Authentication (2FA) accounts and generate their security codes
https://docs.2fauth.app/
GNU Affero General Public License v3.0
2.12k stars 142 forks source link

Windows deploy to cPanel path/install problem #370

Closed muhammedtur closed 2 weeks ago

muhammedtur commented 2 months ago

Is your feature request related to a problem? Please describe. Yes, the problem is about install on windows PC and upload to cPanel host. Storage path getting wrong path on windows, I have to update the all paths in config.php file after install. I have no access to SSH or terminal so I can't install or can't use commands on cPanel.

Describe the solution you'd like Can be creating a question while using "install" command and we can give host path.

Describe alternatives you've considered I have to create path links etc. on host and I have to update on config.php file. But I found a solution, I created a virtual machine with same path on host, so after installation I'm just zipping the folder and upload to host and extract there.

Additional context I searched and didn't find any relating issue or discussion, if there is a solution please let me know. Also can't create symbolic link on windows, that's the another problem.

Bubka commented 1 month ago

Hi, Windows (10 & 11 at least) can create symlinks (with mklink /J myLinkName c:\absolute\path\to\target or mklink /J myLinkName ..\relative\path\to\target), but AFAIK they won't work once uploaded to a unix system.

Anyway, you are in a specific situation. I don't want to develop a dedicated solution, but here is an easier workaround (IMO) than your VM trick.

On Windows, edit the file \<2FAuth_install_dir>\routes\web.php and add the following lines right before the last line of the file:

Route::get('/symlink', function () {
    Artisan::call('storage:link');
});

Your file should now ends like this:

/**
 * Route for the main landing view
 */
Route::get('/symlink', function () {
    Artisan::call('storage:link');
});
Route::get('/{any}', [SinglePageController::class, 'index'])->where('any', '.*')->name('landing');

Once saved, upload the file to cPanel (overwrite the existing file if there is one) and open https://<your.2fauth.url>/symlink in your browser. You will probably get a blank page, but on the server side the php script will create the symlink for you.

You should now have a working 2FAuth instance. The web.php file can be restored to its original version by removing the extra lines and updated again in cPanel, the symlink won't be deleted.

muhammedtur commented 1 month ago

Hi, Windows (10 & 11 at least) can create symlinks (with mklink /J myLinkName c:\absolute\path\to\target or mklink /J myLinkName ..\relative\path\to\target), but AFAIK they won't work once uploaded to a unix system.

Anyway, you are in a specific situation. I don't want to develop a dedicated solution, but here is an easier workaround (IMO) than your VM trick.

On Windows, edit the file \<2FAuth_install_dir>\routes\web.php and add the following lines right before the last line of the file:

Route::get('/symlink', function () {
    Artisan::call('storage:link');
});

Your file should now ends like this:

/**
 * Route for the main landing view
 */
Route::get('/symlink', function () {
    Artisan::call('storage:link');
});
Route::get('/{any}', [SinglePageController::class, 'index'])->where('any', '.*')->name('landing');

Once saved, upload the file to cPanel (overwrite the existing file if there is one) and open https://<your.2fauth.url>/symlink in your browser. You will probably get a blank page, but on the server side the php script will create the symlink for you.

You should now have a working 2FAuth instance. The web.php file can be restored to its original version by removing the extra lines and updated again in cPanel, the symlink won't be deleted.

Thank you so much for detailed explanation