nginx 未加载(包括附加主机/*.conf;)不会更改目录?中心 7

nginx isn't loading (include additional-hosts/*.conf;) wont change directory? centos7

我是 Linux 的新手,在设置我的网络服务器时遇到了一些问题...我正在使用 LEMP 与 Varnish 和 phpMyAdmin。服务器是 运行,我可以通过 https 等访问 phpMyAdmin。现在我正在尝试使用 include /directory/*.conf 在另一个目录上设置 Wordpress;但是它似乎没有加载文件。它只会加载 nginx.conf

中设置的默认目录

这是我的 nginx.conf,

user  nginx;
worker_processes  4;

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;

keepalive_timeout  65;

include       /etc/nginx/v-hosts/*.conf;

index   index.php index.html index.htm;

server {
    listen  127.0.0.1:8080;
    root         /usr/share/nginx/html;
    location / {
    }

    error_page  404              /404.html;
    location = /40x.html {
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
    }

location ~ \.php$ {
  root   /usr/share/nginx/html;
  fastcgi_split_path_info  ^(.+\.php)(.*)$;
  fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
  fastcgi_index  index.php;
  fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
  include fastcgi_params;
}
location ~* ^/stolenmx.com/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /srv/www/;
}

location ~ \.php$ {
  root   /usr/share/nginx/html;
  fastcgi_split_path_info  ^(.+\.php)(.*)$;
  fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
  fastcgi_index  index.php;
  fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
  include fastcgi_params;
}
}


server {
listen       443;
client_max_body_size 80M;    

ssl                  on;
ssl_certificate      /etc/nginx/ssl/server.crt;
ssl_certificate_key  /etc/nginx/ssl/server.key;

ssl_session_timeout  5m;

ssl_protocols  SSLv2 SSLv3 TLSv1;
ssl_ciphers  HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers   on;

location / {
root   /usr/share/nginx/html;
index  index.html index.htm;
}
location ~* ^/phpMyAdmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ { root /usr/share/;
}

location ~ \.php$ {
  root   /usr/share/nginx/html;
  fastcgi_split_path_info  ^(.+\.php)(.*)$;
  fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
  fastcgi_index  index.php;
  fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
  include fastcgi_params;
}
}
}

这是我要为 wordpress 加载的文件,

server {
server_name stolenmx.com;
listen 8080;
access_log /var/log/nginx/stolenmx.com-access.log;
error_log /var/log/nginx/stolenmx.com-error.log;
root /srv/www/stolenmx.com;

location / {
    index index.php;
}

# Disable favicon.ico logging
location = /favicon.ico {
    log_not_found off;
    access_log off;
}

# Allow robots and disable logging
location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}

# Enable permalink structures
if (!-e $request_filename) {
    rewrite . /index.php last;
}

# Handle php requests
location ~ \.php$ {
    include /etc/nginx/fastcgi_params;
    fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /srv/www/stolenmx.com$fastcgi_script_name;
}

# Disable static content logging and set cache time to max
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires max;
    log_not_found off;
}

# Deny access to htaccess and htpasswd files
location ~ /\.ht {
    deny  all;
}
}

我已将此文件目录包含在 nginx.conf "include /etc/nginx/v-hosts/*.conf;" 中,但由于某种原因它没有加载它并且不会将 server_name 指向 /srv/www/ ?

有人对它为什么不加载额外内容有任何建议 server.conf 吗?

我可以将 wordpress 安装拖到 /usr/share/nginx/html 中,它可以工作,但我只能拥有一台服务器。我认为这与我的 nginx.conf 有关,但不确定要更改/添加什么?

问候狡猾

在更改可以影响之前,您需要 restart/reload 您的 nginx,在 CentOS 中,它由 运行:

完成
/etc/init.d/nginx restart

(如果你不是 root 使用 sudo)

您要求所有包含的文件都以“.conf”为后缀,请确保您的文件具有此扩展名。最后一件事,您将您的 Wordpress 服务器配置为侦听 8080,您检查过这个端口了吗?