drupal 7 in www/mysite, with virtual host name and clean url

654 views
Skip to first unread message

katrien

unread,
Feb 13, 2015, 5:23:44 PM2/13/15
to wpn...@googlegroups.com
I'm trying to run drupal 7 (Open Atrium distro) in www/mysite with the virtual server name www.mysite.be, with clean url enabled.

Out of the box my drupal sites installs, but during the process I get " 
Warning: file_put_contents(temporary://fil150F.tmp): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" ...

I tried hardcoding WPN-XM's default temp directory in my drupal settings.php
$conf['file_temporary_path'] = '//temp';
no success, installation is stuck now

Before that I have tried perusio's settings for nginx-drupal in a custom mysite.conf in sites-enabled, giving a lot of nginx errors.

Any help on how to get this working would be much appreciated.

WPN-XM

unread,
Feb 13, 2015, 8:07:13 PM2/13/15
to wpn...@googlegroups.com
Hello Katrien!

We provide default configs for Codeigniter, Laravel and Xenforo over at https://github.com/WPN-XM/WPN-XM/tree/master/configs/nginx/conf/domains-disabled
Maybe you can derive a configuration from these examples.

I found a drupal-nginx.conf - but it's untested.
It would be nice, if you could provide some feedback on it - so that we get a working version, which we can include as default configuraton for Drupal.

Looking forward hearing from you,
Jens


server { 
 
 listen 127.0.0.1:80; root www/drupal;
 
 # Enable compression, this will help if you have for instance advagg module
 # by serving Gzip versions of the files.
 gzip_static on;
 
 location = /favicon.ico {
  log_not_found off;
  access_log off;
 }
 
 location = /robots.txt {
  allow all;
  log_not_found off;
  access_log off;
 }
 
 # This matters if you use drush prior to 5.x
 # After 5.x backups are stored outside the Drupal install.
 #location = /backup {
 # deny all;
 #}
 
 # Very rarely should these ever be accessed outside of your lan
 location ~* \.(txt|log)$ {
  allow 192.168.0.0/16;
  deny all;
 }
 
 location ~ \..*/.*\.php$ {
  return 403;
 }
 
 # No no for private
 location ~ ^/sites/.*/private/ {
 return 403;
 }
 
 # Block access to "hidden" files and directories whose names begin with a
 # period. This includes directories used by version control systems such
 # as Subversion or Git to store control files.
 location ~ (^|/)\. {
  return 403;
 }
 
 location / {
 # This is cool because no php is touched for static content
  try_files $uri @rewrite;
 }
 
 location @rewrite {
 # You have 2 options here
 # For D7 and above:
 # Clean URLs are handled in drupal_environment_initialize().
 rewrite ^ /index.php;
 # For Drupal 6 and bwlow:
 # 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;
 }
 
 location ~ \.php$ {
 fastcgi_split_path_info ^(.+\.php)(/.+)$;
 #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $request_filename;
 fastcgi_intercept_errors on;
 fastcgi_pass unix:/tmp/phpfpm.sock;
 }
 
 # Fighting with Styles? This little gem is amazing.
 # This is for D6
 #location ~ ^/sites/.*/files/imagecache/ {
 # This is for D7 and D8
 location ~ ^/sites/.*/files/styles/ {
 try_files $uri @rewrite;
 }
 
 location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
  expires max;
  log_not_found off;
 }
 
}

katrien

unread,
Feb 14, 2015, 10:43:13 AM2/14/15
to wpn...@googlegroups.com
Thanks for your reaction Jens,

this is the same config I tested before. The site is running BUT: 
  • my site was loading as flat html, without any markup. I found the solution in this post https://www.drupal.org/node/2268989 with followin steps 
    • Goto the path admin/config/development/performance
    • Find the section BANDWIDTH OPTIMIZATION.
    • Uncheck the options "Aggregate and compress CSS files" and "Aggregate JavaScript files." 
    • > Probably you can uncheck these variables in your settings.php before installing ??
  • The site now looks normally but I still get this warning on top: Warning: file_put_contents(temporary://fil86BD.tmp): failed to open stream: "DrupalTemporaryStreamWrapper::stream_open" call failed infile_unmanaged_save_data() (line 1936 of A:\WPN\www\bcnatuurlso\includes\file.inc). The file could not be created.   > I think something is still wrong with the location or permissions of my local temp directory, tried 
    • //temp (above root) 
    • sites/default/files/tmp
  • Clean url test keeps failing. I experimented with all of these variants (read an tried every single google result on 'nginx clean url' ):
    • try_files $uri $uri/ @rewrite;
    • try_files $uri @rewrite;
    • try_files   $uri $uri/ /index.php;
    • try_files $uri $uri/ /index.php?$args;
  • Following line  fastcgi_pass unix:/tmp/phpfpm.sock; makes nginx complain: "the unix domain sockets are not supported on this platform in upstream "unix:/tmp/phpfpm.sock" so I disable it
  • Maybe someone can help me fix these problems?

katrien

unread,
Feb 14, 2015, 11:01:59 AM2/14/15
to wpn...@googlegroups.com
Ok, just got rid of the warning. I realized that i was still hardcoding the //temp directory in my drupal settings.php ... after removing that line setting the temp directory ro 'sites/default/files/tmp' solved the problem.

Only issue left is the clean urls ...

Jens-André Koch

unread,
Feb 14, 2015, 2:39:10 PM2/14/15
to wpn...@googlegroups.com
Reproduce Steps:

2. Extract into c:\server\www
3. rename versionized folder to just "drupal" = full path to drupal = c:\wpn-xm\www\drupal
4. run drupal install - http://localhost/drupal/install.php
5. activate extensions: gd2, mbstring, restart php
6. reload install page, all green, proceed
7. before fill the database dialog, create database "drupal" in adminer, then use that as db in dialog
8. proceed with install steps until done


----------

9. Enable access via "drupal.dev"

9.1 modify / check nginx.conf for the following directive in your server block

    # Make site accessible from http://drupal.dev/
    server_name drupal.dev;

9.2 add "drupal.dev" to your "hosts" file

    - manually

    - Steps for the WPN-XM Server Control Panel:
      - right-click tray icon
      - "Manage Hosts"
      - "Add"
      - Data "127.0.01" "drupal.dev"
      - Click Ok.
      - The Windows Permissions Dialog pops up.
      - Click Ok, to allow writing to the "hosts" file.
      - (If Anti-Virus tool blocks writing to the hosts file, disable AV it, repeat the steps, enable it again.)

9.3 Restart Nginx

Use the URL "http://drupal.dev" in your browser.

10. Drupal "Clean URLs"

Two things are needed (a) Nginx Rewriting the URL and (b) Drupal accepting the rewritten URL.
a) is done by a rewrite rule
b) is done by enabling "Clean URLs" in the Drupal Configuration

Important Notice:

The short/nice/clean URLs work only for URLs starting with "http://drupal.dev/" not for "localhost".
Using megaphone: not working on "localhost" - use "drupal.dev".

10.1 Nginx Conf for Drupal (a)


10.2 Testing "Clean URLs"

Response: {"status":true}

10.3 Enabling "Clean URLs" (b)

  Check Checkbox.
  Save.

Final Checks:

katrien

unread,
Feb 15, 2015, 7:57:13 PM2/15/15
to wpn...@googlegroups.com
Thank you very much for this step-by-step outline.

Step 9.1 is not completely clear to me. Should I add this line in the existing server block for localhost? in a new empty server block? or in the sites-enables/drupal.conf?

My experience: 
Since I used the host manager, and afterwards edited the .host file manually, the WPN-XM user interface has started crashing on startup.
I tried reinstalling everything (wpn, drupal open atrium, database, ...) 3x over (using the 'start all' and 'stop all' shortcuts), 
but can't get things normal again, and when I try to access my site from the server_name (f.i. 'drupal.dev', the page keeps redirecting to the webinterface of wpn-xm 'drupal.dev/tools/webinterface', ending in 404 not found. Maybe .hosts got corrupted?

Open Atrium uses 'spaces'. I read here that this would ask for another rewrite?

Anyway, i tried the same steps with a normal drupal install and also can't get vhost working. I keep trying ...

Op vrijdag 13 februari 2015 23:23:44 UTC+1 schreef katrien:
Reply all
Reply to author
Forward
0 new messages