web - Comment lier un nom de domaine avec Nginx?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-05-16 17:24:25
0
3
769

rt, une recherche sur Internet a montré comment utiliser plusieurs noms de domaine, mais après l'avoir essayé avec l'idée de l'essayer, j'ai découvert que cela ne fonctionnait pas. . . Je voudrais demander comment écrire le fichier de configuration. .

曾经蜡笔没有小新
曾经蜡笔没有小新

répondre à tous(3)
習慣沉默

Son fichier de configuration est clair. Changez-le simplement en conséquence
Remplacez simplement localhost par votre propre nom de domaine dans server_name.

PHPzhong

Fichier de configuration principal

user  huangyanxiong;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/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  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

Fichiers de configuration d'hébergement Web inclus

log_format  compression   '$remote_addr - $remote_user [$time_local] '
                       '"$request" $status $bytes_sent '
                       '"$http_referer" "$http_user_agent" "$gzip_ratio"';
#access_log  /var/log/nginx/log/studyphome.access.log  compression  buffer=32k;

server {
    listen       80;
    server_name  www.mylaravel.com

    charset utf-8;
    #log_format  compression   '$remote_addr - $remote_user [$time_local] '
    #                   '"$request" $status $bytes_sent '
    #                   '"$http_referer" "$http_user_agent" "$gzip_ratio"';
    access_log  /var/log/nginx/log/www.mylaravel.access.log  compression  buffer=32k;
    error_log   /var/log/nginx/log/www.mylaravel.error.log;
    root        /home/huangyanxiong/www/laravel/public;

    location / {
        #root   /var/www/html;
        try_files $uri $uri/ /index.php?$query_string;
        index  index.html index.htm index.php;
    }

    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   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1:8080;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ .php$ {
        #root           html;
        fastcgi_pass   127.0.0.1:9090;
        fastcgi_index  index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

   location ~ ^/(images|javascript|js|css|flash|media|static)/ {
   #过期30天,静态文件不怎么更新,过期可以设大一点,
   #如果频繁更新,则可以设置得小一点。
                 expires 30d;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }
}

仅有的幸福

Pourquoi je pense que la résolution de votre nom de domaine n'a pas ajouté l'enregistrement correspondant ?

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!