【问题标题】:Unable to connect ,can’t establish a connection to the server无法连接,无法与服务器建立连接
【发布时间】:2020-04-06 18:38:30
【问题描述】:

我知道这个问题已经被问了很多次了,不幸的是,在我的场景中,我似乎不知道问题出在哪里。

使用带有这些配置的 nginx 设置站点后 '

server {
listen 80;
listen [::]:80;
server_name  xxxxxx.xxxxxxx.co.zw;
root   /var/www/xxxxxx;
index  index.php;

access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;

client_max_body_size 100M;

autoindex off;

location / {
    try_files $uri $uri/ /index.php$is_args$args;
}

location ~ \.php$ {
     include snippets/fastcgi-php.conf;
     fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     include fastcgi_params;
}
}'

公共(lavarel站点)的.htacess文件有这些配置'

  <IfModule mod_rewrite.c>
  <IfModule mod_negotiation.c>
       Options -MultiViews
  </IfModule>

  RewriteEngine On

  # Redirect Trailing Slashes...
  RewriteRule ^(.*)/$ /$1 [L,R=301]

  # Handle Front Controller...
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [L]
  </IfModule>'

我得到的错误是“无法检索请求的 URL。无法连接到远程服务器”。当我尝试在 localhost 上运行它时,它仍然出现同样的错误。

我尝试运行这些命令,但效果不佳'

  sudo a2enmod rewrite
  sudo a2ensite xxxxxx.conf
  sudo systemctl restart nginx'

错误日志是空白的,这里是访问日志'

127.0.0.1 - - [13/Dec/2019:08:00:46 +0000] "GET / HTTP/1.1" 200              396 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
127.0.0.1 - - [13/Dec/2019:08:00:47 +0000] "GET /favicon.ico HTTP/1.1" 404 134 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
127.0.0.1 - - [13/Dec/2019:08:16:36 +0000] "GET /phpinfo.php  HTTP/1.1" 200       21 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101     Firefox/71.0"
127.0.0.1 - - [13/Dec/2019:08:17:43 +0000] "GET / HTTP/1.1" 304 0 "-"     "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"'

请帮忙。

【问题讨论】:

  • 你能检查一下 ngix 服务器错误日志吗?如果在这里找到。

标签: php nginx http-status-code-404 ubuntu-server


【解决方案1】:

请查看 nginx 的 access.log 和 error.log 来调试这个问题。

【讨论】:

    猜你喜欢
    • 2012-10-17
    • 1970-01-01
    • 1970-01-01
    • 2019-06-21
    • 2021-07-18
    • 2018-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多