运行Nginx 1.17的Digital Ocean Ubuntu18.04 VPS。10 PHP-FPM7.3。我不知道如何正确运行PHP文件(其他一切都正常运行)php文件生成Nginx的404未找到页面。Nginx错误日志仅显示“信号处理已启动”每次更改后,我都会重新启动nginx fpm。我已经研究了几乎所有与此相关的StackOverflow问题,并尝试了各种不同的配置。如果您能提供任何有关这一情况的信息,我将不胜感激。(为了匿名,域名和IP被更改为example.com和127.0.0.1。)
Nginx服务器配置:
server {
listen 80;
listen [::]:80;
root /example.io/public;
server_name www.example.com example.com;
return 301 https://$server_name$request_uri;
index index.html index.php;
}
server {
listen 443 ssl;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://127.0.0.1:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
add_header Front-End_Https on;
}
location ~ \.php$ {
include /etc/nginx/snippets/fastcgi-php.conf;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php7.3-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
/etc/nginx/conf.d
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
# limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;
}
# upstream websocket {
# ip_hash;
# server 127.0.0.1:8081;
# }
##
# Basic Settings
##
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;
##
# 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 Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
# include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/default;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
}
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
fastcgiphp。形态
# regex to split $uri to $fastcgi_script_name and $fastcgi_path
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# Check that the PHP script exists before passing it
try_files $fastcgi_script_name =404;
# Bypass the fact that try_files resets $fastcgi_path_info
# see: http://trac.nginx.org/nginx/ticket/321
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_index index.php;
include fastcgi.conf;
Fastcgi_params
fastcgi_param SCRIPT_FILENAME $request_filename;
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 SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /example.io/public;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REQUEST_SCHEME $scheme;
fastcgi_param HTTPS $https;
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;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
php.ini
PHP fpm 7.3的默认php.ini文件,除了我所做的更改(未注释):
cgi.fix_pathinfo=1
www.conf
包括它的主要部分。任何不包括的都是默认的。
; Start a new pool named 'www'.
; the variable $pool can be used in any directive and will be replaced by the
; pool name ('www' here)
[www]
; Per pool prefix
; It only applies on the following directives:
; - 'access.log'
; - 'slowlog'
; - 'listen' (unixsocket)
; - 'chroot'
; - 'chdir'
; - 'php_values'
; - 'php_admin_values'
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
; will be used.
user = www-data
group = www-data
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
; Note: This value is mandatory.
listen = /var/run/php7.3-fpm.sock
; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 511
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
; mode is set to 0660
listen.owner = www-data
listen.group = www-data
;listen.mode = 0666
; When POSIX Access Control Lists are supported you can set them using
; these options, value is a comma separated list of user/group names.
; When set, listen.owner and listen.group are ignored
;listen.acl_users =
;listen.acl_groups =
对于任何想知道的人,我用一个新的VPS重新开始,完美地安装了所有东西,所有这些都得到了修复。在上面的设置中,我一定是把配置和那些类型的东西弄得太乱了。
问题内容: 在Tomcat服务器上运行Eclipse项目时出现以下错误: HTTP状态404-请求的资源(/ ProjectName /)不可用。 浏览器地址栏中的URL为。 我真的不知道文件中缺少什么。我在文件夹中有一个,并且我的包含以下条目: 问题答案: 默认情况下,当您打开项目根文件夹而不是中的物理文件时,服务器将在中查找欢迎文件。如果未找到任何内容,则将出现此404“找不到页面”错误。 就
问题内容: 我将在春季阅读有关宁静的Web服务的这本书。我决定放弃他们的工作,而使用Java配置文件。出于某种原因,切换到Java配置后,该服务将正确运行(在控制台窗口中),但是当我实际转到localhost上的端点时,我得到了: 白标错误页 此应用程序没有针对/ error的显式映射,因此您将其视为后备。 PDT 2016年4月23日星期六20:48:25发生意外错误(类型=未找到,状态= 40
问题内容: 我正在构建一个Spring 4 MVC应用程序。并且它是使用Java注释完全配置的。没有。该应用是使用的实例进行配置的,就像这样, 和 我现在正在尝试为404页添加全局/全部捕获异常处理程序,但没有成功。以下是我尝试过的一些方法。 这些方法均未执行。我不知道如何处理这个问题。我不想使用,因为我必须为此创建一个。 问题答案: 默认情况下,不会抛出。您需要启用它。 本应该让你重写如何被创建
问题内容: 如何使用Play为他们的404/505错误页面创建全局自定义外观? 问题答案: 在Play Framework 1中,您只需修改提供的和。
问题内容: 在带有springboot的vaadin项目中使用spring security时遇到问题 。因此,我正在使用PdfViewer插件来显示PDF文件。但是我收到 以下错误消息: and my spring security configuration looks like this: So checking the loaded files in Chrome I see a fold
问题内容: 这是我有史以来的第一个servlet。这是代码。 我使用此命令对其进行了编译, 然后将文件放入WEB-INF文件夹中的classes文件夹中。 这是我的web.xml Tomcat7一直给我一个404的说法 文件树: 我在这里做错了什么? 问题答案: 您应该将servlet类放在包中。无包servlet是否起作用取决于旧版Tomcat和JVM版本的特定组合。如果您在书/教程中看到此示例
问题内容: 当我运行selenium WebDriver驱动程序= new FirefoxDriver()显示错误时,它将导入所需的所有库,但仍会重现错误 当我使用Firefox驱动程序()运行时,显示以下错误 你能帮我解决这个问题吗:D 问题答案: 此错误消息… …暗示 GeckoDriver 无法启动/产生新的 WebBrowsing会话, 即 Firefox浏览器 会话。 当您使用 硒3.x
问题内容: 如何获得Spring 3.0控制器来触发404? 我有一个带有控制器的控制器,对于要访问该控制器的某些URL,我希望该容器带有404。 问题答案: 从Spring 3.0开始,您还可以抛出带有注释声明的Exception :