1

i apologize for my english first and i cant put link.
here is my situation.

  • i got nginx server and php-fpm server.

  • after setup and configured, i can run http//nginx/info.php or http//nginx/index.php where 'http//nginx/' is in nginx sever, and info.php and index.php is located in php-fpm server.

  • the problem is when i browse http//nginx/website/index.php, I'm getting error 404 not found and when i browse for that file in php-fpm server, it's there but i still get 404 not found

  • changed permission to nginx:nginx and 777

-----------------------------------------------------------------------------------------------------------------------------------.

here is my nginx server default.conf

upstream php{
        server 10.21.35.230:9000;
        }
server {
    listen       80;
    server_name  10.21.35.230;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /var/www/html;
        index  index.php index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

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


    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /var/www/html;
        fastcgi_pass   10.21.35.230:9000;
        fastcgi_index  index.php;
        fastcgi_intercept_errors on;
        fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;
        include      fastcgi_params;
    }
        #user configuration
        tcp_nodelay off;
        open_file_cache max=1000 inactive=120s;
        open_file_cache_valid 45s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

-----------------------------------------------------------------------------------------------------------------------------------. here is my php-fpm server www.conf file

; Start a new pool named 'www'.
[nginx]
user = nginx
group = nginx
listen = 10.21.35.230:9000
listen.owner = nginx
listen.group = nginx
listen.mode = 0777
listen.allowed_clients = 10.21.35.228

-----------------------------------------------------------------------------------------------------------------------------------. here is the print screen

5
  • Where are your static files located? Commented Sep 11, 2017 at 16:05
  • its in php-fpm server Commented Sep 12, 2017 at 0:59
  • Php-fpm should not serve static files and in your config it only serves php files. You need to configure a additional block for static files with root defined Commented Sep 12, 2017 at 4:56
  • you mean i need to put those files in nginx server? Commented Sep 13, 2017 at 6:37
  • Yes static files are served using nginx Commented Sep 13, 2017 at 6:40

1 Answer 1

1

Php-fpm should not serve static files and in your config it only serves php files. You need to configure a additional block for static files with root defined

something like

location /www {
   root <folder path where /www is located>;
   try_files $uri =404;
}
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.