Nginx+php7,为什么根目录的可以打开PHP文件,子目录就没有办法解析php文件,救急~ 80C

配置文件全部内容如下:
server{
listen 443;
server_name www.11law.cn 11law.cn;
root /home/wwwroot/domain/11law; # 该项要修改为你准备存放相关网页的路径

ssl on;
ssl_certificate           ------------------;
ssl_certificate_key       -----------------;
ssl_session_timeout       5m;
ssl_protocols             TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers               ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA;
ssl_session_cache         shared:SSL:50m;
ssl_prefer_server_ciphers on;
location / {
    index  index.php index.html index.htm;
     #如果请求既不是一个文件,也不是一个目录,则执行一下重写规则

}
#proxy the php scripts to php-fpm
       location ~ \.php$ {

         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.php;
         fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
         include        fastcgi_params;
     }




location ^~ /data/runtime {
return 404;
}

location ^~ /application {
return 404;
}

location ^~ /simplewind {
return 404;
}

}

1个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
Nginx+php7,为什么根目录的可以打开PHP文件,子目录就没有办法解析php文件,救急~

配置文件全部内容如下: server{ listen 443; server_name www.11law.cn 11law.cn; root /home/wwwroot/domain/11law; # 该项要修改为你准备存放相关网页的路径 ssl on; ssl_certificate ------------------; ssl_certificate_key -----------------; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA; ssl_session_cache shared:SSL:50m; ssl_prefer_server_ciphers on; location / { index index.php index.html index.htm; #如果请求既不是一个文件,也不是一个目录,则执行一下重写规则 } #proxy the php scripts to php-fpm location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ^~ /data/runtime { return 404; } location ^~ /application { return 404; } location ^~ /simplewind { return 404; } }

Nginx阻止根目录

<div class="post-text" itemprop="text"> <p>I have nginx. There is a site in it, the root of the site is /root/SITE In this SITE directory i have some .php files, and few directories. How can i deny the access ONLY to the .php files in the /root/SITE directory (i mean that in those few directories that are in /root/SITE .php files shouldn't be blocked)</p> </div>

lnmp网站根目录权限问题

环境centos7.2+nginx+php5.5+mysql5.6问题:网站的根路径只能是/tmp下才能访问,其他路径一律不能访问,nginx和php的用户和组都是www,给了根目录权限755和777都不行,所有者是www也不可以,跳出index.php中的错误,是php中的realpath获取不到绝对路径,返回bool(flase),导致php的index.php入口文件进不去,请问有人遇到过这样的问题吗,如有烦请指导救急,感激不尽,如图是错误页面和index.php部分内容![![图片说明](https://img-ask.csdn.net/upload/201710/23/1508768601_530675.png)图片说明](https://img-ask.csdn.net/upload/201710/23/1508768593_790996.png)

nginx配置。使用域名可以正常访问php文件,但使用ip地址就变成下载php文件了。这该如何解决?

如题。在目标文件下还创了个html文件,这时使用ip可以正常访问。 粘贴部分nginx的配置。 user www www; worker_processes auto; error_log /www/wwwlogs/nginx_error.log crit; pid /www/server/nginx/logs/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; multi_accept on; } http { include mime.types; #include luawaf.conf; include proxy.conf; default_type application/octet-stream; server_names_hash_bucket_size 512; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn_zone $server_name zone=perserver:10m; server_tokens off; access_log off; server { listen 888; server_name 47.104.172.177; index index.html index.htm index.php; root /www/server/phpmyadmin; #error_page 404 /404.html; include enable-php.conf; location ~ .*\.php$ { fastcgi_pass 127.0.0.1:9000; } location ^~ /web/{ alias /www/wwwroot/server.meiliyou591.com/meiliyou/web/; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ /\. { deny all; } access_log /www/wwwlogs/access.log; } include /www/server/panel/vhost/nginx/*.conf; }

NGINX下载PHP文件而不是显示

<div class="post-text" itemprop="text"> <p>I'm trying to display index.php and info.php on my NGINX webserver but i cant get it working for some reason, my browser keeps downloading the files instead of displaying them. I tried alot of tutorials but i dont know whats wrong.</p> <p>OS: Ubuntu 17.10 Server</p> <p>PHP version: 7.1</p> <p>cgi.fix_pathinfo is set to 0</p> <p>www.conf file is default except de cgi.fix_pathinfo</p> <pre><code>server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name nginx1.domain.com; location / { try_files $uri $uri/ =404; } location ~ \.php$ { try_files $uri $uri/ =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: fastcgi_pass unix:/var/run/php/php7.1-fpm.sock; fastcgi_index index.php; include fastcgi_params; } #location ~ /\.ht { # deny all; #} } </code></pre> <p>Can someone please help me?</p> </div>

求帮助,Linux安装Nginx后改了根目录报403

没改之前还有欢迎。。。。。啥的改了之后![图片说明](https://img-ask.csdn.net/upload/201701/06/1483691094_90538.jpg) 我修改的是下面三个地方,原来的都是html; ![图片说明](https://img-ask.csdn.net/upload/201701/06/1483691156_430340.jpg) ![图片说明](https://img-ask.csdn.net/upload/201701/06/1483691545_725464.jpg) 除了报403,里面的图片可以看![图片说明](https://img-ask.csdn.net/upload/201701/06/1483691671_993991.jpg) 关于权限,我都设置了777 ![图片说明](https://img-ask.csdn.net/upload/201701/06/1483691614_210400.jpg) ![图片说明](https://img-ask.csdn.net/upload/201701/06/1483691779_604789.jpg) ![图片说明](https://img-ask.csdn.net/upload/201701/06/1483691789_124871.jpg)

使用nginx在子目录中时不执行PHP

<div class="post-text" itemprop="text"> <p>When going on <code>example.com</code>, <code>example.com/foo/</code> or <code>example.com/foo/bar/</code>, PHP was working great. Then I tried to modify Nginx conf to have <code>foo.example.com</code> pointing on <code>example.com/foo/</code> (the DNS is already configured). It works, but now when I access to <code>foo.example.com/bar/</code>, I can download <code>foo/bar/index.php</code> instead of executing it.</p> <p>Here is the Nginx configuration:</p> <pre><code>server { listen 80; server_name *.example.com; root /var/www/html/; location / { index index.html; } } server { listen 80; server_name foo.example.com; root /var/www/html/foo/; location / { index index.php; try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { fastcgi_pass web_fpm:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } </code></pre> <p>I know there are plenty of similar threads, but none of those I read worked.</p> </div>

NGINX + PHP7 + FastCGI不执行PHP文件并将PHP文件下载到客户端

<div class="post-text" itemprop="text"> <p>The title says it all... follows are my config files.</p> <p>There have to be many others looking for an updated solution to the FastCGI configuration woes.</p> <p>Merci!</p> <p>nginx -t</p> <pre><code>nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful </code></pre> <p>curl -i <a href="http://ipaddress" rel="nofollow noreferrer">http://ipaddress</a></p> <pre><code>HTTP/1.1 200 OK Server: nginx/1.10.2 Date: Tue, 28 Mar 2017 21:18:20 GMT Content-Type: application/octet-stream Content-Length: 1780 Last-Modified: Thu, 15 Dec 2016 15:20:08 GMT Connection: keep-alive ETag: "5852b4a8-6f4" Accept-Ranges: bytes </code></pre> <p>nginx/php-fpm generated no errors in logs</p> <p>nginx access log generated the following.</p> <pre><code>192.88.135.5 - - [28/Mar/2017:13:18:38 -0400] "GET / HTTP/1.1" 200 1780 "-""Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 OPR/43.0.2442.1144" </code></pre> <p>files in .sock path directory</p> <pre><code>-rw-r--r--. 1 root root 5 Mar 28 18:13 php-fpm.pid srw-rw----. 1 nginx nginx 0 Mar 28 18:13 website.com.sock </code></pre> <p>nginx version: nginx/1.10.2 PHP 7.0.16 (fpm-fcgi) (built: Feb 18 2017 10:26:54)</p> <p>nginx.conf</p> <pre><code>user nginx nginx; worker_processes 4; error_log /var/log/nginx/error.log; error_log /var/log/nginx/error.log notice; error_log /var/log/nginx/error.log info; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; upstream php { server unix:/var/run/php-fpm/website.com.sock; } server { include /etc/nginx/conf.d/default.conf; include /etc/nginx/sites-available/*.conf; } } </code></pre> <p>default.conf</p> <pre><code>include /etc/nginx/security; #expires max; #Uploads configuration client_max_body_size 32m; </code></pre> <p>site-available/site.conf</p> <pre><code>listen [::]:80; server_name *.website.com; root /some/directory/website/; access_log /var/log/nginx/www.access.log; error_log /var/log/nginx/www.error.log notice; #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; #Index targets index index.php index.html index.htm; location / { # redirect admin/auth #rewrite ^/(admin|auth)(.*) https://$host$request_uri?; # try_files $uri =404; # #fastcgi_split_path_info ^(.+\.php)(/.+)$; try_files $uri $uri/ /index.php$is_args$args; } # if the file being requested ends in ".php", it's something # that PHP-FPM should process, so hand it to upstream server location ~ \.php$ { fastcgi_pass php; } </code></pre> <p>php-fpm/www.conf</p> <pre><code>; Start a new pool named 'www'. [www] ping./var/run/php-fpm/website.com.sock = /ping listen = /var/run/php-fpm/website.com.sock; pm = dynamic pm.status_/var/run/php-fpm/website.com.sock = /status user = nginx group = nginx listen.owner = nginx listen.group = nginx listen.mode = 0666 pm.max_children = 5 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 3 </code></pre> <p>fastcgi.conf</p> <pre><code>fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param QUERY_STRING $query_string; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; # To use NGINX + Virtual Host + PHP you should ommit the SCRIPT_NAME variable in order for # PHP to choose the correct DOCUMENT_ROOT. #fastcgi_param SCRIPT_NAME $fastcgi_script_name; # 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 REQUEST_SCHEME $scheme; fastcgi_param HTTPS $https if_not_empty; 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; </code></pre> </div>

能在Apache下运行网站,但不能在nginx的根目录下运行,为什么?

**提示 403 Forbidden Nginx版本号错误** **两个服务可以同时启动,防火墙也允许了对应的端口** 错误日志/var/log/nginx/access.log 192.168.128.131 - - [30/May/2017:03:26:58 +0800] "GET /mysite/lyadmin/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [30/May/2017:03:26:59 +0800] "GET /mysite/lyadmin/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [30/May/2017:03:27:00 +0800] "GET /mysite/lyadmin/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [30/May/2017:03:27:03 +0800] "GET /mysite/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [30/May/2017:03:27:09 +0800] "GET /mysite/lyadmin/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [30/May/2017:13:37:28 +0800] "GET /mysite/lyadmin/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [30/May/2017:13:37:29 +0800] "GET /mysite/lyadmin/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [30/May/2017:13:37:30 +0800] "GET /mysite/lyadmin/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [30/May/2017:13:47:04 +0800] "GET /mysite/lyadmin/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [30/May/2017:13:47:05 +0800] "GET /mysite/lyadmin/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [30/May/2017:13:47:06 +0800] "GET /mysite/lyadmin/ HTTP/1.1" 403 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:04:13 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:04:13 +0800] "GET /favicon.ico HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:07:52 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:07:53 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:07:54 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:10:45 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:10:47 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:10:47 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:10:52 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:11:04 +0800] "GET /lyadmin HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:11:23 +0800] "GET /lyadmin/index.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:15:10 +0800] "GET /lyadmin/index.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:15:16 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:23:06 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:23:07 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:23:07 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:23:08 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:23:09 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:24:39 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:24:40 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" 192.168.128.131 - - [31/May/2017:16:24:45 +0800] "GET /info.php HTTP/1.1" 404 169 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0" "-" **/etc/nginx/conf.d/default配置:** 这个配置是零云框架默认的,没改过 server { listen 80; root /usr/share/nginx/html/mysite; index index.html index.htm index.php; server_name localhost; location / { # URL重写支持 try_files $uri $uri/ /index.php?s=$uri&$args; } # 开启PHP支持 location ~ \.php { fastcgi_split_path_info ^(.+\.php)(.*)$; fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param PATH_INFO $fastcgi_path_info; # 环境变量 fastcgi_param CT_DEV_MODE 'true'; # 加载Nginx默认"服务器环境变量"配置 include fastcgi_params; } } [链接](http://blog.csdn.net/han_cui/article/details/54892400?locationNum=14&fps=1 "") http://blog.csdn.net/han_cui/article/details/54892400?locationNum=14&fps=1 根据这个链接,加的代码却报错 fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/mysite/$fastcgi_script_name;

将目录位置重写为php文件nginx

<div class="post-text" itemprop="text"> <p>I'm having difficulty converting this .htaccess in /thumb directory to nginx to work.</p> <p>.htaccess file:</p> <pre><code>Options +FollowSymLinks &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteRule .* ../thumb.php [L,QSA] &lt;/IfModule&gt; </code></pre> <p>What I tried:</p> <pre><code>location /thumb { rewrite ^(.*)$ /thumb.php; } location /thumb { index thumb.php; rewrite ^/thumb/(.*)$ /thumb.php; } </code></pre> <p>These won't work.</p> <p>edited: I think I found the problem but I'm still puzzle on the solutions. I made a small echo php file to test, all result that does not end in extension seem to work. Any url that end with any extension will return a 404.</p> <p><a href="http://www.example.com/thumb" rel="nofollow noreferrer">http://www.example.com/thumb</a> work<br> <a href="http://www.example.com/thumb/jsdlfjfds" rel="nofollow noreferrer">http://www.example.com/thumb/jsdlfjfds</a> work<br> <a href="http://www.example.com/thumb/jsdlfjfds/sfjlkdfjldf" rel="nofollow noreferrer">http://www.example.com/thumb/jsdlfjfds/sfjlkdfjldf</a> work<br> <a href="http://www.example.com/thumb/asldkjfls.png" rel="nofollow noreferrer">http://www.example.com/thumb/asldkjfls.png</a> not work<br> <a href="http://www.example.com/thumb/zxcvmfds/asldkjfls.jpg" rel="nofollow noreferrer">http://www.example.com/thumb/zxcvmfds/asldkjfls.jpg</a> not work<br></p> <p>How do I rewrite full url, including all extension to /thumb.php? I always thought this regex mean full url with extension ^(.*)$?</p> <p>thumb.php</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;PHP Test&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;?php echo '&lt;p&gt;Hello World&lt;/p&gt;'; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> </div>

nginx下载php文件而不是执行它们

<div class="post-text" itemprop="text"> <p>I'm trying to set up a LEMP stack and after going through several tutorials i can't seem to get php working here is my nginx config: </p> <p>default.conf:</p> <pre><code>server { listen 80 0.0.0.0; listen [::]:80 0.0.0.0 ipv6only=on; # note that these lines are originally from the "location /" block root /usr/share/nginx/html; index index.php index.html index.htm; location / { try_files $uri $uri/ =404; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } </code></pre> </div>

问一下各位大佬,安装php-fpm和nginx不能访问php页面,会自动下载php文件

系统是centos7.安装php-fpm 和 nginx以后,php文件自动下载。安装nginx的时候也安装pcre了。

nginx php7只能在文档根目录下工作

<div class="post-text" itemprop="text"> <p>beginner here ;)</p> <p>I moved a page from one VPS to another and after installing nginx,php7 etc (using <a href="https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-in-ubuntu-16-04" rel="nofollow noreferrer">this tutorial</a>) everything is working great. Added SSL no problem at all.</p> <p>However if I execute any php files (f.e hello world) in any newly created subfolder f.e mydomain.pw/newfolder/index.php I get a blank result. If I execute the same file in the page root folder (WP), it works fine.</p> <p>I have added my user to the www-data group and gave the same permission as I did on the former VPS. If I check the nginx error log or php7.0-fpm.log I get no error at all.</p> <p>If anyone has any hint or idea what the problem is, I'd really appreciate it. I suspect a permission error but searched on SO and Google without success.</p> <p>Here is my nginx conf :</p> <pre><code>server { listen [::]:80 default_server ipv6only=on; listen 80 default_server; # listen on the www and non-www host server_name www.mydomain.pw mydomain.pw; root /var/www/mydomain; index index.html index.htm index.php ; # and redirect to the https host (declared below) return 301 https://mydomain.pw$request_uri; location ~ \.php$ { try_files $uri $uri/ /index.php?$args; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } server { listen [::]:443 ssl; listen 443 ssl; server_name www.mydomain.pw mydomain.pw; root /var/www/mydomain; index index.html index.htm index.php; ssl_certificate /etc/letsencrypt/live/mydomain.pw/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/mydomain.pw/privkey.pem; location ~ \.php$ { try_files $uri $uri/ /index.php?$args; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { expires 365d; } } </code></pre> <p>Thanks in advance!</p> </div>

nginx报错,域名下子目录访问报错404

nginx 报错: 访问域名:http://webapp.otcwallet.io/otc/ 域名下子目录所有文件跳转到主目录然后报错404,我想要的效果是域名下可以建多个工程子目录,通过加目录就可以访问。 ![图片说明](https://img-ask.csdn.net/upload/201912/23/1577085321_597173.png) ``` location /otc { root /www/wwwroot/webapp; index index.html index.htm; #proxy_pass http://ant_web/; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; if ($request_method = POST ) { proxy_pass http://bc; } try_files $uri $uri/ /index.html?$query_string; } ``` 代理设置

求教 Nginx 二级目录 Rewrite 的问题

需要在二级目录整个 Rewrite,对 Nginx 不熟整了好一会没搞定 原URL : https://www.a.com/club/index.php?/q/detail/1 目标URL : https://www.a.com/club/q/detail/1 就是把中间的 index.php? 部分去掉了,求高人指教 Nginx 版本是 nginx 1.4.6

nginx配置phpmyadmin虚拟目录的问题

server {listen 80; server_name ceshi3.com; #charset koi8-r; #access_log logs/host.access.log main; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; location / { root /www/html/ceshi3.com/htdocs; index index.html index.php index.htm; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000# location ~ \.php$ { # root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /www/html/ceshi3.com/htdocs$fastcgi_script_name; include fastcgi_params; } location /phpmyadmin { alias /usr/share/phpMyAdmin/; index index.php;} location ~ /phpmyadmin/.+\.php$ { if ($fastcgi_script_name ~ /phpmyadmin/(.+\.php.*)$) { set $valid_fastcgi_script_name $1;} include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name; } }但是这样配置之后phpmyadmin打不开,phpmyadmin不在网站根目录下,用的alias定义虚拟目录,如果我把 location ~ \.php$这个删掉,phpmyadmin就可以打开了,但是这样网站首页如果是php的,那么打开首页就会变成下载php文件了,说明php解析不成功,这是怎么回事! 以上语法有错误吗,为什么有冲突呢? [http://kimsom.com 曾劲松博客](http://kimsom.com "曾劲松博客")

windows怎么利用nginx访问本地目录

我想通过本地服务器访问本地的目录某文件对比软件版本,更新自己软件版本。

为什么nginx在我的PHP文件下载中返回403?

<div class="post-text" itemprop="text"> <p>I use nginx 1.14.1 with PHP and I have problems with a call that should result in a file download.</p> <p>The PHP application produces a response with status code 200 and the file contents are dumped in the body, but from nginx I get the following answer (head)</p> <pre><code>HTTP/2 403 server: nginx/1.14.1 date: Tue, 23 Apr 2019 07:19:19 GMT content-type: text/html; charset=UTF-8 vary: Accept-Encoding x-powered-by: PHP/7.2.17 strict-transport-security: max-age=31536000 </code></pre> <p>The headers my PHP application produces are not included in the nginx response.</p> <p>Firefox yields the error "/Users/myuser/Downloads/NBPKD9pN.mp4.part could not be saved, because the source file could not be read. Try again later, or contact the server administrator."</p> <p>The file that should be downloaded is about 1 GB in size.</p> <p>The rest of the PHP application works fine (does not result in 403s).</p> <p>Does it help to provide my full nginx config?</p> <p>When I put the same file into the web root and call it directly (without PHP) the download works fine.</p> <p><strong>Edit:</strong> The PHP code roughly looks like this:</p> <pre><code>header('Content-Type: video/mp4'); header('Content-Disposition: attachment; filename="' . $filename . '"'); header('Content-Length: ' . $filesize)); readfile($file); die(); </code></pre> </div>

Nginx不处理php文件并保存(php7.2-fpm)?

<div class="post-text" itemprop="text"> <p>Nginx does not process the php file and saves it (php7.2-fpm) Ubuntu18:04</p> <p>How to set up correctly nginx for working with php7.2</p> <h1>/etc/nginx/sites-available/default</h1> <pre><code> server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/html; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; # # With php-fpm (or other unix sockets): fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } </code></pre> <p>}</p> <h1>/etc/nginx/sites-available/test.ru</h1> <pre><code> server { listen 80; listen [::]:80; root /var/www/test.ru/html; index index.php index.html index.htm index.nginx-debian.html; server_name test.ru www.test.ru; location / { try_files $uri $uri/ =404; } } </code></pre> <p>sudo service nginx reload sudo nginx -t</p> <pre><code> nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful </code></pre> <p>What is the reason for this behavoir ? How to set it up?</p> </div>

Nginx反向代理中绝对目录如何处理?

## 场景需求 现要设计一个对外网关服务器,代理众多公司内部的其他服务。 现在使用的方法为nginx反向代理。 Nginx.conf中代码如下 ``` location ^~ /services/ { ... proxy_pass 真实uri ... } ``` ## 遇到的问题 当某一个服务的html代码中包含对绝对目录的资源访问或者跳转时会出现问题。 比如要代理abc网站 10.10.10.10/ 该网站的html中包含对 /static/a.jpg资源的访问。 当用户访问我的网关服务器时,调用的方法依次为 Get www.xxx.com/services/abc Get www.xxx.com/static/a.jpg,此时会get失败。 现有的临时应对方法为在nginx.conf中添加对abc网站绝对目录的代理,如下 ``` location /static/ { proxy_pass http://10.10.10.10/static/; } ``` 但是如果服务一多,就会冲突。 请问问题如何解决? 谢谢各位大神浏览。

大学四年自学走来,这些私藏的实用工具/学习网站我贡献出来了

大学四年,看课本是不可能一直看课本的了,对于学习,特别是自学,善于搜索网上的一些资源来辅助,还是非常有必要的,下面我就把这几年私藏的各种资源,网站贡献出来给你们。主要有:电子书搜索、实用工具、在线视频学习网站、非视频学习网站、软件下载、面试/求职必备网站。 注意:文中提到的所有资源,文末我都给你整理好了,你们只管拿去,如果觉得不错,转发、分享就是最大的支持了。 一、电子书搜索 对于大部分程序员...

在中国程序员是青春饭吗?

今年,我也32了 ,为了不给大家误导,咨询了猎头、圈内好友,以及年过35岁的几位老程序员……舍了老脸去揭人家伤疤……希望能给大家以帮助,记得帮我点赞哦。 目录: 你以为的人生 一次又一次的伤害 猎头界的真相 如何应对互联网行业的「中年危机」 一、你以为的人生 刚入行时,拿着傲人的工资,想着好好干,以为我们的人生是这样的: 等真到了那一天,你会发现,你的人生很可能是这样的: ...

程序员请照顾好自己,周末病魔差点一套带走我。

程序员在一个周末的时间,得了重病,差点当场去世,还好及时挽救回来了。

ArrayList源码分析(入门篇)

ArrayList源码分析 前言: 写这篇博客的主要原因是,在我上一次参加千牵科技Java实习生面试时,有被面试官问到ArrayList为什么查找的速度较快,插入和删除的速度较慢?当时我回答得不好,很大的一部分原因是因为我没有阅读过ArrayList源码,虽然最后收到Offer了,但我拒绝了,打算寒假学得再深入些再广泛些,下学期开学后再去投递其他更好的公司。为了更加深入理解ArrayList,也为

我以为我学懂了数据结构,直到看了这个导图才发现,我错了

数据结构与算法思维导图

String s = new String(" a ") 到底产生几个对象?

老生常谈的一个梗,到2020了还在争论,你们一天天的,哎哎哎,我不是针对你一个,我是说在座的各位都是人才! 上图红色的这3个箭头,对于通过new产生一个字符串(”宜春”)时,会先去常量池中查找是否已经有了”宜春”对象,如果没有则在常量池中创建一个此字符串对象,然后堆中再创建一个常量池中此”宜春”对象的拷贝对象。 也就是说准确答案是产生了一个或两个对象,如果常量池中原来没有 ”宜春” ,就是两个。...

技术大佬:我去,你写的 switch 语句也太老土了吧

昨天早上通过远程的方式 review 了两名新来同事的代码,大部分代码都写得很漂亮,严谨的同时注释也很到位,这令我非常满意。但当我看到他们当中有一个人写的 switch 语句时,还是忍不住破口大骂:“我擦,小王,你丫写的 switch 语句也太老土了吧!” 来看看小王写的代码吧,看完不要骂我装逼啊。 private static String createPlayer(PlayerTypes p...

和黑客斗争的 6 天!

互联网公司工作,很难避免不和黑客们打交道,我呆过的两家互联网公司,几乎每月每天每分钟都有黑客在公司网站上扫描。有的是寻找 Sql 注入的缺口,有的是寻找线上服务器可能存在的漏洞,大部分都...

讲一个程序员如何副业月赚三万的真实故事

loonggg读完需要3分钟速读仅需 1 分钟大家好,我是你们的校长。我之前讲过,这年头,只要肯动脑,肯行动,程序员凭借自己的技术,赚钱的方式还是有很多种的。仅仅靠在公司出卖自己的劳动时...

上班一个月,后悔当初着急入职的选择了

最近有个老铁,告诉我说,上班一个月,后悔当初着急入职现在公司了。他之前在美图做手机研发,今年美图那边今年也有一波组织优化调整,他是其中一个,在协商离职后,当时捉急找工作上班,因为有房贷供着,不能没有收入来源。所以匆忙选了一家公司,实际上是一个大型外包公司,主要派遣给其他手机厂商做外包项目。**当时承诺待遇还不错,所以就立马入职去上班了。但是后面入职后,发现薪酬待遇这块并不是HR所说那样,那个HR自...

女程序员,为什么比男程序员少???

昨天看到一档综艺节目,讨论了两个话题:(1)中国学生的数学成绩,平均下来看,会比国外好?为什么?(2)男生的数学成绩,平均下来看,会比女生好?为什么?同时,我又联想到了一个技术圈经常讨...

副业收入是我做程序媛的3倍,工作外的B面人生是怎样的?

提到“程序员”,多数人脑海里首先想到的大约是:为人木讷、薪水超高、工作枯燥…… 然而,当离开工作岗位,撕去层层标签,脱下“程序员”这身外套,有的人生动又有趣,马上展现出了完全不同的A/B面人生! 不论是简单的爱好,还是正经的副业,他们都干得同样出色。偶尔,还能和程序员的特质结合,产生奇妙的“化学反应”。 @Charlotte:平日素颜示人,周末美妆博主 大家都以为程序媛也个个不修边幅,但我们也许...

MySQL数据库面试题(2020最新版)

文章目录数据库基础知识为什么要使用数据库什么是SQL?什么是MySQL?数据库三大范式是什么mysql有关权限的表都有哪几个MySQL的binlog有有几种录入格式?分别有什么区别?数据类型mysql有哪些数据类型引擎MySQL存储引擎MyISAM与InnoDB区别MyISAM索引与InnoDB索引的区别?InnoDB引擎的4大特性存储引擎选择索引什么是索引?索引有哪些优缺点?索引使用场景(重点)...

如果你是老板,你会不会踢了这样的员工?

有个好朋友ZS,是技术总监,昨天问我:“有一个老下属,跟了我很多年,做事勤勤恳恳,主动性也很好。但随着公司的发展,他的进步速度,跟不上团队的步伐了,有点...

我入职阿里后,才知道原来简历这么写

私下里,有不少读者问我:“二哥,如何才能写出一份专业的技术简历呢?我总感觉自己写的简历太烂了,所以投了无数份,都石沉大海了。”说实话,我自己好多年没有写过简历了,但我认识的一个同行,他在阿里,给我说了一些他当年写简历的方法论,我感觉太牛逼了,实在是忍不住,就分享了出来,希望能够帮助到你。 01、简历的本质 作为简历的撰写者,你必须要搞清楚一点,简历的本质是什么,它就是为了来销售你的价值主张的。往深...

玩转springboot启动banner定义所得

最近接手了一个springboot项目,不是不熟悉这个框架,启动时打印的信息吸引了我。 这不是我熟悉的常用springboot的打印信息啊,我打开自己的项目: 还真是的,不用默认的感觉也挺高大上的。一时兴起,就去研究了一下源代码,还正是有些收获,稍后我会总结一下。正常情况下做为一个老程序员,是不会对这种小儿科感兴趣的,不就是一个控制台打印嘛。哈哈! 于是出于最初的好奇,研究了项目的源代码。看到

带了6个月的徒弟当了面试官,而身为高级工程师的我天天修Bug......

即将毕业的应届毕业生一枚,现在只拿到了两家offer,但最近听到一些消息,其中一个offer,我这个组据说客户很少,很有可能整组被裁掉。 想问大家: 如果我刚入职这个组就被裁了怎么办呢? 大家都是什么时候知道自己要被裁了的? 面试软技能指导: BQ/Project/Resume 试听内容: 除了刷题,还有哪些技能是拿到offer不可或缺的要素 如何提升面试软实力:简历, 行为面试,沟通能...

离职半年了,老东家又发 offer,回不回?

有小伙伴问松哥这个问题,他在上海某公司,在离职了几个月后,前公司的领导联系到他,希望他能够返聘回去,他很纠结要不要回去? 俗话说好马不吃回头草,但是这个小伙伴既然感到纠结了,我觉得至少说明了两个问题:1.曾经的公司还不错;2.现在的日子也不是很如意。否则应该就不会纠结了。 老实说,松哥之前也有过类似的经历,今天就来和小伙伴们聊聊回头草到底吃不吃。 首先一个基本观点,就是离职了也没必要和老东家弄的苦...

男生更看重女生的身材脸蛋,还是思想?

往往,我们看不进去大段大段的逻辑。深刻的哲理,往往短而精悍,一阵见血。问:产品经理挺漂亮的,有点心动,但不知道合不合得来。男生更看重女生的身材脸蛋,还是...

为什么程序员做外包会被瞧不起?

二哥,有个事想询问下您的意见,您觉得应届生值得去外包吗?公司虽然挺大的,中xx,但待遇感觉挺低,马上要报到,挺纠结的。

当HR压你价,说你只值7K,你该怎么回答?

当HR压你价,说你只值7K时,你可以流畅地回答,记住,是流畅,不能犹豫。 礼貌地说:“7K是吗?了解了。嗯~其实我对贵司的面试官印象很好。只不过,现在我的手头上已经有一份11K的offer。来面试,主要也是自己对贵司挺有兴趣的,所以过来看看……”(未完) 这段话主要是陪HR互诈的同时,从公司兴趣,公司职员印象上,都给予对方正面的肯定,既能提升HR的好感度,又能让谈判气氛融洽,为后面的发挥留足空间。...

面试:第十六章:Java中级开发(16k)

HashMap底层实现原理,红黑树,B+树,B树的结构原理 Spring的AOP和IOC是什么?它们常见的使用场景有哪些?Spring事务,事务的属性,传播行为,数据库隔离级别 Spring和SpringMVC,MyBatis以及SpringBoot的注解分别有哪些?SpringMVC的工作原理,SpringBoot框架的优点,MyBatis框架的优点 SpringCould组件有哪些,他们...

面试阿里p7,被按在地上摩擦,鬼知道我经历了什么?

面试阿里p7被问到的问题(当时我只知道第一个):@Conditional是做什么的?@Conditional多个条件是什么逻辑关系?条件判断在什么时候执...

终于懂了TCP和UDP协议区别

终于懂了TCP和UDP协议区别

你打算用Java 8一辈子都不打算升级到Java 14,真香

我们程序员应该抱着尝鲜、猎奇的心态,否则就容易固步自封,技术停滞不前。

无代码时代来临,程序员如何保住饭碗?

编程语言层出不穷,从最初的机器语言到如今2500种以上的高级语言,程序员们大呼“学到头秃”。程序员一边面临编程语言不断推陈出新,一边面临由于许多代码已存在,程序员编写新应用程序时存在重复“搬砖”的现象。 无代码/低代码编程应运而生。无代码/低代码是一种创建应用的方法,它可以让开发者使用最少的编码知识来快速开发应用程序。开发者通过图形界面中,可视化建模来组装和配置应用程序。这样一来,开发者直...

面试了一个 31 岁程序员,让我有所触动,30岁以上的程序员该何去何从?

最近面试了一个31岁8年经验的程序猿,让我有点感慨,大龄程序猿该何去何从。

大三实习生,字节跳动面经分享,已拿Offer

说实话,自己的算法,我一个不会,太难了吧

程序员垃圾简历长什么样?

已经连续五年参加大厂校招、社招的技术面试工作,简历看的不下于万份 这篇文章会用实例告诉你,什么是差的程序员简历! 疫情快要结束了,各个公司也都开始春招了,作为即将红遍大江南北的新晋UP主,那当然要为小伙伴们做点事(手动狗头)。 就在公众号里公开征简历,义务帮大家看,并一一点评。《启舰:春招在即,义务帮大家看看简历吧》 一石激起千层浪,三天收到两百多封简历。 花光了两个星期的所有空闲时...

《经典算法案例》01-08:如何使用质数设计扫雷(Minesweeper)游戏

我们都玩过Windows操作系统中的经典游戏扫雷(Minesweeper),如果把质数当作一颗雷,那么,表格中红色的数字哪些是雷(质数)?您能找出多少个呢?文中用列表的方式罗列了10000以内的自然数、质数(素数),6的倍数等,方便大家观察质数的分布规律及特性,以便对算法求解有指导意义。另外,判断质数是初学算法,理解算法重要性的一个非常好的案例。

立即提问
相关内容推荐