NGINXV180 Installation and Configuration

Source: Internet
Author: User
Tags install openssl
First, install the relevant support library:
Yum-y Install gcc gcc-c++ autoconf
Yum-y Install OpenSSL Openssl-devel

Pcre: In order to rewrite rewrite, zlib: For gzip compression, Ngx_pagespeed plug-in: Front Page access speed optimization plugin
(1) Pcre Installation:
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
TAR-ZXVF pcre-8.36.tar.gz
CD pcre-8.36
./configure
Make && make install
Cd.. /

Ln-s/usr/local/lib/libpcre.so.1/lib64/

(2) Zlib installation:
wget http://zlib.net/zlib-1.2.8.tar.gz
TAR-ZXVF zlib-1.2.8.tar.gz
CD zlib-1.2.8
./configure
Make && make install
Cd.. /

(3) OpenSSL installation:
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
TAR-ZXVF openssl-1.0.1c.tar.gz
CD openssl-1.0.1c
./config
Make && make install
Cd.. /

(4) Pagespeed installation:
wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.8.31.4-beta.tar.gz
wget https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz
TAR-ZXVF v1.8.31.4-beta.tar.gz
CP 1.8.31.4.tar.gz./ngx_pagespeed-1.8.31.4-beta
CD Ngx_pagespeed-1.8.31.4-beta
TAR-XZVF 1.8.31.4.tar.gz

Second, Nginx installation
To create a dedicated user and user group:
/usr/sbin/groupadd www
/usr/sbin/useradd-g www www
Ulimit-shn 65535

wget http://nginx.org/download/nginx-1.8.0.tar.gz
TAR-ZXVF nginx-1.8.0.tar.gz
CD nginx-1.8.0
./configure–user=www \
–prefix=/usr/local/nginx \
–with-http_ssl_module \
–with-http_stub_status_module \
–with-http_realip_module \
–add-module=/home/yq/ngx_pagespeed-1.8.31.4-beta

Make && make install

Third, the relevant configuration file:
1, nginx.conf

User www www;
Worker_processes 4;

Error_log/var/log/nginx/error.log;

Pid/var/run/nginx.pid;

Events {
Use Epoll;
Worker_connections 1024;
}

HTTP {
Upstream tomcat7{
Server 127.0.0.1:8090;
}
Upstream fdfs{
Server 192.168.77.32:8888;
}
Pagespeed on;
Pagespeed Filecachepath "/var/cache/ngx_pagespeed/";
Pagespeed enablefilters Combine_css,combine_javascript;

include       mime.types;default_type  application/octet-stream;#log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '#                  '$status $body_bytes_sent "$http_referer" '#                  '"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;sendfile        on;#tcp_nopush     on;#keepalive_timeout  0;keepalive_timeout  65;gzip  on;gzip_min_length     1000;gzip_buffers        4 16k;gzip_http_version   1.1;gzip_types  text/plain application/x-javascript text/css application/xml;  include vhost.conf; include vhost/*;

}

VHOST.CONF is the default project, which is a virtual machine configuration,
server {
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;    error_page   500 502 503 504  /50x.html;    location = /50x.html {        root   html;    }}

The following is a typical virtual machine configuration:
Test.conf
server {
Listen 80;
server_name test.qq.cn;

#charset koi8-r;#access_log  logs/host.access.log  main;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header  Host $host;proxy_set_header  X-Real-IP $remote_addr;proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;proxy_connect_timeout 30;proxy_read_timeout 60;proxy_buffer_size 4k;proxy_buffers 4 32k;proxy_busy_buffers_size 64k;proxy_temp_file_write_size 64k;proxy_max_temp_file_size 128m;proxy_set_header Host $host;proxy_pass_header User-Agent;  location / {proxy_pass   http://tomcat7;}location /assets {        root html;index index.html;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {    root   html;}

}

The above describes the NginxV180 installation and configuration, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.