VestaCP + nginx + nginx-push-stream-module
Понадобилось мне тут для битрикса поставить этот модуль nginx. Скудность информации на форуме битрикса поразила, как будто попал на очередное компьюнити drupal. Все решения у них сводились к “поставь настроенную виртуалку” или фееричное “не поддерживаем вражескую платформу VestaCP”. Пришлось курить мануалы самому.
Мое окружение: CentOS 6.8, Vesta 0.9.8–16
Перед началом всех работ настоятельно прошу делать бекапы сервака. У каждой системы есть свои особенности, так что бездумно копировать команды не получится.
При установке nginx штатными средствами ОС в Linux (yum) нет возможности сконфигурировать его установку, чтобы добавить или убрать какие-либо модули и nginx устанавливается “как есть”.
Что же делать, если нам необходимо добавить какой-либо модуль? Правильно, нужно пересобрать nginx вручную… Поэтому начнем с команды nginx -V
nginx version: nginx/1.10.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --add-dynamic-module=njs-1c50334fbea6/nginx --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
Сохраним вывод команды nginx -V в какой-нибудь текстовый редактор — эта информация нам пригодится при конфигурировании. Видим, что версия nginx у нас установлена 1.10.1 — скачиваем такую же версию:
# cd /
# wget http://nginx.org/download/nginx-1.10.1.tar.gz
# tar –xvf nginx-1.10.1.tar.gz
Далее, для сборки, нам потребуется установить в систему дополнительные пакеты.
# yum install gcc gcc-c++ kernel-devel
# yum groupinstall 'Development Tools'
# yum install pcre-devel openssl-devel GeoIP-devel libxslt-devel
# yum install gd-devel perl-ExtUtils-Embed
С базовом минимумом разобрались. Теперь необходимо уже скачать сам nginx-push-stream-module и ngx_pagespeed, который почему-то после сборки весты потерялся.
# wget https://github.com/wandenberg/nginx-push-stream-module/archive/0.4.1.tar.gz
# wget http://hg.nginx.org/njs/archive/1c50334fbea6.zip
# tar –xvf 0.4.1.tar.gz
# unzip 1c50334fbea6.zip
# mv nginx-push-stream-module-0.4.1 nginx-push-stream-module
# NGINX_PUSH_STREAM_MODULE_PATH=$PWD/nginx-push-stream-module
Мне для битрикса нужен был именно 0.4.1, другие версии смотрите на гитхабе
Для сборки nginx все готово. Теперь остается сконфигурировать команду и запустить компиляцию.
В начале статьи мы копировали nginx -V в блокнот, теперь из той информации мы сделаем команду.
Копируем начиная с — prefix=
Было :
--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --add-dynamic-module=njs-1c50334fbea6/nginx --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'
Сконфигурировали команду дописав нужное (выделено жирным):
./configure --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_perl_module=dynamic --add-dynamic-module=/njs-1c50334fbea6/nginx --with-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --add-module=../nginx-push-stream-module
Теперь остается только зайти в папку nginx и запустить ее.
Если мы получаем ошибки потипу
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
То устанавливаем модуль, который он требует, но я вроде все перечислил.
В конце мы должы получить следующую информацию
nginx path prefix: "/etc/nginx"
nginx binary file: "/usr/sbin/nginx"
nginx modules path: "/usr/lib64/nginx/modules"
nginx configuration prefix: "/etc/nginx"
nginx configuration file: "/etc/nginx/nginx.conf"
**** и так далее
Теперь можно собрать бинарник nginx — выполняем 2 команды:
# make
# make install
Все. Радуемся nginx -V, в котором установлен наш новый модуль.