вторник, 1 марта 2016 г.

Установка модуля nginx ngx_pagespeed на CentOS 6

Клиенту с CentOS 6 и ISPmanager 5 понадобилось установить модуль nginx pagespeed.
Краткая заметка по установке:

Установим зависимости, свежий gcc:
# rpm --import https://linux.web.cern.ch/linux/scientific6/docs/repository/cern/slc6X/i386/RPM-GPG-KEY-cern
# wget -O /etc/yum.repos.d/slc6-devtoolset.repo https://linux.web.cern.ch/linux/scientific6/docs/repository/cern/devtoolset/slc6-devtoolset.repo
# yum install devtoolset-2-gcc-c++ devtoolset-2-binutils

# PS_NGX_EXTRA_FLAGS="--with-cc=/opt/rh/devtoolset-2/root/usr/bin/gcc"



# yum install gcc-c++ pcre-dev pcre-devel zlib-devel make unzip 

Загружаем модуль ngx_pagespeed:
# cd /usr/src/
# NPS_VERSION=1.10.33.5
# wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip -O release-${NPS_VERSION}-beta.zip
# unzip release-1.10.33.5-beta.zip
# cd ngx_pagespeed-release-1.10.33.5-beta/
# wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
# tar -xzvf ${NPS_VERSION}.tar.gz

Загружаем исходники nginx:
# NGINX_VERSION=1.8.1
# wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz
# tar -xvzf nginx-${NGINX_VERSION}.tar.gz
# cd nginx-${NGINX_VERSION}/

Смотрим конфигурацию уже установленного nginx в системе:
# nginx -V
nginx version: nginx/1.6.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --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-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g'

Соберем nginx из исходников:
# ./configure __параметры_у_старого_nginx_ --add-module=/usr/src/ngx_pagespeed-release-${NPS_VERSION}-beta ${PS_NGX_EXTRA_FLAGS}
# make
# make install

Проверим, что все ок:
# nginx -V
nginx version: nginx/1.8.1
built by gcc 4.8.2 20140120 (Red Hat 4.8.2-15) (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 --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-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g' --add-module=/usr/src/ngx_pagespeed-release-1.10.33.5-beta --with-cc=/opt/rh/devtoolset-2/root/usr/bin/gcc

Перезапустим nginx:
# service nginx restart

Так же не забудем, защитить пакет от обновления:
# vim /etc/yum.conf 
и добавим строку: exclude=nginx

Полезные ссылки:

1 комментарий: