Home > OS >  Nginx 1.16 can run under the root directory of the PHP file, but PHP files under the project file is
Nginx 1.16 can run under the root directory of the PHP file, but PHP files under the project file is

Time:10-01

CentOS7 + Nginx1.16 + php7.2, why the root directory to open the PHP files, directories, there is no way to parse.
Nginx configuration below
 # user nobody; 
Worker_processes 1;

# error_log logs/error. The log;
# error_log logs/error log notice;
# error_log logs/error. The log info;

# pid logs/nginx. Pid;


Events {
Worker_connections 1024;
}


HTTP {
. Include the mime types;
Default_type application/octet - stream;

# log_format main '$remote_addr - $remote_user [$time_local] "$request"'
# '$$body_bytes_sent status "$http_referer"'
# '" $http_user_agent "" $http_x_forwarded_for"';
# access_log logs/access. Log the main;

Sendfile on;
# tcp_nopush on;

# keepalive_timeout 0;
Keepalive_timeout 65;

# gzip on;

Server {
listen 80;
Server_name localhost.

# charset koi8 - r;

# access_log logs/host. Access. Log the main;

The location/{
The root HTML;
Index index. HTML index. HTM index. PHP;
}

404/404 # error_page. HTML;

# redirect server error pages to the static page/50 x) HTML
#
Error_page 504/50, 500, 502, 503 x. HTML;
Location=/50 x) HTML {
The root HTML;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
# the location ~ \. PHP ${
# proxy_pass http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
The location ~ \. PHP ${
The root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index. PHP;
Fastcgi_param SCRIPT_FILENAME $$fastcgi_script_name document_root;
The include fastcgi_params;
}

# to deny access to...htaccess files, if the Apache 's document root
# concurs with nginx 's one
#
# the location ~/\. Ht {
# deny all;
#}
}


# another virtual host using mix of IP -, name, and port - -based configuration
#
# server {
# 8000; listen
# listen somename: 8080;
# server_name somename alias another. Alias;
# the location/{
# root HTML;
# index index. HTML index. HTM;
#}
#}


# HTTPS server
#
# server {
443 the SSL # listen;
# server_name localhost.

# ssl_certificate cert. Pem;
# ssl_certificate_key cert. Key;

# ssl_session_cache Shared: SSL: 1 m;
# ssl_session_timeout 5 m;

# ssl_ciphers HIGH:! ANULL:! MD5;
# ssl_prefer_server_ciphers on;

# the location/{
# root HTML;
# index index. HTML index. HTM;
#}
#}

}

The error log:
[error] # 0:16704 * 311 FastCGI sent in stderr: "Unable to open primary script:/usr/local/nginx/HTML/39.98.43.18/test/code, PHP (Operation not permitted)" while reading the response headers from upstream, client: 192.168.0.101, server: localhost, the request: "GET/39.98.43.18/test/code. HTTP/1.1 PHP", upstream: FastCGI://127.0.0.1: "9000", the host: "26 m106z396. Wicp. VIP," referrer: "http://26m106z396.wicp.vip/39.98.43.18/test/index.html"

CodePudding user response:

Nginx server root directory is the HTML folder, HTML folder a phpinfo. PHP can access, but HTML subfolders under other PHP is not find a 404 error,

CodePudding user response:

Some of the methods tested online, no matter use,

CodePudding user response:

The error log:
 [error] # 0:16704 * 311 FastCGI sent in stderr: "Unable to open primary script:/usr/local/nginx/HTML/39.98.43.18/test/code, PHP (Operation not permitted)" while reading the response headers from upstream, client: 192.168.0.101, server: localhost, the request: "GET/39.98.43.18/test/code. HTTP/1.1 PHP", upstream: FastCGI://127.0.0.1: "9000", the host: "26 m106z396. Wicp. VIP," referrer: "http://26m106z396.wicp.vip/39.98.43.18/test/index.html" 

CodePudding user response:

Don't tip Operation not permitted, 777
  • Related