Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
2.6k views
in Q2A Core by
I bought a digitalocean vps with an ubuntu os . I upload q2a program into it and I found error occurred. I use nginx for web server. But nginx doesnot find my q2a page. Who can give me a nginx on ubuntu cvonfig file to solve this problem ?I really need it .Please help, thank you.
by
Do any of the related questions help? This has been asked many times before.
by
I have seen related questions, but they don't help, they don't work in my server. I have to configure my server again. Someone tell me I must write rewrite rule for my server. But I cannot do it.  I really need a complete config file, please help, thank you

2 Answers

+2 votes
by
selected by
 
Best answer

Working config for znauka.ru, working on nginx and php 7:

server {
    server_name znauka.ru;
    access_log    /var/log/nginx/access.log;
    error_log    /var/log/nginx/error.log;
    root     /usr/share/nginx/html;

    gzip on;
    gzip_min_length    1000;
    gzip_proxied    any;
    gzip_types        text/plain application/xml application/x-javascript text/javascript text/css text/json application/javascript;
    gzip_disable    "msie6";
    gzip_comp_level    5;
    gzip_vary on;

    location / {
        index  index.php index.html index.htm;
        if (!-f $request_filename) {
            rewrite ^/(.+)?$ /index.php?qa-rewrite=$1 last;
        }
    }

    # Own cache plugin
    #location ~^/([0-9]*)/(.*)$ {
    #    set $cache_file $1;
    #    set $redirect 0;
    #    if ( $http_cookie ~* qa_session ) {
    #        set $redirect 1;
    #    }
    #    if ( $request_method = POST ) {
    #        set $redirect 1;
    #    }
    #    if ( $redirect = 1 ) {
    #        return 412;
    #        error_page 412 = @runphp;
    #    }
    #    types {}
    #    default_type text/html;
    #    try_files /qa-plugin/cache-master/cache/$cache_file @runphp;
    #}  

    location @runphp {
        rewrite ^/(.+)?$ /index.php?qa-rewrite=$1 last;
    }
    
    location = /sitemap.xml {
        try_files $uri @runphp;
    }

    location ~* \.(jpg|jpeg|gif|png|css|js|ico|xml)$ {
        access_log        off;
        log_not_found     off;
        expires           1d;
    }

    location ~ /\. {
        access_log off;
        log_not_found off;
        deny all;
    }

    location ~ \.php$ {
        fastcgi_index index.php;
        include /etc/nginx/fastcgi_params;
        if ( -f $request_filename ) {
            #fastcgi_pass  127.0.0.1:9000;
            fastcgi_pass   unix:/var/run/php/php7.0-fpm.sock;
        }
        fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    }
}

 

by
Can you tell me how to configure nginx? I mainly configure /etc/nginx/sites-available/default file .But now itdoesnot work. Something wrong happened to this file.What is the difference between sites-available/default and sites-enabled/default ?May i delete this file and replace it with the file you bring me ?Do you use php-fastcgi or php-fpm? I use php-fastcgi so the file you give me isnot workable in my server.I want to invite you to configure my server. Do you have time?If you are online,please send me a message.Thank you.
by
this not server block wait for easly config
+1 vote
by
location /wordpresssubfolder {
                index index.php index.html index.htm;
                try_files $uri $uri/ /wordpresssubfolder/index.php?q=$uri&$args;
        }
 
        location /question2answer {
                index index.php index.html index.htm;
                 if (!-e $fastcgi_script_name) {
                rewrite ^/qa/(.+)?$ /question2answer/index.php?qa-rewrite=$1 last;
         }

}

        location /wordpresssubfolder5 {
                index index.php;
                try_files $uri $uri/ /wordpresssubfolder5/index.php?q=$uri&$args;
        }
                      
        location /wordpresssubfolder3 {
                index index.php;
                try_files $uri $uri/ /wordpresssubfolder3/index.php?q=$uri&$args;
        }      

        location /wordpresssubfolder1 {
                index index.php index.html index.htm;
                try_files $uri $uri/ /wordpresssubfolder1/index.php?q=$uri&$args;
        }                                                                 

        location /wordpresssubfolder2 {
                index index.php index.html index.htm;
                try_files $uri $uri/ /wordpresssubfolder2/index.php?q=$uri&$args;
        }
by
It has really refused to work for me
...