【问题标题】:deploy laravel on nginx在 Nginx 上部署 laravel
【发布时间】:2022-03-16 23:49:36
【问题描述】:

我的 nginx 和 php 已安装并运行成功。在我的浏览器中输入 URL http://127.0.0.1:8080/ 将显示“欢迎使用 NGINX”页面以及当我运行时

php phpinfo.php

在终端上将显示我的 php.ini 中的所有设置。我尝试运行 MY_SERVER_NAME/phpinfo.php 将继续加载而不显示任何内容。当我尝试使用我在 nginx.conf 中设置的 MY_SERVER_NAME 打开我的网站时,它会继续加载而不显示任何内容。

我的 web.conf 监听 80 端口,原来的 nginx.conf 监听 8080 端口

server{   
    listen 80;
    server_name MY_SERVER_NAME;
    root /...../public;
    index index.php index.html index.htm index.nginx-debian.html;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$ {
        try_files $uri /index.php=404;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
    } 
}

运行 sudo nginx -t 显示语法没问题,测试成功

【问题讨论】:

  • 您的 nginx 服务器监听 80 端口,而您正试图通过 8080 访问它。
  • 8080是我想检查我的nginx是否安装成功的端口,它与我的网站80端口无关
  • 打开你的nginx.conf文件并检查你是否能找到类似include servers/*;这行告诉nginx从servers目录加载所有配置文件。
  • 是的,我的 nginx.conf 中有这个

标签: php nginx fastcgi


【解决方案1】:

这应该可以!

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

    server_name SERVER_NAME; # server name of your choice. 

    root ROOT_DIRECTORY/public; # assumes the index.php is in public folder

    index index.php index.html index.htm index-nginx-debian.html;
    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        try_files $uri /index.php=404;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000; # assumes PHP listens on the port 9000
    } 
}

【讨论】:

  • 仍然没有加载页面
  • 我什至清除了所有缓存并重新启动 nginx 和 php
  • 你所有的cmets都是我的配置文件
  • lsof -i | grep php的输出是什么
  • php-fpm 45930 xm 7u IPv4 0x3e1b762573d49621 0t0 TCP localhost:cslistener (LISTEN) php-fpm 45931 xm 8u IPv4 0x3e1b762573d49621 0t0 TCP localhost:cslistener (LISTEN) php-fpm 45932 xm 8u IPv4 0x3e1b762573d49621 0t0 TCP localhost:cslistener (LISTEN)
【解决方案2】:

我遇到了类似的问题,希望此链接对遇到类似问题的人有所帮助 Install Laravel PHP Framework CentOS 8 with NGINX

【讨论】:

    猜你喜欢
    • 2017-04-27
    • 1970-01-01
    • 2013-07-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-01
    • 2020-05-07
    • 1970-01-01
    相关资源
    最近更新 更多