unbit / uwsgi

uWSGI application server container
http://projects.unbit.it/uwsgi
Other
3.47k stars 692 forks source link

No app loaded when running php site on drupal 8.5 cms #1987

Open shmel210 opened 5 years ago

shmel210 commented 5 years ago

Error from vassal log:

 *** Starting uWSGI 2.1-dev-f17bdbd (64bit) on [Wed Feb 27 12:14:21 2019] ***
  4494  compiled with version: 5.4.0 20160609 on 26 February 2019 17:16:03
  4495  os: Linux-4.4.0-142-generic #168-Ubuntu SMP Wed Jan 16 21:00:45 UTC 2019
  4496  nodename: zd28
  4497  machine: x86_64
  4498  clock source: unix
  4499  pcre jit disabled
  4500  detected number of CPU cores: 2
  4501  current working directory: /etc/uwsgi/vassals
  4502  writing pidfile to /run/uwsgi/rud-garden.test.pid
  4503  detected binary path: /opt/uwsgi/uwsgi
  4504  chdir() to /home/shmel/projects/rud-garden.com/web
  4505  your processes number limit is 30486
  4506  your memory page size is 4096 bytes
  4507  detected max file descriptor number: 1024
  4508  lock engine: pthread robust mutexes
  4509  thunder lock: disabled (you can enable it with --thunder-lock)
  4510  *** Cache "rud-garden.test.sessions" initialized: 64MB (key: 2136 bytes, keys: 2136000 bytes, data: 65536000 bytes, bitmap: 0 bytes) preallocated ***
  4511  uwsgi socket 0 bound to UNIX address /run/uwsgi/rud-garden.test.sock fd 5
  4512  dropping root privileges after socket binding
  4513  PHP 7.3.2 initialized
  4514  dropping root privileges after plugin initialization
  4515  your server socket listen backlog is limited to 100 connections
  4516  your mercy for graceful operations on workers is 60 seconds
  4517  your request buffer size is 4096 bytes
  4518  setting request body buffering size to 1048576 bytes
  4519  mapped 3364608 bytes (3285 KB) for 2 cores
  4520  *** Operational MODE: preforking ***
  4521  *** no app loaded. GAME OVER ***
  4522  VACUUM: pidfile removed.
  4523  VACUUM: unix socket /run/uwsgi/rud-garden.test.sock removed.
  4524  unlink(): No such file or directory [core/uwsgi.c line 1732]

In older version of uwsgi (2.0.17.1) error does not appear. Version of uwsgi:

commit f17bdbd1b59565a0d6e81e7b825ee6e08ec8e29e
Author: Unbit <info@unbit.it>
Date:   Sat Feb 9 15:29:02 2019 +0100

    Update README

Emprerior config:

[uwsgi]
plugins-dir = /opt/uwsgi
emperor = /etc/uwsgi/vassals
uid = www-data
gid = www-data
logto = /var/log/uwsgi/emperor.log
check-static-docroot = true
emperor-stats = :1717
plugins-dir = /opt/uwsgi

Vassal config:

[uwsgi]
plugins-dir = /opt/uwsgi
plugins = php73
# variables
project_name = rud-garden.test
project_domain = %(project_name)
root = /home/shmel/projects
workdir = %(root)

# main config
chdir = %(root)/rud-garden.com/web
need-app = true
php-docroot = %(root)/rud-garden.com/web
php-index = index.php
php-allowed-ext = .php
php-allowed-ext = .inc
php-set = open_basedir=/tmp/:%(root)
php-set = post_max_size=100M
php-set = upload_max_filesize=100M
php-set = date.timezone=Europe/Kiev
#php-index = index.php
post-buffering = 1048576
http-socket-modifier1 = 14
#uid = nginx
#gid = nginx
master=true
lang = ru_RU.utf8
env = LANG = ru_RU.utf8

# control
pidfile = /run/uwsgi/%(project_name).pid
socket = /run/uwsgi/%(project_name).sock
stats = /run/uwsgi/%(project_name).stats.sock
chown-socket = www-data:www-data
chmod-socket = 664
#touch-reload = %(root)/logs/%(project_name).reload.txt
logto = /var/log/uwsgi/%(project_name).log
vacuum = true

# perfomance
cache2 = name=%(project_name).sessions,items=1000
php-set = session.save_handler=uwsgi
php-set = session.save_path=%(project_name).sessions
processes = %k
#enable-threads = true
#threads = 4
harakiri = 180
max-requests = 5000

Nginx config:

server {
    server_name rud-garden.test;
    charset UTF-8;
    set $domain rud-garden.test;
    set $user shmel;
    set $root_path /home/$user/projects/rud-garden.com/web;
    root $root_path;
    access_log /var/log/uwsgi/rud-garden.test.access.log;
    error_log /var/log/uwsgi/rud-garden.test.error.log notice;
    index index.php;
    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
    location = /config {
      return 403;
    }
    # Very rarely should these ever be accessed outside of your lan
    location ~* \.(txt|log)$ {
        allow 192.168.0.0/16;
        deny all;
    }

    location ~ \..*/.*\.php$ {
        return 403;
    }

    location ~ ^/sites/.*/private/ {
        return 403;
    }

    # Allow "Well-Known URIs" as per RFC 5785
    location ~* ^/.well-known/ {
        allow all;
    }

    # Block access to "hidden" files and directories whose names begin with a
    # period. This includes directories used by version control systems such
    # as Subversion or Git to store control files.
    location ~ (^|/)\. {
        return 403;
    }

    location / {
        # try_files $uri @rewrite; # For Drupal <= 6
        try_files $uri /index.php?$query_string; # For Drupal >= 7
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    # Don't allow direct access to PHP files in the vendor directory.
    location ~ /vendor/.*\.php$ {
        deny all;
        return 404;
    }

    # In Drupal 8, we must also match new paths where the '.php' appears in
    # the middle, such as update.php/selection. The rule we use is strict,
    # and only allows this pattern with the update.php front controller.
    # This allows legacy path aliases in the form of
    # blog/index.php/legacy-path to continue to route to Drupal nodes. If
    # you do not have any paths like that, then you might prefer to use a
    # laxer rule, such as:
    #   location ~ \.php(/|$) {
    # The laxer rule will continue to work if Drupal uses this new URL
    # pattern with front controllers other than update.php in a future
    # release.
    location ~ '\.php$|^/update.php' {
        fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
        include uwsgi_params;
        uwsgi_modifier1 14;
        uwsgi_pass unix:///run/uwsgi/rud-garden.test.sock;
        uwsgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        uwsgi_param SCRIPT_NAME     $fastcgi_script_name;
        #uwsgi_param HTTP_PROXY "";
        #uwsgi_param PATH_INFO $fastcgi_path_info;
        #uwsgi_param QUERY_STRING $query_string;
        #fastcgi_intercept_errors on;
    }

    # Fighting with Styles? This little gem is amazing.
    location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
        try_files $uri @rewrite;
    }

    # Handle private files through Drupal. Private file's path can come
    # with a language prefix.
    location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
        try_files $uri /index.php?$query_string;
    }
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }
}
niol commented 7 months ago

Duplicate of #2106 , solution is a config file with need-app = False

Tanjimul1 commented 4 days ago

This post was extremely helpful.