0

I have a django running on example.com, i need add a Wordpress to my server, would be example.com/blog, perhaps doesnt work (404 error):

listen      80;
server_name www.example.com;    

location ^~ /blog/ {
        root    /www/blog;
        index   index.html index.htm index.php;
        try_files  $uri =404;

        location ~ \.php {
                root /www/blog;
                fastcgi_split_path_info ^(.*\.php)(.*)$;
                include fastcgi_params;

                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_param PATH_INFO $fastcgi_path_info;
                fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
                fastcgi_pass 127.0.0.1:9000;
        }

}

location / {
    uwsgi_pass  unix:/tmp/myapp.sock;
    include     /www/webapp/system/uwsgi_params; # the uwsgi_params file you installed
    uwsgi_read_timeout 300;
}

2 Answers 2

1

I ran in this problem too. Here, you can check my location config.

location /blog {
    root /var/www/html; 

    try_files $uri $uri/ /blog/index.php?$args;
    index index.php; 

    location ~ [^/]\.php(/|$) { 
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;

        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php; 
    } 

}

Adapted for your config:

location /blog {
     root    /www/blog; 

    try_files $uri $uri/ index.php?$args;
    index index.php; 

    location ~ [^/]\.php(/|$) { 
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;

        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO       $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php; 
    } 

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

4 Comments

wordpress folder is /www/blog/index.php but nginx is searching in "/usr/share/nginx/htmlindex.php"
@user2925795 I think you should let the / in /index.php? But I don't know why are u getting 404.
Is giving 404 coz he searches wordpress in "/usr/share/nginx/htmlindex.php" ... where he should look in / www/blog/ how i change this?
@user2925795 add / to index.php, like this : try_files $uri $uri/ /index.php?$args;
0

@Levi configuration give me some light, i need to modify because i'm getting 404 error or No input file especified.

    location /blog {
         alias    /www/blog;

        try_files $uri $uri/ index.php?$args;
        index index.php;

        location ~ [^/]\.php(/|$) {
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;

            include fastcgi_params;
            fastcgi_param  SCRIPT_FILENAME  /www/blog$fastcgi_script_name;
            fastcgi_param SCRIPT_FILENAME $request_filename;

            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
        }

    }

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.