【问题标题】:Two drupal installs in nginx在 nginx 中安装两个 drupal
【发布时间】:2014-09-04 09:27:46
【问题描述】:

我试图在 CENTOS 7 Digital Ocean 服务器上设置 2 个网站。

一个站点由/srv/http/eventadvisor.in/public_html 提供服务,另一个站点由/srv/http/eventadvisor.in/public_html 提供服务。

我在第一个目录中成功安装了 drupal。现在,当我重复第二个步骤时,它会自动从第一个站点的 settings.php 中获取设置并给出以下错误:

Drupal Already Installed
To start over, you must empty your existing database.
To install to a different database, edit the appropriate settings.php file in the sites folder.
To upgrade an existing installation, proceed to the update script.
View your existing site.

我正在运行具有以下 conf 文件的 nginx 服务器:

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

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

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*.conf;
}

每个站点的配置文件是:

server {
    listen       80;
    server_name sanjayshitole.com www.sanjayshitole.com *.sanjayshitole.com;

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

#    location / {
        root   /srv/http/sanjayshitole.com/public_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           /srv/http/eventadvisor.in/public_html;
        fastcgi_pass   unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

【问题讨论】:

    标签: php drupal nginx drupal-7


    【解决方案1】:

    我设法通过修改此博客中显示的配置解决了这个问题:Lelutin

    这是我运行良好的配置文件(对 centOS 进行了轻微的修改):

    server {
        server_name sanjayshitole.com;
        root /srv/http/sanjayshitole.com/public_html;
    
        index index.html index.htm index.php;
    
        access_log /var/log/nginx/sanjayshitole.comaccess.log;
        error_log /var/log/nginx/sanjayshitole.org.error.log;
    
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }
    
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
    
        # For drush
        location = /backup {
                deny all;
        }
    
        # Prevent user from accessing settings.php directly
        location ~ ^/sites/[^/]+/settings.php$ {
                deny all;
        }
    
        ## Replicate the Apache <FilesMatch> directive of Drupal standard
        ## .htaccess. Disable access to any code files. Return a 404 to curtail
        ## information disclosure. Hide also the text files.
        location ~* ^(?:.+\.(?:htaccess|make|txt|log|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(?:\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
                return 404;
        }
    
        location ~ \..*/.*\.php$ {
                return 403;
        }
    
        location / {
                # This is cool because no php is touched for static content
                try_files $uri @rewrite;
        }
    
        location @rewrite {
                # Some modules enforce no slash (/) at the end of the URL
                # Else this rewrite block wouldn't be needed (GlobalRedirect)
                #rewrite ^/(.*)$ /index.php?q=$1&$args;
                rewrite ^ /index.php last;
        }
    
        # Use an SSH tunnel to access those pages. They shouldn't be visible to
        # external peeping eyes.
        location = /install.php {
                allow 127.0.0.1;
                deny all;
        }
    
        location = /update.php {
                allow 127.0.0.1;
                deny all;
        }
    
     location ~ \.php$ {
                root /srv/http/sanjayshitole.com/public_html;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
                fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        }
    
    
        ## Drupal 7 generated image handling, i.e., imagecache in core. See:
        ## https://drupal.org/node/371374
        location ~* /sites/.*/files/styles/ {
                access_log off;
                expires 30d;
                try_files $uri @rewrite;
        }
    
        # Fighting with ImageCache? This little gem is amazing.
        location ~ ^/sites/.*/files/imagecache/ {
                try_files $uri @rewrite;
        }
    
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
    }
    

    我仍然想解释为什么 nginx 附带的默认 conf 不起作用,所以请随时回答这个问题。

    标清

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-27
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多