CentOS7 nginx 最簡單的安裝以及設置開機啓動

1. 下載tar包.javascript

2. 解壓縮tar包css

3. 安裝必須的部分 yum包html

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

4. configure 以及 make 和 make installjava

默認安裝目錄linux

/usr/local/nginx/sbin/nginx

5. 設置方向代理 最簡單的部分nginx

 

    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;
        }

完整的conf文件vim

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. 設置開機啓動app

vim /etc/rc.d/rc.local

增長內容

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

注意 -c 以後的 文件..  須要肯定.

 7. 今天在linux上面設置的spa

相關文章
相關標籤/搜索