【问题标题】:Deploy Laravel Project on Debian Server using Ngnix使用 Nginx 在 Debian 服务器上部署 Laravel 项目
【发布时间】:2019-11-13 16:04:09
【问题描述】:

所以我用 laravel 创建了一个应用程序,现在我尝试将它托管在 Debian 服务器中。

我上传了在(/var/www/html/site)中找到的所有laravel项目

(site) 是包含所有文件的文件夹 app, public, .env ....

只是还有一个正在运行的 mybb 论坛(/var/www/html/board),这是另一个开发人员提出的,所以我不想做任何可能导致论坛关闭的错误操作

所以在我查看如何在 Debian 上启动 Laravel 项目之前,我按照说明进行操作 from this tutorial,(并非全部因为我已经安装了 PHP 7.3、phpmyadmin)

这就是我设置的方式(sudo vim /etc/nginx/sites-available/mydomain.com)


    server {
        server_name mydomain.com mydomain.com;
        listen 80;

        root /var/www/html/site/public;

        access_log /var/log/nginx/laravel-access.log;
        error_log /var/log/nginx/laravel-error.log;

        location / {
            try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }

        location ~ /\.ht {
            deny all;
        }    
    }

最后我运行这个命令

sudo 服务 nginx 重启

我收到这个错误


    root@ns300976:~# sudo service nginx restart
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xe" for details.

所以接下来我尝试(systemctl status nginx.service),我得到了这个


    root@ns300976:~# sudo service nginx restart
    Job for nginx.service failed because the control process exited with error code.
    See "systemctl status nginx.service" and "journalctl -xe" for details.
    root@ns300976:~# systemctl status nginx.service
    ● nginx.service - A high performance web server and a reverse proxy server
       Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
       Active: failed (Result: exit-code) since Wed 2019-11-13 06:37:35 UTC; 40s ago
         Docs: man:nginx(8)
      Process: 21913 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=1/F
      Process: 21911 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, s
    nov. 13 06:37:33 ns300976 nginx[21913]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
    nov. 13 06:37:34 ns300976 nginx[21913]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
    nov. 13 06:37:34 ns300976 nginx[21913]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
    nov. 13 06:37:34 ns300976 nginx[21913]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
    nov. 13 06:37:34 ns300976 nginx[21913]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
    nov. 13 06:37:35 ns300976 nginx[21913]: nginx: [emerg] still could not bind()
    nov. 13 06:37:35 ns300976 systemd[1]: nginx.service: Control process exited, code=exited status=1
    nov. 13 06:37:35 ns300976 systemd[1]: Failed to start A high performance web server and a reverse pr
    nov. 13 06:37:35 ns300976 systemd[1]: nginx.service: Unit entered failed state.
    nov. 13 06:37:35 ns300976 systemd[1]: nginx.service: Failed with result 'exit-code'.
    lines 1-17/17 (END)

接下来我尝试(journalctl -xe),我得到了这个


    root@ns300976:~# journalctl -xe
    nov. 13 06:59:12 ns300976 sshd[22318]: Failed password for root from 112.85.42.89 port 41078 ssh2
    nov. 13 06:59:14 ns300976 sshd[22318]: Failed password for root from 112.85.42.89 port 41078 ssh2
    nov. 13 06:59:15 ns300976 sshd[22318]: Received disconnect from 112.85.42.89 port 41078:11:  [preaut
    nov. 13 06:59:15 ns300`enter code here`976 sshd[22318]: Disconnected from 112.85.42.89 port 41078 [preauth]
    nov. 13 06:59:15 ns300976 sshd[22318]: PAM 2 more authentication failures; logname= uid=0 euid=0 tty
    nov. 13 07:01:01 ns300976 sudo[22331]:     root : TTY=pts/1 ; PWD=/root ; USER=root ; COMMAND=/usr/s
    nov. 13 07:01:01 ns300976 sudo[22331]: pam_unix(sudo:session): session opened for user root by root(
    nov. 13 07:01:01 ns300976 systemd[1]: Starting A high performance web server and a reverse proxy ser
    -- Subject: L'unité (unit) nginx.service a commencé à démarrer
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- L'unité (unit) nginx.service a commencé à démarrer.
    nov. 13 07:01:01 ns300976 nginx[22340]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
    nov. 13 07:01:01 ns300976 nginx[22340]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
    nov. 13 07:01:02 ns300976 nginx[22340]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
    nov. 13 07:01:02 ns300976 nginx[22340]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
    nov. 13 07:01:02 ns300976 nginx[22340]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
    nov. 13 07:01:02 ns300976 nginx[22340]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
    nov. 13 07:01:03 ns300976 nginx[22340]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
    nov. 13 07:01:03 ns300976 nginx[22340]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
    nov. 13 07:01:03 ns300976 nginx[22340]: nginx: [emerg] listen() to 0.0.0.0:80, backlog 511 failed (9
    nov. 13 07:01:03 ns300976 nginx[22340]: nginx: [emerg] listen() to [::]:80, backlog 511 failed (98:
    nov. 13 07:01:04 ns300976 nginx[22340]: nginx: [emerg] still could not bind()
    nov. 13 07:01:04 ns300976 sudo[22331]: pam_unix(sudo:session): session closed for user root
    nov. 13 07:01:04 ns300976 systemd[1]: nginx.service: Control process exited, code=exited status=1
    nov. 13 07:01:04 ns300976 systemd[1]: Failed to start A high performance web server and a reverse pr
    -- Subject: L'unité (unit) nginx.service a échoué
    -- Defined-By: systemd
    -- Support: https://www.debian.org/support
    --
    -- L'unité (unit) nginx.service a échoué, avec le résultat failed.
    nov. 13 07:01:04 ns300976 systemd[1]: nginx.service: Unit entered failed state.
    nov. 13 07:01:04 ns300976 systemd[1]: nginx.service: Failed with result 'exit-code'.

这是我第一次使用 Linux 并寻找我怀疑阻塞端口 80 的 apache2 的解决方案

但是做个kill进程,怕影响论坛,不知道是不是用Apache2做功能

如果我必须通过 Apache 运行我的应用程序,我希望得到您的建议

感谢您的帮助!

【问题讨论】:

  • 像这样测试你的配置文件nginx -c /etc/nginx/nginx.conf -t

标签: linux laravel nginx debian


【解决方案1】:

根目录后 /var/www/html/site/public;添加这个

index index.php index.html index.htm index.nginx-debian.html;

我认为你的 apache 正在运行。在正在运行的 wchich 端口中检查它

sudo netstat -ntpl

然后杀死那个进程

sudo kill pid(your pid)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-09
    • 2022-07-09
    • 2021-03-22
    • 1970-01-01
    • 1970-01-01
    • 2016-11-12
    • 1970-01-01
    • 2021-11-11
    相关资源
    最近更新 更多