无法连接,无法建立与服务器的连接

时间:2019-12-13 10:14:14

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

我知道这个问题已经问过很多次了,不幸的是,在我的情况下,我似乎找不到问题所在。

使用具有以下配置的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"'

请帮助。

1 个答案:

答案 0 :(得分:0)

请检查nginx的access.log和error.log以调试此问题。