mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 06:13:58 -07:00
feat(installer): Add web server config guidance post-installation (#2086)
* feat(installer): Add web server config guidance post-installation * Update install.php * Update install.php * Update install.php * Update install.php * Update install.php
This commit is contained in:
parent
1e3e58aeed
commit
b1b8c23d93
3 changed files with 52 additions and 17 deletions
57
install.php
57
install.php
|
@ -297,26 +297,43 @@ if (!empty($DB_HOST) && !empty($DB_DATABASE) && !empty($DB_USERNAME)) {
|
|||
|
||||
// Autofill host in robots.txt
|
||||
$robots_txt_file = BB_ROOT . 'robots.txt';
|
||||
if (isset($TP_HOST) && is_file($robots_txt_file)) {
|
||||
if (isset($TP_HOST) && is_file($robots_txt_file) && is_writable($robots_txt_file)) {
|
||||
$content = file_get_contents($robots_txt_file);
|
||||
$content = str_replace('example.com', $TP_HOST, $content);
|
||||
file_put_contents($robots_txt_file, $content);
|
||||
}
|
||||
|
||||
if (isset($APP_ENV) && $APP_ENV === 'local') {
|
||||
if (!is_file(BB_ROOT . 'library/config.local.php')) {
|
||||
if (copy(BB_ROOT . 'library/config.php', BB_ROOT . 'library/config.local.php')) {
|
||||
out('- Local configuration file created!', 'success');
|
||||
// Suggest configuration files based on selected web server
|
||||
out("--- Web Server configuration ---\n", 'info');
|
||||
echo "Which web server are you using? (nginx / caddy / apache): ";
|
||||
$webserver = mb_strtolower(trim(readline()));
|
||||
$install_dir = 'install' . DIRECTORY_SEPARATOR;
|
||||
|
||||
switch ($webserver) {
|
||||
case 'nginx':
|
||||
$config_path = BB_ROOT . $install_dir . 'nginx.conf';
|
||||
if (is_file($config_path)) {
|
||||
out("- Nginx configuration file: $config_path", 'success');
|
||||
} else {
|
||||
out('- Cannot create library/config.local.php file. You can create it manually, just copy config.php and rename it to config.local.php', 'warning');
|
||||
}
|
||||
out("- Nginx config not found: $config_path", 'warning');
|
||||
out('- You can find an example in the documentation', 'info');
|
||||
}
|
||||
break;
|
||||
|
||||
case 'caddy':
|
||||
$config_path = BB_ROOT . $install_dir . 'Caddyfile';
|
||||
if (is_file($config_path)) {
|
||||
out("- Caddy configuration file: $config_path", 'success');
|
||||
} else {
|
||||
if (rename(__FILE__, __FILE__ . '_' . hash('xxh128', time()))) {
|
||||
out("- Installation file renamed!", 'success');
|
||||
} else {
|
||||
out('- Cannot rename installation file (' . __FILE__ . '). Please, rename it manually for security reasons', 'warning');
|
||||
out("- Caddy config not found: $config_path", 'warning');
|
||||
out('- You can find an example in the documentation', 'info');
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (in_array($webserver, ['nginx', 'caddy'])) {
|
||||
out("- Note: These configuration files include settings specific to TorrentPier,\nsuch as URL rewriting, security headers, and PHP handling", 'info');
|
||||
out('- Adapt them to your environment and web server setup', 'info');
|
||||
sleep(3);
|
||||
}
|
||||
|
||||
// Cleanup...
|
||||
|
@ -337,5 +354,23 @@ if (!empty($DB_HOST) && !empty($DB_DATABASE) && !empty($DB_USERNAME)) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isset($APP_ENV) && $APP_ENV === 'local') {
|
||||
if (!is_file(BB_ROOT . 'library/config.local.php')) {
|
||||
echo "\n";
|
||||
if (copy(BB_ROOT . 'library/config.php', BB_ROOT . 'library/config.local.php')) {
|
||||
out('- Local configuration file created!', 'success');
|
||||
} else {
|
||||
out('- Cannot create library/config.local.php file. You can create it manually, just copy config.php and rename it to config.local.php', 'warning');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo "\n";
|
||||
if (rename(__FILE__, __FILE__ . '_' . hash('xxh128', time()))) {
|
||||
out("- Installation file renamed!", 'success');
|
||||
} else {
|
||||
out('- Cannot rename installation file (' . __FILE__ . '). Please, rename it manually for security reasons', 'warning');
|
||||
}
|
||||
}
|
||||
|
||||
out("\n- Voila! Good luck & have fun!", 'success');
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# Example Caddy configuration for TorrentPier
|
||||
|
||||
example.com {
|
||||
root * /path/to/root
|
||||
root * /path/to/www
|
||||
encode gzip zstd
|
||||
php_fastcgi unix//run/php/php-fpm.sock
|
||||
try_files {path} {path}/ /index.php?{query}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
# Example nginx configuration for TorrentPier
|
||||
|
||||
server {
|
||||
listen 80; # port
|
||||
server_name example.com; # your domain
|
||||
root /path/to/root; # folder with TorrentPier installed
|
||||
listen 80;
|
||||
server_name example.com;
|
||||
root /path/to/www;
|
||||
index index.php;
|
||||
charset utf-8;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue