Инструменты пользователя

Инструменты сайта


service:apache

Различия

Показаны различия между двумя версиями страницы.

Ссылка на это сравнение

Предыдущая версия справа и слеваПредыдущая версия
Следующая версия
Предыдущая версия
service:apache [16.06.2019 06:09] – [Включить HTTP/2] viacheslavservice:apache [30.07.2024 19:21] (текущий) – внешнее изменение 127.0.0.1
Строка 1: Строка 1:
 +===== Apache =====
 +==== Включить HTTP/2 ====
 +[[wp>HTTP/2]] поддерживается Апачем начиная с версии 2.4.17.
 +<code bash>
 +# Проверить версию Апача
 +apache2 -v
 +# Активировать поддержку HTTP/2
 +sudo a2enmod http2
 +# Добавить строки в соответствующие конфиги
 +# (/etc/apache2/sites-enabled, /etc/apache2/sites-available):
 +# Для <VirtualHost *:80> ... </VirtualHost>
 +Protocols h2c http/1.1
 +# Для <VirtualHost *:443> ... </VirtualHost>
 +Protocols h2 http/1.1
 +# Перезапустить Апач
 +service apache2 restart
  
 +# Перечень загруженных модулей
 +apachectl -t -D DUMP_MODULES
 +</code>
 +https://dmitriyilichev.com/perehod-na-http-2-ubuntu-apache/
 +
 +Тесты:\\
 +https://tools.keycdn.com/http2-test\\
 +https://www.dareboost.com/en/website-speed-test-http2-vs-http1
 +
 +В Apache 2.4.18 есть баг:
 +<code bash>
 +a2enmod http2
 +</code>
 +<WRAP round alert 60%>
 +ERROR: Module http2 does not exist!
 +</WRAP>
 +
 +Решение:
 +<code bash>
 +apt-get install libnghttp2-dev
 +mkdir apache2
 +cd apache2
 +apt-get source apache2
 +apt-get build-dep apache2
 +cd apache-2.4.18
 +# apt-get install fakeroot
 +fakeroot debian/rules binary
 +cp debian/apache2-bin/usr/lib/apache2/modules/mod_http2.so /usr/lib/apache2/modules/
 +touch /etc/apache2/mods-available/http2.load
 +echo 'LoadModule http2_module /usr/lib/apache2/modules/mod_http2.so' > /etc/apache2/mods-available/http2.load
 +a2enmod http2
 +</code>
 +
 +https://bugs.launchpad.net/ubuntu/+source/apache2/+bug/1543572
 +
 +=== Apache 2.4.27, HTTP/2 not supported in prefork ===
 +Starting from Apache 2.4.27, the Apache MPM (Multi-Processing Module) prefork no longer supports HTTP/2. This will be indicated in your Apache error log as follows:
 +
 +<WRAP round box 100%>
 +AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
 +</WRAP>
 +
 +To fix this, select a different MPM: event or worker. We highly recommend you to use the event prefork.
 +If you are using PHP, it is likely that PHP is integrated to Apache via the mod_php module, which requires the prefork MPM. If you switch out from preform MPM, you will need to use PHP as FastCGI. To switch to php-fpm, you can do as folllwing. Please note that this assumes you have PHP installed from ondrej/php repository on Ubuntu. The PHP package names could be different in other repositories. Change package name and apt-get commands to match your PHP vendor and package manager.
 +<code bash>
 +apachectl stop
 +apt-get install php7.1-fpm # Install the php-fpm from your PHP repository. This package name depends on the vendor.
 +a2enmod proxy_fcgi setenvif
 +a2enconf php7.1-fpm # Again, this depends on your PHP vendor.
 +a2dismod php7.1 # This disables mod_php.
 +a2dismod mpm_prefork # This disables the prefork MPM. Only one MPM can run at a time.
 +a2enmod mpm_event # Enable event MPM. You could also enable mpm_worker.
 +apachectl start
 +</code>
 +https://http2.pro/doc/Apache
 +
 +==== Case-insensitive URIs ====
 +Redirect a URI to an all-lowercase version of itself
 +<code bash>
 +# Add RewriteMap for redirecting to lowercase URIs
 +<IfModule mod_rewrite.c>
 +RewriteMap lc int:tolower
 +RewriteRule "(.*)" "${lc:$1}" [R]
 +</IfModule>
 +</code>
 +Please note that the example offered here is for illustration purposes only, and is not a recommendation. If you want to make URLs case-insensitive, consider using [[https://httpd.apache.org/docs/trunk/mod/mod_speling.html|mod_speling]] instead.
 +
 +https://httpd.apache.org/docs/trunk/rewrite/rewritemap.html
 +
 +mod_speling:
 +<code bash>
 +a2enmod speling
 +
 +nano /etc/apache2/sites-available/000-default.conf
 +
 +<IfModule mod_speling.c>
 +CheckSpelling On
 +CheckCaseOnly On
 +</IfModule>
 +
 +systemctl restart apache2
 +</code>
 +
 +https://stackoverflow.com/questions/3450032/apache-mod-speling-case-insensitive-urls-issue\\
 +https://support.plesk.com/hc/en-us/articles/360000125574-How-to-avoid-case-sensitive-URLs-
 +
 +==== Перенаправление ====
 +https://httpd.apache.org/docs/2.4/rewrite/remapping.html
 +
 +<file bash /etc/apache2/sites-available/000-default.conf>
 +# Неполный адрес в полный
 +<If "%{HTTP_HOST} != 'wiki.domain.ru'">
 +    Redirect "/" "http://wiki.domain.ru/"
 +</If>
 +</file>
 +
 +В HTML-файле:
 +<code html>
 +<html>
 +        <head>
 +                <!-- Относительный редирект на URL -->
 +                <meta http-equiv="refresh" content="0; url=./zabbix" />
 +        </head>
 +</html>
 +</code>
 +https://stackoverflow.com/questions/37752440/relative-redirect-using-meta-http-equiv-refresh-with-gh-pages\\
 +https://stackoverflow.com/questions/5411538/redirect-from-an-html-page
 +
 +==== OCSP Stapling ====
 +<code bash>
 +# Edit your site’s VirtualHost SSL configuration.
 +# Add the following line INSIDE the <VirtualHost></VirtualHost> block:
 +SSLUseStapling on
 +
 +# Add the following line OUTSIDE the <VirtualHost></VirtualHost> block:
 +SSLStaplingCache shmcb:/tmp/stapling_cache(128000)
 +
 +# Check the configuration for errors with the Apache Control service.
 +Apachectl -t
 +
 +# Reload the Apache service.
 +service apache2 reload
 +</code>
 +
 +https://www.digicert.com/kb/ssl-support/apache-enable-ocsp-stapling-on-server.htm
 +
 +====== Tomcat ======
 +
 +<code yaml>
 +---
 +# Простой запуск в докере
 +# docker run --rm --name tomcat -p 8080:8080 -v ./sample.war:/usr/local/tomcat/webapps/sample.war tomcat:jre11
 +
 +services:
 +  tomcat:
 +    image: tomcat:jre11
 +    container_name: tomcat
 +    ports:
 +      - 8080:8080
 +    volumes:
 +      - ./sample.war:/usr/local/tomcat/webapps/sample.war
 +</code>
 +Доступ к приложению - http://localhost:8080/sample
 +
 +https://hub.docker.com/_/tomcat\\
 +https://tomcat.apache.org/tomcat-10.1-doc/appdev/sample/ (тестовое приложение)
 +
 +Показать версию
 +<code bash>
 +docker exec -it tomcat bash -c '/usr/local/tomcat/bin/version.sh'
 +</code>
 +https://stackoverflow.com/questions/14925073/tomcat-how-to-find-out-running-tomcat-version

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki