日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

一、背景介紹

Nginx (engine x) 是一個高性能的HTTP和反向代理web服務器,同時也提供了IMAP/POP3/SMTP服務。

二、安裝

$ wget http://nginx.org/download/nginx-1.14.2.tar.gz

# 解壓源碼
$ tar -zxvf nginx-1.14.2.tar.gz

# 進入源碼目錄
$ cd nginx-1.14.2

$ ./configure
--prefix=/usr/local/nginx --with-http_ssl_module --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --add-module=/usr/local/src/ModSecurity-nginx

$ make

$ make install

 

四、配置

1)、創建目錄

  • 日志目錄 /www/logs/nginx/
  • 證書目錄 /usr/local/nginx/ssl/

要把證書放入到上訴目錄

2)、主配置文件

user  www www;
worker_processes  8;

pid        /var/run/nginx.pid;


worker_rlimit_nofile 65535;

events {
    worker_connections 65535;
}


http {

    charset utf-8;
    include       mime.types;
    default_type  Application/octet-stream;

    log_format  main escape=json '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" "$request_time" "$request_body" "$host"';



    error_log  logs/nginx_error.log  error;

    #proxy_ignore_client_abort on;
    proxy_buffering off;

    server_names_hash_bucket_size 128;
    client_header_buffer_size 128k;
    large_client_header_buffers 4 128k;
    client_max_body_size 100m;
    client_body_buffer_size 1024k;

    ssl_session_cache   shared:SSL:10m;
    ssl_session_timeout 10m;

    sendfile        on;
    tcp_nopush     on;

    keepalive_timeout  65;
    tcp_nodelay on;

    fastcgi_intercept_errors on;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 128k;
    fastcgi_buffers 4 128k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 128k;

    gzip  on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types       text/plain application/x-JAVAscript text/css application/xml image/jpeg image/gif image/png;
    gzip_vary on;

    server_tokens off;
    proxy_hide_header X-Powered-By;
    proxy_hide_header Server;
    fastcgi_hide_header X-Powered-By;

   include conf.d/*.conf;
}

 

3)、報錯設置

初期調試時,請不要調整到指定的5xx頁面

 

   error_page   500 502 503 504  /50x.html;

 

4)、子域名

server {
    listen 80;
    listen 443 ssl;
    #域名配置
    server_name subdomain.domain.com;
    #根目錄
    root /www/domain/public;
    index index.php index.html;
    # 沒搞明白這里為啥是關閉

    ssl off;
    # 證書
    ssl_certificate /usr/local/nginx/ssl/domain.com.pem;
    ssl_certificate_key /usr/local/nginx/ssl/domain.com.key;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    if ($host !~* ^(.*).domain.com$) {
       return 403;
    }

    # enable HSTS
    #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains;preload" always;

    #if ($scheme = http) {
    #     return 301 https://$host$request_uri;
    #}

    if ($time_iso8601 ~ "^(d{4}-d{2}-d{2})") {
        set $year $1;
        set $month $2;
        set $day $3;
    }

    access_log /www/logs/nginx/domain_access_$year-$month-$day.log main;
    error_log  /www/logs/nginx/domain_error.log error;
# 配置php部分
    location / {
        try_files $uri $uri/ /index.php?$query_string;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    location ~* .php$ {
        fastcgi_index  index.php;
        fastcgi_pass   127.0.0.1:9000;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
    }

    }

五、啟動-停止

 

#啟動
$ /usr/local/nginx/sbin/nginx

#停止
$ /usr/local/nginx/sbin/nginx -s stop

#重啟
$ /usr/local/nginx/sbin/nginx -s reload

 

六、服務管理

需要配置服務管理文件

1)、創建nginx.service

vim /usr/lib/systemd/system/nginx.service

 

2)、設置內容如下

[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/run/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=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true

[Install]
WantedBy=multi-user.target

 

3)、使文件生效

systemctl daemon-reload

 

4)、常用命令

啟動
systemctl start nginx

關閉nginx
systemctl stop nginx

重啟nginx
systemctl restart nginx

5)、開機啟動

systemctl enable nginx

 

7、排錯

1)、端口被占用

[root@zjt-baidu nginx-1.14.2]# /usr/local/nginx/sbin/nginx
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

使用ps axf 看看

[root@zjt-baidu ~]# ps axf | grep nginx
 2969 pts/2    S+     0:00          _ grep --color=auto nginx
 1295 ?        Ss     0:00 nginx: master process /usr/sbin/nginx
 1296 ?        S      0:00  _ nginx: worker process
 1297 ?        S      0:00  _ nginx: worker process

不過這個是不嚴謹的,因為有的時候,會是別的應用程序占用了80的服務端口

那查看端口占用情況

[root@zjt-baidu ~]# netstat -ntlup | grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1295/nginx: master  
tcp6       0      0 :::80                   :::*                    LISTEN      1295/nginx: master  

結束掉相應的進程

2)、配置文件出錯

[root@zjt-baidu ~]# /usr/local/nginx/sbin/nginx -s stop
nginx: [emerg] unexpected "}" in /usr/local/nginx/conf/nginx.conf:149

缺少分號

    #}
 include conf.d/*.conf

}

 

感謝 點贊,收藏,轉發。關注我,了解更多軟件資訊~!

分享到:
標簽:nginx
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定