首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在我将ubuntu/php7.2迁移到Debian/php7.3之后,Nginx WordPress网站崩溃了。

在我将ubuntu/php7.2迁移到Debian/php7.3之后,Nginx WordPress网站崩溃了。
EN

Stack Overflow用户
提问于 2019-06-19 06:20:50
回答 1查看 231关注 0票数 0

我把我的Nginx WordPress网站从Ubuntu/PHP7.2移到Debian/PHP7.3,我博客的首页很好,但是所有的子页面都不加载

1)我尝试了Ubuntu18.04和PHP7.2中的工作代码,但出现了错误,并丢失了参数。

2)我在php.ini "cgi.fix_pathinfo=0“中设置了以下值

3) PHP正在运行。

代码语言:javascript
复制
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正在运行

代码语言:javascript
复制
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目录

代码语言:javascript
复制
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/站点-可用/#.com.conf目录

代码语言:javascript
复制
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/$_script_name;

代码语言:javascript
复制
                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格式

代码语言:javascript
复制
/article/%postname%/

/etc/nginx/contcgi.conf目录

代码语言:javascript
复制
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的次要版本时更新了sock位置,该文件是存在的。

代码语言:javascript
复制
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 (cli) (建于:2019年5月31日11:27:35)版权(c) 1997-2018年PHP v3.3.6版权(c) 1998-2018 Zend技术与Zend v7.3.6-1+0~20190531112735.39+stretch~1.gbp6131b7,版权(c) 1999-2018

文件的主页面只加载一个子博客文章(url: /文章/监控-/)报告。

代码语言:javascript
复制
404 Not Found
nginx/1.16.0

对于如何通过快速cgi在我的博客上加载子页面(根很好),我完全不知所措。

EN

回答 1

Stack Overflow用户

发布于 2019-06-19 06:35:51

我修正了在/etc/nginx/site中替换它-可获得的/#.com.conf

代码语言:javascript
复制
location / {
                try_files $uri $uri/ =404;
       }

有了这个

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56661208

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档