CentOS7 nginx easiest installation and startup settings

1. Download the tar package.

2. Extract the tar packets

3. The mounting portion must yum package

yum install -y gcc pcre pcre-devel openssl openssl-devel gd gd-devel

4. configure and make and make install

The default installation directory

/usr/local/nginx/sbin/nginx

The simplest arrangement direction proxy portion

 

    gzip on;
    gzip_min_length 1k;
    gzip_buffers 16 64k;
    gzip_http_version 1.1;
    gzip_comp_level 6;
    gzip_types text/plain application/x-javascript application/javascript text/javascript text/css application/xml;
    gzip_vary on;


    server {
        listen       80;
        server_name  localhost;

        location / {
            proxy_pass http://localhost:5001/;
            proxy_set_header Host $host:$server_port;
        }

Complete conf file

worker_processes  1;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  1800;

    gzip on;
    gzip_min_length 1k;
    gzip_buffers 16 64k;
    gzip_http_version 1.1;
    gzip_comp_level 6;
    gzip_types text/plain application/x-javascript application/javascript text/javascript text/css application/xml;
    gzip_vary on;


    server {
        listen       80;
        server_name  localhost;

        location / {
            proxy_pass http://localhost:5000/;
            proxy_set_header Host $host:$server_port;
        }
       error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }

}

6. Set the boot

vim /etc/rc.d/rc.local

add content

/usr/local/nginx/sbin/nginx -c /nginx/nginx-1.15.10/conf/nginx.conf

Note file -c after .. be determined.

 7. Today in linux set above

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/11010572.html