Установка nginx с модулем pagespeed на Debian

Быстрая установка последней версии nginx(на момент написания статьи была версия 1.17.0) с модулем pagespeed на Debian


Подробная инструкция находится на оф.сайте www.modpagespeed.com, там же есть инструкция для других ОС.


Все приведенные пункты выполняются в консоле с root правами, тестировалось только на Debian 9(stretch).

1. Удаляем, если установлен пакет nginx:

apt-get remove nginx

2. Устанавливаем необходимые для компиляции пакеты:

apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip uuid-dev

3. Собираем nginx из исходников, для этого выполняем команду:

bash <(curl -f -L -sS https://ngxpagespeed.com/install) --nginx-version latest

4. Указываем какие стандартные модули нужно установить, можно оставить пустым и нажать enter:
Установка nginx с модулем pagespeed

Название модулей нужно вводить через пробел, примерный список модулей:

--with-http_addition_module
--with-http_auth_request_module
--with-http_dav_module
--with-http_flv_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_mp4_module
--with-http_random_index_module
--with-http_realip_module
--with-http_secure_link_module
--with-http_slice_module
--with-http_ssl_module
--with-http_stub_status_module
--with-http_sub_module
--with-http_v2_module
--with-mail_ssl_module
--with-stream_realip_module
--with-stream_ssl_module
--with-stream_ssl_preread_module

этот же список одной строй для копирования в консоль:

--with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail_ssl_module --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module

5. Потверждаем установку выбранных модулей, нажимаем Y и enter:
Установка nginx с модулем pagespeed

6. Потверждаем начало компиляции, нажимаем Y и enter:
Установка nginx с модулем pagespeed

7. Копируем испоняемый файл nginx в /user/sbin:

cp /usr/local/nginx/sbin/nginx /usr/sbin/nginx

8. Создаем конфиг для автозапуска /lib/systemd/system/nginx.service:

nano /lib/systemd/system/nginx.service

с содержимым:

[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

устанавливаем права доступа 644:

chmod 644 /lib/systemd/system/nginx.service

9. Выполняем команду:

systemctl unmask nginx.service

10. Редактируем основной конфиг nginx:

nano /etc/nginx/nginx.conf

в секцию html добавляем строки:

pagespeed on;
pagespeed FileCachePath /tmp/ngx_pagespeed_cache;

on или off - включение или выключение pagespeed.
FileCachePath - путь до папки для кешированных файлов, создается автоматически при запуске сервера.

11. Запускаем сервер:

service nginx start

Поделиться:

Счетчики

Регистрация сайта в каталогах, раскрутка и оптимизация сайта, контекстная реклама

Яндекс цитирования

Рейтинг@Mail.ru