Nginx Combat (i) Openresty installation

Source: Internet
Author: User

Objective

The system environment is the openresty version of the CentOS 7,nginx selection

Compiling openresty Download

wget https://openresty.org/download/openresty-1.13.6.2.tar.gz
Tar zxmf openresty-1.13.6.2.tar.gz

Compile

CD OPENRESTY-1.13.6.2/
Yum-y install gcc gcc-c++ pcre pcre-devel zlib zlib-devel OpenSSL openssl-devel Curl autoconf Automake
./configure
Gamke & Gmake Install

Hint: The above command default compilation parameters:
Parameters parameter Description Detailed Description
--prefix=/usr/local/openresty/nginx installation directory
--with-cc-opt=-o2
--add-module=. /ngx_devel_kit-0.3.0
--add-module=. /echo-nginx-module-0.61 module when debugging location in nginx.conf 79305097
--add-module=. /xss-nginx-module-0.06 Cross-domain AJAX support. Only GET is currently supported.
--add-module=. /ngx_coolkit-0.2rc3
--add-module=. /set-misc-nginx-module-0.32 URI Escape Module http://www.ttlsa.com/nginx/nginx_set-misc-nginx-module-module-description/
--add-module=. /form-input-nginx-module-0.12 Parsing parameters in a POST request Https://www.cnblogs.com/linxiong945/p/4284434.html
--add-module=. /encrypted-session-nginx-module-0.08 http://ju.outofmemory.cn/entry/35811
--add-module=. /srcache-nginx-module-0.31 Page Caching 56480092
--add-module=. /ngx_lua-0.10.13 Lua script
--add-module=. /ngx_lua_upstream-0.07
--add-module=. /headers-more-nginx-module-0.33
--add-module=. /array-var-nginx-module-0.05
--add-module=. /memc-nginx-module-0.19
--add-module=. /redis2-nginx-module-0.15
--add-module=. /redis-nginx-module-0.3.7
--add-module=. /rds-json-nginx-module-0.15
--add-module=. /rds-csv-nginx-module-0.09
--add-module=. /ngx_stream_lua-0.0.5
--with-ld-opt=-wl,-rpath,/usr/local/openresty/luajit/lib
--with-stream
--with-stream_ssl_module
--with-http_ssl_module

Configure can add modules with the following parameters (http://openresty.org/cn/components.html)

Parameters parameter Description Instructions for use
--with-http_iconv_module Enable Ngx_http_iconv_module
--with-http_drizzle_module Enable Ngx_http_drizzle_module
--with-http_postgres_module Enable Ngx_http_postgres_module
--with-luajit Enable and build the bundled Luajit 2.1 (the default)
--with-select_module Enable Select module
--with-poll_module Enable Poll module
--with-threads Enable thread pool support
--with-file-aio Enable file AIO support
--with-ipv6 Enable IPV6 Support
--with-http_v2_module Enable Ngx_http_v2_module
--with-http_realip_module Get the user's real IP 82878257
--with-http_addition_module Enable Ngx_http_addition_module
--with-http_xslt_module Enable Ngx_http_xslt_module
--with-http_xslt_module=dynamic Enable Dynamic Ngx_http_xslt_module
--with-http_image_filter_module Enable Ngx_http_image_filter_module
--with-http_image_filter_module=dynamic
--with-http_geoip_module Enable Ngx_http_geoip_module
--with-http_geoip_module=dynamic Enable Dynamic Ngx_http_geoip_module
--with-http_sub_module Enable Ngx_http_sub_module
--with-http_dav_module Enable Ngx_http_dav_module
--with-http_flv_module Enable Ngx_http_flv_module
--with-http_mp4_module Enable Ngx_http_mp4_module
--with-http_gunzip_module Enable Ngx_http_gunzip_module
--with-http_gzip_static_module Enable Ngx_http_gzip_static_module
--with-http_auth_request_module Enable Ngx_http_auth_request_module
--with-http_random_index_module Enable Ngx_http_random_index_module
--with-http_secure_link_module Enable Ngx_http_secure_link_module
--with-http_degradation_module Enable Ngx_http_degradation_module
--with-http_slice_module Enable Ngx_http_slice_module
--with-http_stub_status_module Enable Ngx_http_stub_status_module
--with-http_perl_module Enable Ngx_http_perl_module
--with-http_perl_module=dynamic Enable Dynamic Ngx_http_perl_module
--with-mail Enable POP3/IMAP4/SMTP proxy Module
--with-mail=dynamic Enable dynamic POP3/IMAP4/SMTP Proxy module
--with-mail_ssl_module Enable Ngx_mail_ssl_module
--with-stream Enable TCP/UDP proxy Module
--with-stream=dynamic Enable dynamic TCP/UDP Proxy module
--with-stream_ssl_module Enable Ngx_stream_ssl_module
--with-stream_realip_module Enable Ngx_stream_realip_module
--with-stream_geoip_module Enable Ngx_stream_geoip_module
--with-stream_geoip_module=dynamic Enable Dynamic Ngx_stream_geoip_module
--with-stream_ssl_preread_module Enable Ngx_stream_ssl_preread_module
--with-google_perftools_module Enable Ngx_google_perftools_module
--with-cpp_test_module Enable Ngx_cpp_test_module
System and Nginx Configuration
Cd/usr/local/openresty/nginx/confcat >/usr/local/openresty/nginx/conf/nginx.conf << Eofworker_processes auto;worker_rlimit_nofile 65535;events {use epoll;worker_connections 65536;multi_accept on; Accept_mutex on;accept_mutex_delay 500ms;} ##--with-stream This module TCP proxy supports stream {include conf.d/*.ream;} HTTP {include mime.types;default_type application/octet-stream;log_format main ' $remote _addr-$remote _user [$tim E_local] "$request"-$upstream _addr "$status $body _bytes_sent" $http _referer "" "$http _user_agent" "$http _x_ Forwarded_for "'; Access_log logs/access.log main;sendfile on;keepalive_timeout 65;charset Utf-8;server_names_has H_bucket_size 256;client_header_buffer_size 32k;large_client_header_buffers 4 128k;   #最大缓存为4个128KBclient_max_body_size 20m;        #允许客户端请求的最大的单个文件字节数sendfile on;      #开启高效文件传输模式tcp_nopush on;     #用于防止网络阻塞tcp_nodelay on;      #用于防止网络阻塞keepalive_timeout 60;   #超过这个时间之后服务器会关闭该连接client_header_timeout 10; #客户端请求头读取超时时间, customers over this timeThe end has not yet sent data Nginx returns 408 error client_body_timeout 10;   #客户端请求主体读取超时时间, more than this time the client has not sent data Nginx returned 408 error server_tokens on;  #不显示nginx版本信息include gzip.conf; #HttpGzip的配置文件include conf.d/*.conf;} Eofmkdir Conf.dcat >default <<    eofserver {listen 80;server_name localhost; #charset koi8-r; #access_log Logs/host.access.log main;location/{root Html;index index.html index.htm;} #error_page 404/404.html;# Redirect Server error pages to the static Page/50x.html#error_page 500 502 50 3 504/50x.html;location =/50x.html {root html;} # Proxy The PHP scripts to Apache listening on 127.0.0.1:80# #location ~ \.php$ {# Proxy_pass http://127.0.0.1;#}# pas s the PHP scripts to FastCGI server listening on 127.0.0.1:9000# #location ~ \.php$ {# root html;# fastcgi_    Pass 127.0.0.1:9000;# fastcgi_index index.php;# fastcgi_param script_filename/scripts$fastcgi_script_name;# Include fastcgi_params;#}# deny access to. htaccess files, if APache ' s document root# concurs with Nginx ' s one# #location ~/\.ht {# deny all;#}}# another virtual host using mix of I  P, name-, and port-based configuration# #server {# Listen 8000;# listen somename:8080;# server_name Somename alias another.alias;# location/{# root html;# index index.html index.htm;#}#}# HTTPS server# #server {# Listen 443 ssl;# server_name localhost;# ssl_certificate cert.pem;# ssl_certific Ate_key cert.key;# ssl_session_cache shared:ssl:1m;# ssl_session_timeout 5m;# ssl_ciphers HIGH:!aNULL:! md5;# ssl_prefer_server_ciphers on;# location/{# root html;# index index.html index.htm;#}#} Eof
Registering System Services
cat >/usr/lib/systemd/system/nginx.service <<EOF[Unit]Description=The OpenResty HTTP and reverse proxy serverAfter=network.target remote-fs.target nss-lookup.target[Service]Type=forkingPIDFile=/usr/local/openresty/nginx/logs/nginx.pid# Nginx will fail to start if /run/nginx.pid already exists but has the wrong# SELinux context. This might happen when running `nginx -t` from the cmdline.# https://bugzilla.redhat.com/show_bug.cgi?id=1268621ExecStartPre=/usr/bin/rm -f /usr/local/openresty/nginx/logs/nginx.pidExecStartPre=/usr/local/openresty/bin/openresty -tExecStart=/usr/local/openresty/bin/openrestyExecReload=/bin/kill -s HUP $MAINPIDKillSignal=SIGQUITTimeoutStopSec=5KillMode=processPrivateTmp=true[Install]WantedBy=multi-user.targetEOF

Systemctl Enable Nginx

Systemctl start Nginx

Nginx Combat (i) Openresty installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.