Procházet zdrojové kódy

Fix apache install

Ernesto Nicolás Carrea před 5 roky
rodič
revize
59ae9e9419

+ 9 - 8
bin/module/apache/install.inc

@@ -29,10 +29,11 @@ hestia_module_apache_install() {
     cp -f $HESTIA_INSTALL_DIR/$OSAL_PKG_APACHE/${OSAL_PKG_APACHE}.conf $OSAL_PATH_APACHE_CONF/
     cp -f $HESTIA_INSTALL_DIR/logrotate/${OSAL_PKG_APACHE} $OSAL_PATH_LOGROTATE_CONF_D/
 
+    echo "# Powered by Hestia" > $OSAL_PATH_APACHE_CONF/ports.conf
+
     if [ "$OS_BASE" = 'debian' ]; then
         echo "# Powered by Hestia" > $OSAL_PATH_APACHE_CONF/sites-available/default
         echo "# Powered by Hestia" > $OSAL_PATH_APACHE_CONF/sites-available/default-ssl
-        echo "# Powered by Hestia" > $OSAL_PATH_APACHE_CONF/ports.conf
         echo -e "/home\npublic_html/cgi-bin" > /etc/apache2/suexec/www-data
 
         # Copy configuration files
@@ -51,6 +52,13 @@ hestia_module_apache_install() {
         # Copy configuration files
         cp -f $HESTIA_INSTALL_DIR/$OSAL_PKG_APACHE/status.conf $OSAL_PATH_APACHE_CONF_D/hestia-status.conf
         osal_apache_module_enable status > /dev/null 2>&1
+
+        # Delete CentOS style apache logs if present (Hestia will use error.log and access.log)
+        [ -f /var/log/$OSAL_PKG_APACHE/access_log ] && rm /var/log/$OSAL_PKG_APACHE/access_log
+        [ -f /var/log/$OSAL_PKG_APACHE/error_log ] && rm /var/log/$OSAL_PKG_APACHE/error_log
+
+        # Mitigation for some Debian-only scripts
+        ln -s /etc/httpd/conf.modules.d/ /etc/httpd/mods-enabled
     fi
 
     touch /var/log/$OSAL_PKG_APACHE/access.log /var/log/$OSAL_PKG_APACHE/error.log
@@ -59,13 +67,6 @@ hestia_module_apache_install() {
     chmod 640 /var/log/$OSAL_PKG_APACHE/access.log /var/log/$OSAL_PKG_APACHE/error.log
     chmod 751 /var/log/$OSAL_PKG_APACHE/domains
 
-    # Delete CentOS style apache logs if present (Hestia will use error.log and access.log)
-    [ -f /var/log/$OSAL_PKG_APACHE/access_log ] && rm /var/log/$OSAL_PKG_APACHE/access_log
-    [ -f /var/log/$OSAL_PKG_APACHE/error_log ] && rm /var/log/$OSAL_PKG_APACHE/error_log
-
-    # Mitigation for some Debian-only scripts
-    ln -s /etc/httpd/conf.modules.d /etc/httpd/mods-enabled
-
     osal_kv_write $HESTIA_CONF_MODULES/apache.conf 'installed' '1'
     osal_kv_write $HESTIA_CONF_MODULES/apache.conf 'description' 'Hestia Apache module'
     osal_kv_write $HESTIA_CONF_MODULES/apache.conf 'enabled' '1'

+ 29 - 27
bin/module/web/setup.inc

@@ -74,40 +74,42 @@ hestia_module_web_setup() {
 
     osal_kv_write $HESTIA_CONF_MODULES/web.conf 'description' 'Hestia Web module'
 
+    if [ "$apache_installed" ] || [ "$nginx_installed" ] ; then
     $BIN/hestia module web setup-ips
 
     # FIXME: setup PHP support
-    php_variant=$(hestia_module_variant_installed php)
-    if [ "$apache_installed" ]; then
-        # Enable mod_ruid/mpm_itk or mpm_event
-        if [ "$php_variant" = 'php-fpm' ]; then
-            # Disable prefork and php, enable event
-            osal_apache_module_disable php$fpm_v > /dev/null 2>&1
-            osal_apache_module_disable mpm_prefork > /dev/null 2>&1
-            osal_apache_module_enable mpm_event > /dev/null 2>&1
-            cp -f $HESTIA_INSTALL_DIR/apache2/hestia-event.conf /etc/apache2/conf.d/
-        else
-            osal_apache_module_enable ruid2 > /dev/null 2>&1
+        php_variant=$(hestia_module_variant_installed php)
+        if [ "$apache_installed" ]; then
+            # Enable mod_ruid/mpm_itk or mpm_event
+            if [ "$php_variant" = 'php-fpm' ]; then
+                # Disable prefork and php, enable event
+                osal_apache_module_disable php$fpm_v > /dev/null 2>&1
+                osal_apache_module_disable mpm_prefork > /dev/null 2>&1
+                osal_apache_module_enable mpm_event > /dev/null 2>&1
+                cp -f $HESTIA_INSTALL_DIR/apache2/hestia-event.conf /etc/apache2/conf.d/
+            else
+                osal_apache_module_enable ruid2 > /dev/null 2>&1
+            fi
         fi
-    fi
 
-    # Rebuild mail
-    for user in $($HESTIA/bin/v-list-sys-users plain); do
-        echo "Rebuilding web domains for user $user"
-        $BIN/v-rebuild-web-domains $user 'no' > /dev/null 2>&1
-    done
+        # Rebuild domains
+        for user in $($HESTIA/bin/v-list-sys-users plain); do
+            echo "Rebuilding web domains for user $user"
+            $BIN/v-rebuild-web-domains $user 'no' > /dev/null 2>&1
+        done
 
-    osal_service_stop $OSAL_SERVICE_NGINX > /dev/null 2>&1
-    osal_service_stop $OSAL_SERVICE_APACHE > /dev/null 2>&1
+        osal_service_stop $OSAL_SERVICE_NGINX > /dev/null 2>&1
+        osal_service_stop $OSAL_SERVICE_APACHE > /dev/null 2>&1
 
-    if [ "$apache_installed" ]; then
-        osal_service_enable $OSAL_SERVICE_APACHE
-        osal_service_start $OSAL_SERVICE_APACHE
-    fi
+        if [ "$apache_installed" ]; then
+            osal_service_enable $OSAL_SERVICE_APACHE
+            osal_service_start $OSAL_SERVICE_APACHE
+        fi
 
-    if [ "$nginx_installed" ]; then
-        osal_service_enable $OSAL_SERVICE_NGINX
-        osal_service_start $OSAL_SERVICE_NGINX
+        if [ "$nginx_installed" ]; then
+            osal_service_enable $OSAL_SERVICE_NGINX
+            osal_service_start $OSAL_SERVICE_NGINX
+        fi
+        check_result $? "Nginx start failed"
     fi
-    check_result $? "Nginx start failed"
 }

+ 66 - 44
install/rhel/httpd/httpd.conf

@@ -1,59 +1,81 @@
-ServerRoot "/etc/httpd"
-Include conf.modules.d/*.conf
-User apache
-Group apache
-ServerAdmin root@localhost
+#=======================================================================#
+# Hestia Apache configuration file                                      #
+# DO NOT MODIFY THIS FILE! CHANGES WILL BE LOST!                        #
+#=======================================================================#
 
-<Directory />
-    AllowOverride none
-</Directory>
+ServerRoot "/etc/httpd"
+Timeout 30
+KeepAlive Off
+MaxKeepAliveRequests 100
+KeepAliveTimeout 10
 
-DocumentRoot "/var/www/html"
-<Directory "/var/www">
-    AllowOverride None
-    Require all granted
-</Directory>
+<IfModule mpm_prefork_module>
+    StartServers          8
+    MinSpareServers       5
+    MaxSpareServers      20
+    ServerLimit         256
+    MaxClients          200
+    MaxRequestsPerChild 4000
+</IfModule>
 
-<Directory "/var/www/html">
-    Options Indexes FollowSymLinks
-    AllowOverride None
-    Require all granted
-</Directory>
+<IfModule mpm_worker_module>
+    StartServers          2
+    MinSpareThreads      25
+    MaxSpareThreads      75
+    ThreadLimit          64
+    ThreadsPerChild      25
+    MaxClients          200
+    MaxRequestsPerChild 4000
+</IfModule>
 
-DirectoryIndex index.php index.html
+<IfModule mpm_event_module>
+    StartServers          2
+    MinSpareThreads      25
+    MaxSpareThreads      75
+    ThreadLimit          64
+    ThreadsPerChild      25
+    MaxClients          200
+    MaxRequestsPerChild 4000
+</IfModule>
 
-<Files ".ht*">
-    Require all denied
-</Files>
+User apache
+Group apache
 
-ErrorLog "logs/error_log"
-LogLevel warn
+AccessFileName .htaccess
 
-LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
-LogFormat "%h %l %u %t \"%r\" %>s %b" common
-LogFormat "%b" bytes
-CustomLog "logs/access_log" combined
+<Files ~ "^\.ht">
+    Order allow,deny
+    Deny from all
+    Satisfy all
+</Files>
 
 TypesConfig /etc/mime.types
-AddType application/x-compress .Z
-AddType application/x-gzip .gz .tgz
-AddType text/html .shtml
-AddOutputFilter INCLUDES .shtml
-#AddHandler cgi-script .cgi
+DefaultType None
+HostnameLookups Off
 
-AddDefaultCharset UTF-8
+ErrorLog /var/log/httpd/error.log
+LogLevel warn
 
-<IfModule mime_magic_module>
-    MIMEMagicFile conf/magic
-</IfModule>
+# Include module configuration:
+Include conf.modules.d/*.conf
 
-EnableSendfile on
+# Include list of ports to listen on and which to use for name based vhosts
+Include conf/ports.conf
 
-<IfModule remoteip_module>
-    RemoteIPHeader X-Real-IP
-    LogFormat "%a %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
-    LogFormat "%a %l %u %t \"%r\" %>s %b" common
-</IfModule>
+LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
+LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
+LogFormat "%h %l %u %t \"%r\" %>s %O" common
+LogFormat "%{Referer}i -> %U" referer
+LogFormat "%{User-agent}i" agent
+LogFormat "%b" bytes
 
-IncludeOptional conf.d/*.conf
+Include conf.d/*.conf
 IncludeOptional conf.d/domains/*.conf
+
+ErrorDocument 403 /error/403.html
+ErrorDocument 404 /error/404.html
+ErrorDocument 500 /error/50x.html
+ErrorDocument 501 /error/50x.html
+ErrorDocument 502 /error/50x.html
+ErrorDocument 503 /error/50x.html
+ErrorDocument 506 /error/50x.html