博客
关于我
Nginx-more
阅读量:563 次
发布时间:2019-03-08

本文共 4395 字,大约阅读时间需要 14 分钟。

Synopsis

Nginx-more 是一个基于 Nginx 的构建版本,集成了额外的模块,如 HTTP2、PageSpeed、Brotli、More Headers、Cache Purge、VTS、GeoIP2 和 Echo。它使用最新的 GCC 版本和 OpenSSL 源码进行编译,并包含内置的 WordPress 和 Laravel php-fpm 设置。关于此包更多信息请参考相关文档,尽管本文可能存在一定的过时性,但 Nginx-more 已经从 2014 年起支持,并且在数百台服务器上得到了应用。

Easy installation for CentOS

对于 CentOS 6、7 和 8,有对应的包可用。最简单的安装方法是通过 Aeris Network yum 仓库:

CentOS 6 > yum install -y https://repo.aerisnetwork.com/pub/aeris-release-6.rpm CentOS 7 > yum install -y https://repo.aerisnetwork.com/pub/aeris-release-7.rpm CentOS 8 > dnf install -y https://repo.aerisnetwork.com/pub/aeris-release-8.rpm

安装完成后,运行:

yum install nginx-more

所有配置文件会安装在默认目录 `/etc/nginx/` 中。包中包含了针对 WordPress、Laravel、Drupal、OpenCart、PrestaShop 和 Sendy 的 PHP-FPM 配置文件,位于 `/etc/nginx/conf.d/custom/`,因此你可以在几秒钟内启动网站 hosting。

以下是一个清晰的 WordPress 服务器配置示例:

server {     listen 80;     listen 443 ssl http2;     server_name example.com;     root /home/www/example.com/public_html;     access_log /var/log/nginx/example.com-access_log main;     error_log /var/log/nginx/example.com-error_log warn;     if ($bad_bot) { return 444; }     include conf.d/custom/ssl.global.conf;     include conf.d/custom/restrictions.conf;     include conf.d/custom/pagespeed.conf;     include conf.d/custom/fpm-wordpress.conf; }

如果你升级到最新版本并遇到问题,可以通过 yum 下降版本来解决:

yum downgrade nginx-more

注意,你无法在系统上同时安装 nginx 和 nginx-more,因为它们都提供了 Nginx 二进制和配置文件。你需要选择使用 nginx-more 或者系统提供的 Nginx。Nginx-more 使用了更 recent 的 GCC 版本,并提供了大量就绪的 WordPress 和 Laravel 配置。如果 Nginx 已经安装,可以通过以下命令轻松切换:

yum swap nginx nginx-more

完整的 Nginx 配置信息:

nginx -V nginx version: nginx/1.18.0 custom build maintained on github.com/karljohns0n/nginx-more built by gcc 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC) built with OpenSSL 1.1.1g  21 Apr 2020 TLS SNI support enabled configure arguments: --prefix=/usr/share/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 --http-client-body-temp-path=/var/lib/nginx/cache/client_body --http-proxy-temp-path=/var/lib/nginx/cache/proxy --http-fastcgi-temp-path=/var/lib/nginx/cache/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/cache/uwsgi --http-scgi-temp-path=/var/lib/nginx/cache/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --user=nginx --group=nginx --with-compat --with-file-aio --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_image_filter_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_geoip_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-threads --with-stream --with-stream_ssl_module --with-stream_realip_module --with-http_slice_module --with-stream_ssl_preread_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -DTCP_FASTOPEN=23' --with-cc=/opt/rh/devtoolset-8/root/usr/bin/gcc --with-openssl=modules/openssl-1.1.1g --with-http_v2_hpack_enc --add-dynamic-module=modules/ngx_modsecurity-1.0.1 --add-module=modules/ngx_headers_more-0.33 --add-module=modules/ngx_cache_purge-2.3 --add-module=modules/ngx_module_vts-0.1.18 --add-module=modules/ngx_pagespeed-1.13.35.2-stable --add-module=modules/ngx_brotli-snap20200506 --add-module=modules/ngx_http_geoip2_module-3.3 --add-module=modules/ngx_echo-0.61

Modules

  • (dynamic)

Patches

SELinux

第三方模块如 PageSpeed 会导致 SELinux 检查失败。为了使 Nginx-more 与 SELinux 一起正常工作,需要至少启用 httpd_execmem 政策:

yum -y install policycoreutils && setsebool -P httpd_execmem 1 > systemctl start nginx

如果需要快速启动,可以临时禁用 SELinux:

semanage permissive -a httpd_t

以下是两个外部博客链接,帮助你 troubleshoot Nginx 与 SELinux 相关问题:

Ansible playbook

一个简单的 Ansible playbooks 可用于在 CentOS 上安装并保持 Nginx-more 更新。

示例 playbooks:

- hosts: servers   roles:     - { role: karljohns0n.nginx-more }

Changelog

所有包的 changelog 可以在 RepoView 中查看:

Package dependencies

截至撰写,仅需要一个外部 CentOS 默认仓库中的包来构建 Nginx-more RPM,即 GeoIP2 模块。建议在 mock 配置中添加 Aeris 仓库,以确保所有依赖项可用。我们尽量避免依赖未在 CentOS 中可用的包,如果有需要,我们会在 Aeris 仓库中添加并构建它们,因此无需其他第三方仓库。

转载地址:http://isjiz.baihongyu.com/

你可能感兴趣的文章
MySQL 中随机抽样:order by rand limit 的替代方案
查看>>
MySQL 为什么需要两阶段提交?
查看>>
mysql 为某个字段的值加前缀、去掉前缀
查看>>
mysql 主从
查看>>
mysql 主从 lock_mysql 主从同步权限mysql 行锁的实现
查看>>
mysql 主从互备份_mysql互为主从实战设置详解及自动化备份(Centos7.2)
查看>>
mysql 主从关系切换
查看>>
MYSQL 主从同步文档的大坑
查看>>
mysql 主键重复则覆盖_数据库主键不能重复
查看>>
Mysql 事务知识点与优化建议
查看>>
Mysql 优化 or
查看>>
mysql 优化器 key_mysql – 选择*和查询优化器
查看>>
MySQL 优化:Explain 执行计划详解
查看>>
Mysql 会导致锁表的语法
查看>>
mysql 使用sql文件恢复数据库
查看>>
mysql 修改默认字符集为utf8
查看>>
Mysql 共享锁
查看>>
MySQL 内核深度优化
查看>>
mysql 内连接、自然连接、外连接的区别
查看>>
mysql 写入慢优化
查看>>