Configurando o apache2 para mediawiki

2

Para que o mediawiki trabalhe no apache2, é necessário um arquivo /etc/apache2/conf/mediawiki . Onde posso encontrá-lo?

    
por Tommy Pollák 18.06.2016 / 20:58

1 resposta

0

A boa ideia é fazer um Host Virtual dedicado (que irá executar um subdomínio separado) para cada MediaWiki no seu servidor. Os arquivos Apache2 virtualhost.conf estão contidos na pasta /etc/apache2/sites-available/ .

Por exemplo, o arquivo de configuração VH pode ser: /etc/apache2/sites-available/ wiki.example.com.conf e seu conteúdo simples deve ser algo como:

<VirtualHost *:80>

    ServerName wiki.example.com
    ServerAdmin [email protected]

    # Redirect Requests to SSL
    Redirect permanent "/" "https://wiki.example.com/"

    ErrorLog ${APACHE_LOG_DIR}/wiki.example.com.error.log
    CustomLog ${APACHE_LOG_DIR}/wiki.example.com.access.log combined

</VirtualHost>

<IfModule mod_ssl.c>

    <VirtualHost _default_:443>

            ServerName wiki.example.com
            ServerAdmin [email protected]
            DocumentRoot /var/www/wiki.example.com

            # According MWiki Manual:Security
            php_flag register_globals off

            ErrorLog ${APACHE_LOG_DIR}/wiki.example.com.error.log
            CustomLog ${APACHE_LOG_DIR}/wiki.example.com.access.log combined

            SSLEngine on
            SSLCertificateFile /etc/ssl/certs/wiki.example.com.crt
            SSLCertificateKeyFile /etc/ssl/private/wiki.example.com.key
            SSLCertificateChainFile /etc/ssl/certs/wiki.example.com.root-bundle.crt

            <FilesMatch "\.(cgi|shtml|phtml|php)$">
                    SSLOptions +StdEnvVars
            </FilesMatch>

            <Directory /usr/lib/cgi-bin>
                    SSLOptions +StdEnvVars
            </Directory>

            <Directory /var/www/wiki.example.com>
                    Options None FollowSymLinks
                    #Allow .htaccess
                    AllowOverride All
                    Require all granted
                    <IfModule security2_module>
                            SecRuleEngine Off
                            # or disable only problematic rules
                    </IfModule>
            </Directory>

            # According to MWiki Manual:Security
            <Directory /var/www/wiki.example.com/images>
                    # Ignore .htaccess files
                    AllowOverride None
                    # Serve HTML as plaintext, don't execute SHTML
                    AddType text/plain .html .htm .shtml .php .phtml .php5
                    # Don't run arbitrary PHP code.
                    php_admin_flag engine off
                    # If you've other scripting languages, disable them too.
            </Directory>

            #According to MWiki Manual:Security
            <Directory /var/www/wiki.example.com/images/deleted>
                    Deny from all
                    AllowOverride AuthConfig Limit
                    Require local
            </Directory>

    </VirtualHost>

</IfModule>

Observe que este exemplo é para configuração com HTTPS / SSL ativado. Para HTTP puro, ele deve se parecer com:

<VirtualHost *:80>

    ServerName wiki.example.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/wiki.example.com

    # According MWiki Manual:Security
    php_flag register_globals off

    ErrorLog ${APACHE_LOG_DIR}/wiki.example.com.error.log
    CustomLog ${APACHE_LOG_DIR}/wiki.example.com.access.log combined

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
    </FilesMatch>

    <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
    </Directory>

    <Directory /var/www/wiki.example.com>
            Options None FollowSymLinks
            #Allow .htaccess
            AllowOverride All
            Require all granted
            <IfModule security2_module>
                    SecRuleEngine Off
                    # or disable only problematic rules
            </IfModule>
    </Directory>

    # According to MWiki Manual:Security
    <Directory /var/www/wiki.example.com/images>
            # Ignore .htaccess files
            AllowOverride None
            # Serve HTML as plaintext, don't execute SHTML
            AddType text/plain .html .htm .shtml .php .phtml .php5
            # Don't run arbitrary PHP code.
            php_admin_flag engine off
            # If you've other scripting languages, disable them too.
    </Directory>

    #According to MWiki Manual:Security
    <Directory /var/www/wiki.example.com/images/deleted>
            Deny from all
            AllowOverride AuthConfig Limit
            Require local
    </Directory>

</VirtualHost>

Para ativar o VirtyalHost você precisa executar:

$ sudo a2ensite wiki.example.com.conf
$ sudo systemctl restart apache2.service
    
por pa4080 08.01.2017 / 16:11