2

I've been searching through all the questions asked and all answers haven't worked. I'm trying to install Damn Vulnerable Web App to my Centos 6.9 server, but when I try to access the page, I'm greeted with a 404 File Not Found error. I can access html files perfectly, just not PHP.

/etc/nginx/conf.d/default.conf:

server {
listen   80;
server_name  localhost;

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm index.php;
}

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

location ~ \.php$ {
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    include        fastcgi_params;
}


}

Can anyone help at all please?

UPDATE: After multiple attempts, below are the updated files. Now getting a 'File Not Found' even though the files reside within the root directory stated in the default.conf file.

/etc/nginx/conf.d/default.conf:

server {
listen   80;
server_name  localhost;
root /usr/share/nginx/html;

location / {
   # root   /usr/share/nginx/html;
    #index  index.html index.htm index.php;
}

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}
location ~ \.php$ {
    include        fastcgi_params;
    root           html;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    try_files $uri =404;
}

}

/etc/nginx/fastcgi_params:

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      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  REQUEST_SCHEME     $scheme;
fastcgi_param  HTTPS              $https if_not_empty;
fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
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;

The changes seen in other questions haven't had any positive effect.

THIS HAS BEEN SOLVED. The location in default.conf was pointing to 'html' where it should have been '/usr/share/nginx/html'.

14
  • What do your error logs say? Do you have PHP installed? Commented Apr 10, 2017 at 15:39
  • And do you have the php-fpm service running? Commented Apr 10, 2017 at 15:40
  • PHP-fpm service is running and the logs say absolutely nothing: [10-Apr-2017 16:18:14] NOTICE: fpm is running, pid 8875 [10-Apr-2017 16:18:14] NOTICE: ready to handle connections Commented Apr 10, 2017 at 15:44
  • Do a curl --head <url> to see what HTTP status you're getting. If it's a PHP issue, you'll get a 5XX. If it's an nginx issue, you'll get a 4XX. (Generally.) Commented Apr 10, 2017 at 15:48
  • # curl --head 192.168.56.11:8080/dvwa/setup.php HTTP/1.1 400 Bad Request Server: Apache-Coyote/1.1 Transfer-Encoding: chunked Date: Mon, 10 Apr 2017 15:49:42 GMT Connection: close Commented Apr 10, 2017 at 15:50

1 Answer 1

1

THIS HAS BEEN SOLVED. The 'root' in default.conf/location ~ .php$ was pointing to 'html' where it should have been '/usr/share/nginx/html'.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.