2014-09-04 22 views
1

我試圖在CENTOS 7數字海洋服務器上建立2個網站。在nginx上安裝兩個drupal

一個網站將由/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; 
    #} 
} 

回答

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; 
    } 
} 

我還是想的,爲什麼默認的conf附帶nginx的沒有工作,所以一個解釋,請隨時回答這個問題。

SD