【问题标题】:How to server setup with nginx in ubuntu?如何在 ubuntu 中使用 nginx 进行服务器设置?
【发布时间】:2017-11-22 14:58:11
【问题描述】:

我的域类似于 example.com 和 nginx 文件,如下所示。 所以我的根路径是/var/www/campaignmanager/bannerad/public。

所以我的域在 example.com 之类的浏览器中打开,但我想像 example.com/campaignmanagerwww.example.com/campaignmanager 一样打开它

请帮帮我。

server { 
    listen 80; 
    listen [::]:80;

    root /var/www/campaignmanager/bannerad/public;

    index index.php index.html index.htm;

    server_name exmaple.com www.example.com;

    location / {
      try_files $uri $uri/index.html $uri.html @upstream;
    }

    location @upstream {
     location ~ \.php$ {
       try_files $uri /index.php =404;
       fastcgi_split_path_info ^(.+\.php)(/.+)$;
       fastcgi_pass unix:/run/php/php7.1-fpm.sock;
       fastcgi_index index.php;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       include fastcgi_params;
     }
   }
}

【问题讨论】:

  • 我认为您只需将server_name exmaple.com www.example.com; 更改为server_name exmaple.com www.example.com/campaignmanager; 然后sudo systemctl reload nginx 希望这对您有所帮助!告诉我。
  • 这对你有帮助吗??
  • 这对 Hiren 不起作用。
  • 当我重新启动 nginx 时。得到类似的错误。 nginx.service 的作业失败,因为控制进程以错误代码退出。详见“systemctl status nginx.service”和“journalctl -xe”。
  • 将您的位置路径更新为/sample

标签: laravel ubuntu nginx


【解决方案1】:

您可以结合使用服务器和位置指令。

 server { 
        listen 80; 
        listen [::]:80;

        root /var/www/campaignmanager/bannerad/public;

        index index.php index.html index.htm;

        server_name exmaple.com/sample

        location /sample {
          try_files $uri $uri/index.html $uri.html @upstream;
        }

        location @upstream {
         location ~ \.php$ {
           try_files $uri /index.php =404;
           fastcgi_split_path_info ^(.+\.php)(/.+)$;
           fastcgi_pass unix:/run/php/php7.1-fpm.sock;
           fastcgi_index index.php;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           include fastcgi_params;
         }
       }
    }

请原谅语法错误。 https://www.keycdn.com/support/nginx-location-directive/ http://nginx.org/en/docs/http/server_names.html

【讨论】:

  • 当我重新启动 nginx 时出现类似错误。 nginx.service 的作业失败,因为控制进程以错误代码退出。详见“systemctl status nginx.service”和“journalctl -xe”。
  • @sanjaymokariya 我的错,答案不正确。更新。另请查看此答案stackoverflow.com/questions/19108044/…
猜你喜欢
  • 2021-09-06
  • 1970-01-01
  • 1970-01-01
  • 2021-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-09
  • 1970-01-01
相关资源
最近更新 更多