Сломанный веб-сайт Nginx WordPress после того, как я перешел с Ubuntu / PHP 7.2 на Debian / PHP 7.3 - PullRequest
0 голосов
/ 19 июня 2019

Я переместил свой веб-сайт Nginx WordPress с Ubuntu / PHP 7.2 на Debian / PHP 7.3, первая страница моего блога работает, но все подстраницы не загружаются

1) Я попробовал рабочий код из Ubuntu 18.04и PHP 7.2, были ошибки с отсутствующими параметрами fastcgi.

2) Я установил следующее значение в php.ini "cgi.fix_pathinfo = 0"

3) PHP FPM работает.

sudo service php7.3-fpm status
* php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-06-19 05:41:36 UTC; 15min ago
     Docs: man:php-fpm7.3(8)
 Main PID: 4587 (php-fpm7.3)
   Status: "Processes active: 0, idle: 15, Requests: 28, slow: 0, Traffic: 0req/sec"
    Tasks: 16 (limit: 4915)
   CGroup: /system.slice/php7.3-fpm.service
           |-4587 php-fpm: master process (/etc/php/7.3/fpm/php-fpm.conf)
           |-4588 php-fpm: pool www
           |-4589 php-fpm: pool www
           |-4590 php-fpm: pool www
           |-4591 php-fpm: pool www
           |-4592 php-fpm: pool www
           |-4593 php-fpm: pool www
           |-4594 php-fpm: pool www
           |-4595 php-fpm: pool www
           |-4596 php-fpm: pool www
           |-4597 php-fpm: pool www
           |-4598 php-fpm: pool www
           |-4599 php-fpm: pool www
           |-4600 php-fpm: pool www
           |-4601 php-fpm: pool www
           `-4602 php-fpm: pool www

NGINX работает

sudo service nginx status
* nginx.service - nginx - high performance web server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-06-19 05:50:28 UTC; 7min ago
     Docs: http://nginx.org/en/docs/
  Process: 4836 ExecStop=/bin/kill -s TERM $MAINPID (code=exited, status=0/SUCCESS)
  Process: 4840 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 4841 (nginx)
    Tasks: 5 (limit: 4915)
   CGroup: /system.slice/nginx.service
           |-4841 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf
           |-4842 nginx: worker process
           |-4843 nginx: worker process
           |-4844 nginx: worker process
           `-4845 nginx: worker process

/ etc / nginx / nginx.conf содержимое

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

error_log /var/log/nginx/error.log;
events {
    worker_connections 1024;
}

http {

    access_log /var/log/nginx/access.log;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout 65;
    types_hash_max_size 2048;
    # server_tokens off;

    # server_names_hash_bucket_size 64;
    # server_name_in_redirect off;

    include /etc/nginx/mime.types;
    default_type application/octet-stream;


    client_max_body_size 10M;


    proxy_connect_timeout 1200s;
    proxy_send_timeout 1200s;
    proxy_read_timeout 1200s;
    fastcgi_send_timeout 1200s;
    fastcgi_read_timeout 1200s;

    ##
    # SSL Settings
    ##

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
    ssl_prefer_server_ciphers on;

    ##
    # Logging Settings
    ##

    #access_log /var/log/nginx/access.log;
    #error_log /var/log/nginx/error.log;


    gzip on;
    gzip_disable "msie6";
    gzip_comp_level 5;
    gzip_min_length 256;
    gzip_vary on;
    gzip_types
    application/atom+xml
    application/ld+json
    application/manifest+json
    application/rss+xml
    application/vnd.geo+json
    application/vnd.ms-fontobject
    application/x-font-ttf
    application/x-web-app-manifest+json
    application/xhtml+xml
    font/opentype
    image/bmp
    image/x-icon
    text/cache-manifest
    text/vcard
    text/vnd.rim.location.xloc
    text/vtt
    text/x-component
    text/x-cross-domain-policy;

    gzip_proxied any;
    gzip_buffers 16 8k;
    gzip_http_version 1.1;

    gzip_types text/plain text/css text/xml text/javascript 
    application/x-javascript application/xml;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

/ etc /nginx / sites-available / ######. com.conf содержимое

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        listen 443 ssl default_server http2;
        listen [::]:443 ssl default_server http2;

        root /www;
        index index.php index.html index.htm;
        server_name fearby.com www.fearby.com;

        #location / {
        #        try_files $uri $uri/ =404;
        #}

        #SSL
        ssl_certificate /root/.acme.sh/fearby.com/fullchain.cer;
        ssl_certificate_key /root/.acme.sh/fearby.com/fearby.com.key;
        ssl_dhparam /root/.acme.sh/fearby.com/dhparams.pem;

        # SECURITY
        add_header X-Frame-Options sameorigin;
        add_header X-Content-Type-Options nosniff;
        add_header X-XSS-Protection "1; mode=block";

        # Force HTTPS
        if ($scheme != "https") {
                return 301 https://$host$request_uri;
        }

        # DENY RULES
        location ~ /\.ht {
                deny all;
        }
        location ~ ^/\.user\.ini {
                deny all;
        }
        location ~ (\.ini) {
                return 403;
        }

        # OTHER RULES

        location / {
                try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
                #try_files $uri =404;
                #try_files $uri $uri/ /index.php?q=$uri&$args;
                try_files $uri $uri/ /index.php?$args;

                fastcgi_split_path_info ^(.+?\.php)(/.*)$;

                if (!-f $document_root$fastcgi_script_name) {
                        return 404;
                }

                fastcgi_index index.php;

                fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
                fastcgi_param  SCRIPT_FILENAME                   

/ wwwroot / $ fastcgi_script_name;

                include fastcgi.conf;
                fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

       }

        # PERFORMANCE
        fastcgi_param PHP_VALUE "memory_limit = 4096M";


        # DNS
        resolver 1.1.1.1 1.0.0.1 valid=60s;
        resolver_timeout 1m;

        # HEADERS
        location ~* \.(?:ico|css|js|gif|jpe?g|png|js)$ {
                expires 30d;
                add_header Pragma public;
                add_header Cache-Control "public";
        }

}

Формат WordPress PermaLink

/article/%postname%/

/ etc / nginx / fastcgi.conf содержимое

fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;

fastcgi_param HTTP_PROXY "";
fastcgi_param   QUERY_STRING            $query_string;
fastcgi_param   REQUEST_METHOD          $request_method;
fastcgi_param   CONTENT_TYPE            $content_type;
fastcgi_param   CONTENT_LENGTH          $content_length;
fastcgi_param   PATH_INFO               $fastcgi_path_info;
#Following line causes an Access denied  erorr
# fastcgi_param   PATH_TRANSLATED         /wwwroot$document_root$fastcgi_path_info;
fastcgi_param   REQUEST_URI             $request_uri;
fastcgi_param   DOCUMENT_URI            $document_uri;
fastcgi_param   DOCUMENT_ROOT           $document_root;
fastcgi_param   SERVER_PROTOCOL         $server_protocol;
fastcgi_param   GATEWAY_INTERFACE       CGI/1.1;
fastcgi_param   SERVER_SOFTWARE         nginx/$nginx_version;
fastcgi_param   REMOTE_ADDR             $remote_addr;
fastcgi_param   REMOTE_PORT             $remote_port;
fastcgi_param   SERVER_ADDR             $server_addr;
fastcgi_param   SERVER_PORT             $server_port;
fastcgi_param   SERVER_NAME             $server_name;
fastcgi_param   HTTPS                   $https;

Раньше я обновлял расположение носка при обновлении до второстепенноговерсия php, файл существует

ls -al /var/run/php/php7.3-fpm.sock;
srw-rw---- 1 www-data www-data 0 Jun 19 05:41 /var/run/php/php7.3-fpm.sock

Версия PHP:

PHP 7.3.6-1 + 0 ~ 20190531112735.39 + stretch ~ 1.gbp6131b7 (cli) (построено: 31 мая 2019 г.11:27:35) (NTS) Copyright (c) 1997-2018 PHP Group Zend Engine v3.3.6, Copyright (c) 1998-2018 Zend Technologies с Zend OPcache v7.3.6-1 + 0 ~ 20190531112735.39 + stretch ~ 1.gbp6131b7, Copyright (c) 1999-2018, ZendТехнологии

Основная страница файла загружается, но отчеты в под-блоге (url: / article / мониторинг-cronjobs-on-linux /).

404 Not Found
nginx/1.16.0

Я нахожусь наполная потеря относительно того, как получить подстраницы для загрузки в моем блоге через быстрый cgi (рут в порядке).

1 Ответ

0 голосов
/ 19 июня 2019

Я исправил, заменив это в /etc/nginx/sites-available/####.com.conf

location / {
                try_files $uri $uri/ =404;
       }

с этим

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

Спасибо за https://www.digitalocean.com/community/questions/nginx-404-error-on-all-wordpress-posts-and-pages-except-homepage

...