search

Home  >  Q&A  >  body text

Problem with nginx configuring discuz second-level domain name

My discuz is placed in the second-level directory of bbs, and the first-level directory contains the wordpress mu program. My nginx configuration is as follows:

    log_format  vfcai.com  '$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';


server
    {
        listen       80;
        server_name vfcai.com *.vfcai.com;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /data/wwwroot/vfcai.com;

        include wordpress.conf;
        location ~ .*\.(php|php5)?$
            {
                try_files $uri =404;
                fastcgi_pass  unix:/tmp/php-cgi.sock;
                fastcgi_index index.php;
                include fcgi.conf;
            }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
            {
                expires      30d;
            }

        location ~ .*\.(js|css)?$
            {
                expires      12h;
            }

        access_log  /home/wwwlogs/vfcai.com.log  vfcai.com;
    }
server 
{ 
    server_name www.vfcai.com;
    rewrite ^(.*) http://vfcai.com/ permanent; 
}
server
{
    server_name bbs.vfcai.com;
    index index.htm index.html index.php;
    root /data/wwwroot/vfcai.com/bbs/;
    location ~ .*\.(php|php5)?$
    {
        try_files $uri =404;
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_NAME        /bbs/$fastcgi_script_name;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
        expires      30d;
    }

    location ~ .*\.(js|css)?$
    {
        expires      12h;   
    }
}

When I access my website through bbs.vfcai.com, the download of index.php will appear, and I cannot access the website normally. What is wrong with my nginx configuration?

PHP中文网PHP中文网2747 days ago767

reply all(2)I'll reply

  • 大家讲道理

    大家讲道理2017-05-16 17:30:48

    Your configuration of bbs.vfcai.com is completely wrong. You have not configured fastcgi, so you will definitely download the file!

    reply
    0
  • PHPz

    PHPz2017-05-16 17:30:48

    It is recommended to re-read the configuration method of nginx and learn from the basics instead of copying the configuration online. Visit bbs.vfcai.com, the first location configuration policy of the first server will respond, which cannot achieve the response you want the policy configured on the third server.

    reply
    0
  • Cancelreply