Nginx单机部署

   1、nginx单机部署(参考:https://www.runoob.com/linux/nginx-install-setup.html):

安装到如下图所示,不要采用菜鸟nginx的配置,另外在安装前请先关闭防火墙

2、nginx配置

 2-1、nginx 配置如下。

 

user  root;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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


    access_log on;
    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;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
            access_log  logs/start.log  main;
        }


        location /static {
            alias  /web/;
            #index  1.html ;
            expires 1d;
           access_log  logs/static.log  main;

关于access_log文件,必须在指定目录下创建权限为777文件,否则有机率产生nginx403问题。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章