博客
关于我
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中varchar类型数字排序不对踩坑记录
查看>>
mysql中出现update-alternatives: 错误: 候选项路径 /etc/mysql/mysql.cnf 不存在 dpkg: 处理软件包 mysql-server-8.0的解决方法(全)
查看>>
MySQL中地理位置数据扩展geometry的使用心得
查看>>
Mysql中存储引擎简介、修改、查询、选择
查看>>
mysql中实现rownum,对结果进行排序
查看>>
mysql中对于数据库的基本操作
查看>>
mysql中的 +号 和 CONCAT(str1,str2,...)
查看>>
MySql中的concat()相关函数
查看>>
mysql中的concat函数,concat_ws函数,concat_group函数之间的区别
查看>>
MySQL中的count函数
查看>>
MySQL中的DB、DBMS、SQL
查看>>
MySQL中的DECIMAL类型:MYSQL_TYPE_DECIMAL与MYSQL_TYPE_NEWDECIMAL详解
查看>>
MySQL中的GROUP_CONCAT()函数详解与实战应用
查看>>
MySQL中的IO问题分析与优化
查看>>
MySQL中的ON DUPLICATE KEY UPDATE详解与应用
查看>>
mysql中的rbs,SharePoint RBS:即使启用了RBS,内容数据库也在不断增长
查看>>
mysql中的undo log、redo log 、binlog大致概要
查看>>
Mysql中的using
查看>>
MySQL中的关键字深入比较:UNION vs UNION ALL
查看>>
MYSQL中频繁的乱码问题终极解决
查看>>