From 93bdf0fac41fa3e43f65e699b520c442f6943c2a Mon Sep 17 00:00:00 2001 From: Babak Alizadeh Date: Sun, 17 Aug 2025 15:39:47 +0000 Subject: [PATCH] increase timeout of apache and php in installation script --- install.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/install.sh b/install.sh index 8bf843b..de82f7c 100644 --- a/install.sh +++ b/install.sh @@ -341,6 +341,39 @@ install_php() { # Enable PHP module for Apache a2enmod php8.3 || a2enmod php8.2 || a2enmod php8.1 || a2enmod php8.0 || a2enmod php7.4 || log_message "WARNING" "Failed to enable PHP module" + # Configure PHP settings for better performance and timeout + log_message "INFO" "Configuring PHP settings..." + local php_ini_files=() + + # Find all PHP INI files + for version_dir in /etc/php/*; do + if [[ -d "$version_dir" && "$version_dir" =~ /etc/php/[0-9]+\.[0-9]+$ ]]; then + local version=$(basename "$version_dir") + if [[ -f "$version_dir/apache2/php.ini" ]]; then + php_ini_files+=("$version_dir/apache2/php.ini") + fi + if [[ -f "$version_dir/cli/php.ini" ]]; then + php_ini_files+=("$version_dir/cli/php.ini") + fi + fi + done + + # Configure each PHP INI file with basic settings (timeout will be set per domain) + for ini_file in "${php_ini_files[@]}"; do + log_message "INFO" "Configuring $ini_file..." + + # Backup original file + cp "$ini_file" "${ini_file}.backup.$(date +%Y%m%d_%H%M%S)" + + # Set basic PHP settings (timeout will be configured per domain) + sed -i 's/^;*memory_limit = .*/memory_limit = 512M/' "$ini_file" + sed -i 's/^;*post_max_size = .*/post_max_size = 100M/' "$ini_file" + sed -i 's/^;*upload_max_filesize = .*/upload_max_filesize = 100M/' "$ini_file" + sed -i 's/^;*max_input_vars = .*/max_input_vars = 3000/' "$ini_file" + + log_message "INFO" "Updated $ini_file with basic settings" + done + # Restart Apache systemctl restart apache2 || log_message "WARNING" "Failed to restart Apache" @@ -419,10 +452,27 @@ install_apache() { log_message "INFO" "Apache installed successfully" fi + # Configure Apache basic settings + log_message "INFO" "Configuring Apache basic settings..." + + # Backup original apache2.conf + cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.backup.$(date +%Y%m%d_%H%M%S) + + # Add basic performance settings to apache2.conf + cat >> /etc/apache2/apache2.conf << EOF + +# Hesabix basic performance settings +KeepAlive On +KeepAliveTimeout 15 +MaxKeepAliveRequests 100 +EOF + # Verify Apache service if ! systemctl is-active --quiet apache2; then handle_error "Apache service is not running" fi + + log_message "INFO" "Apache basic settings configured" } # Function to install Composer @@ -631,10 +681,22 @@ setup_domain() { ServerAlias www.$domain DocumentRoot $domain_path + # Hesabix timeout settings for this domain + Timeout 900 + ProxyTimeout 900 + Options Indexes FollowSymLinks AllowOverride All Require all granted + + # PHP settings for this directory + php_value max_execution_time 900 + php_value max_input_time 900 + php_value memory_limit 512M + php_value post_max_size 100M + php_value upload_max_filesize 100M + php_value max_input_vars 3000 ErrorLog \${APACHE_LOG_DIR}/$domain-error.log