Problem with nginx configuring discuz second-level domain name
PHP中文网
PHP中文网 2017-05-16 17:28:48
0
2
764

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中文网

认证0级讲师

reply all(2)
大家讲道理

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

PHPzhong

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template