service:apache
Различия
Показаны различия между двумя версиями страницы.
Предыдущая версия справа и слеваПредыдущая версияСледующая версия | Предыдущая версия | ||
service:apache [02.11.2017 08:36] – [Включить HTTP/2] viacheslav | service:apache [30.07.2024 19:21] (текущий) – внешнее изменение 127.0.0.1 | ||
---|---|---|---|
Строка 1: | Строка 1: | ||
+ | ===== Apache ===== | ||
+ | ==== Включить HTTP/2 ==== | ||
+ | [[wp> | ||
+ | <code bash> | ||
+ | # Проверить версию Апача | ||
+ | apache2 -v | ||
+ | # Активировать поддержку HTTP/2 | ||
+ | sudo a2enmod http2 | ||
+ | # Добавить строки в соответствующие конфиги | ||
+ | # (/ | ||
+ | # Для < | ||
+ | Protocols h2c http/1.1 | ||
+ | # Для < | ||
+ | Protocols h2 http/1.1 | ||
+ | # Перезапустить Апач | ||
+ | service apache2 restart | ||
+ | # Перечень загруженных модулей | ||
+ | apachectl -t -D DUMP_MODULES | ||
+ | </ | ||
+ | https:// | ||
+ | |||
+ | Тесты: | ||
+ | https:// | ||
+ | https:// | ||
+ | |||
+ | В Apache 2.4.18 есть баг: | ||
+ | <code bash> | ||
+ | a2enmod http2 | ||
+ | </ | ||
+ | <WRAP round alert 60%> | ||
+ | ERROR: Module http2 does not exist! | ||
+ | </ | ||
+ | |||
+ | Решение: | ||
+ | <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/ | ||
+ | cp debian/ | ||
+ | touch / | ||
+ | echo ' | ||
+ | a2enmod http2 | ||
+ | </ | ||
+ | |||
+ | https:// | ||
+ | |||
+ | === 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. | ||
+ | </ | ||
+ | |||
+ | 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 | ||
+ | </ | ||
+ | https:// | ||
+ | |||
+ | ==== Case-insensitive URIs ==== | ||
+ | Redirect a URI to an all-lowercase version of itself | ||
+ | <code bash> | ||
+ | # Add RewriteMap for redirecting to lowercase URIs | ||
+ | < | ||
+ | RewriteMap lc int:tolower | ||
+ | RewriteRule " | ||
+ | </ | ||
+ | </ | ||
+ | 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, | ||
+ | |||
+ | https:// | ||
+ | |||
+ | mod_speling: | ||
+ | <code bash> | ||
+ | a2enmod speling | ||
+ | |||
+ | nano / | ||
+ | |||
+ | < | ||
+ | CheckSpelling On | ||
+ | CheckCaseOnly On | ||
+ | </ | ||
+ | |||
+ | systemctl restart apache2 | ||
+ | </ | ||
+ | |||
+ | https:// | ||
+ | https:// | ||
+ | |||
+ | ==== Перенаправление ==== | ||
+ | https:// | ||
+ | |||
+ | <file bash / | ||
+ | # Неполный адрес в полный | ||
+ | <If " | ||
+ | Redirect "/" | ||
+ | </If> | ||
+ | </ | ||
+ | |||
+ | В HTML-файле: | ||
+ | <code html> | ||
+ | < | ||
+ | < | ||
+ | <!-- Относительный редирект на URL --> | ||
+ | <meta http-equiv=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | https:// | ||
+ | https:// | ||
+ | |||
+ | ==== OCSP Stapling ==== | ||
+ | <code bash> | ||
+ | # Edit your site’s VirtualHost SSL configuration. | ||
+ | # Add the following line INSIDE the < | ||
+ | SSLUseStapling on | ||
+ | |||
+ | # Add the following line OUTSIDE the < | ||
+ | SSLStaplingCache shmcb:/ | ||
+ | |||
+ | # Check the configuration for errors with the Apache Control service. | ||
+ | Apachectl -t | ||
+ | |||
+ | # Reload the Apache service. | ||
+ | service apache2 reload | ||
+ | </ | ||
+ | |||
+ | https:// | ||
+ | |||
+ | ====== Tomcat ====== | ||
+ | |||
+ | <code yaml> | ||
+ | --- | ||
+ | # Простой запуск в докере | ||
+ | # docker run --rm --name tomcat -p 8080:8080 -v ./ | ||
+ | |||
+ | services: | ||
+ | tomcat: | ||
+ | image: tomcat: | ||
+ | container_name: | ||
+ | ports: | ||
+ | - 8080:8080 | ||
+ | volumes: | ||
+ | - ./ | ||
+ | </ | ||
+ | Доступ к приложению - http:// | ||
+ | |||
+ | https:// | ||
+ | https:// | ||
+ | |||
+ | Показать версию | ||
+ | <code bash> | ||
+ | docker exec -it tomcat bash -c '/ | ||
+ | </ | ||
+ | https:// |