Configuring Drupal for Upstream Deployment - drupal

I'm trying to help a co-worker configure a Drupal site so that we can deploy the same site upstream without making database changes. We're having trouble with file paths. Here's what I have:
A Nginx webroot pointing to the root of my Drupal 6 (in this case) install (/opt/frameworks/drupal-6).
The content for this site is in /opt/www/my-site.
A symlink exists in /opt/frameworks/drupal-6/sites: dev-my-site -> /opt/www/dev-my-site
Because of some sharing that's going on, there are multiple versions of my-site on the box, so they have to have different symlink names. Right now, the "file system path" is set to sites/dev-my-site/files which breaks when moved upstream.
Is there a way that I can set a configuration variable to override the database setting? Or is there a better way to configure my webroot and sites? I don't know much about Drupal, but I'd like to build this out so that deployments are as simple as possible.

A bunch of trial and error by 2 inexperienced Drupal folks has led to a possible solution. It looks like setting the $conf['file_system_directory'] in settings.php does exactly what we need. Each site on each box will have it's own settings file that isn't touched by deployments, so we might be all good.
If there's a better way or if there are unintended side effects to this particular way, I'd love to hear answers from more experienced Drupal admins.

Related

/tmp file name collisions when hosting hundreds of small Drupal sites

We host a few hundred small Drupal 6 & 7 websites on a single Debian virtual machine. Each of these sites has it's own Drupal code base and database.
When we had each site using /tmp as the "Temporary files" folder in Drupal, we would occasionally have file name collisions across sites.
Is making a /tmp/site_name folder for each site our only option to stop these file collisions?
Multisite doesn't make sense when you do multiple sites for many clients. They are on different boxes sometimes (their hosting), and it just is cleaner to have version control for each site/drupal folder vs trying to put 200 sites in 1 svn project for the 200 clients. For us, we had a demo server for each of these sites. and standalone folders mapped to demo1.test.com, demo2.test.com... I got some issues when duplicating a site to another test subdomain server. The error had some /tmp message in it and some other complaints and Denied Access to my site. The error seemed to go away after refreshing the site. but not sure if visiting many sites at a time will cause issue to popup again... Maybe in the long run it makes sense to have a special tmp folder for each site. maybe like you suggested /tmp/site_name or ../tmp if can use file structure like: /var/www/vhosts/site1/public (for drupal sites) /var/www/vhosts/site1/tmp (for tmp dir)... not sure what perms to give it though.
try to install Drush on your virtual server, as it will help you a lot
Drupal provide multisite concept where you can use same module for all sites.
https://drupal.org/documentation/install/multi-site

Drupal Export of Site Not Working For Subdirectory Levels Beyond Root Directory

I have to move an existing Drupal site from one server to another. I've done so by doing a mysql database export/import and copying over the files to the new server. On the new system, the root page comes up fine but if I try to go to any deeper directory levels I get a 404 Not Found Error.
so drupal.newserver.com -> works fine
but drupal.newserver.com/user -> gives me a 404 and happens,same for all subdirectories
Is there something that I'm missing that is part of a drupal export? Could it be related to the structure of the /sites directory which is under the webserver's docroot?- which has a folder named after the old server (ie drupal.oldserver.com but not drupal.newserver.com? Also, I noticed that there are _htaccess files and .hta files but not .htaccess files in the site files that I've copied over.
Sorry if I'm asking a bleedingly obvious question - I'm very new to Drupal. Thank you!
Check whether the clean url is enabled in your web server. To check try this:
drupal.newserver.com/?q=user.
Just to let anyone who might come across via a google search - I was able to get this to work . It turns out that while mod_rewrite was enabled, what I had to do was to enable the AllowOverride directive for the web directory in httpd.conf to be set to ‘All’. If it’s not set to this, the server won’t respect the .htaccess rules you put into the drupal directory. It’s been a while since I’ve worked with apache config files so it took a while to finally piece it together. The main breakthrough came when I realized that if I turned off clean-urls then the links worked but looked ugly and then was able to research clean_url.

WordPress hosted on Azure won't allow media file uploads due to bad temp folder

After recent upgrade to latest WordPress version, media uploads no longer work. They return missing temp folder error.
I found out that WP thinks that /wwwroot/wp-admin/ is the temp folder, that's where it is trying to send uploads.
I tried everything to force it to change within WordPress. Setting WP_TEMP_DIR, even tried rewriting core function that looks for temp folder in /wp-includes/text/Diff.php and setting static path.
Nothing works. I don't really know much about Azure, so it's been a pain in the butt.
My last resort is to install and use Azure Storage plugin for WP, but that's last resort.
Anyone can shed some light on this issue? Would greatly appreciate it.
UPDATE: Site is a Azure website, it does not use Azure instance.
http://www.windowsazure.com/en-us/home/features/web-sites/
I'm not to sure about Azure but you can change the tmp directory WordPress uses by using the command below. Make sure to make a folder in your home directory before doing so.
wp-config
define('WP_TEMP_DIR','/link-to-your-folder-you-just-made');
First of all, you should never store anything on an Azure instance, consider it volalite storage just like RAM - if the instance goes down or even gets randomly restarted you could literally get a brand new virtual machine with a new file system and lose everything.
That being said, you can safely RDP into the instance - create a directory (c:\temp for example) and as long as the IIS account has rights over the directory you won't have any issues using it as scratch storage. I would use Andy's approach above (I don't know wordpress, but I know Azure) and simply make sure that it points to a directory that you can use as temp and that the IIS user can safely use.
You may want to log in to the VM with RDP if only for the additional reason that it will give you great insight in how Azure structures the file system for the software it runs, you will see 3 drives and if memory serves one of them is purely a scratch drive that you can use. But it's not persistent, consider that it can get cleared at any moment.
Hope this helps,

Referencing Assets in Drupal

I'm helping a colleague configure a new box for an existing Drupal install with multiple sites. It's functioning, but I've noticed that all assets are being referenced as /sites/<site-name>/files/image.png. I don't know from Drupal, but it strikes me that Drupal should be abstracting the logical site from the code so that site-specific assets could be referenced as /files/image.png and Drupal would figure out -- perhaps based on HTTP_HOST -- which site is meant.
In this case, we need separate snapshots of the same site (dev and staging) so we'd like to be able to store the paths without specifically referencing one site or the other. We can do some rewriting to manage this, but I'm wondering whether there's something that we simply don't know.
Does Drupal do this natively in some way? If not, what are others doing to manage this kind of abstraction? Surely we're not the first to encounter this and think there must be a better way.
Thanks.
That would be an interesting module. The Files directory can be in the following locations:
sites/<site name>/files (standard for multi sites, public)
or
sites/default/files (standard installation for single sites, public)
That is, if you want to use the public files method.
Read here if you want to learn about the private files method (very similar to your thought): http://drupal.org/documentation/modules/file

Seeking good practice advice: multisite in Drupal

I'm using multisite to host my client sites.
During development stage, I use subdomain to host the staging site, e.g. client1.mydomain.com.
And here's how it look under the SITES folder:
/sites/client1.mydomain.com
When the site is completed and ready to go live, I created another folder for the actual domain, e.g. client1.com.
Hence:
/sites/client1.com
Next, I created symlinks under client1.com for FILES and SETTINGS.PHP that points to the subdomain
i.e.
/sites/client1.com/settings.php --> /sites/client1.mydomain.com/settings.php
/sites/client1.com/files --> /sites/client1.mydomain.com/files
Finally, to prevent Google from indexing both the subdomain and actual domain, I created the rule in .htaccess to rewrite client1.mydomain.com to client1.com, therefore, should anyone try to access the subdomain, he will be redirected to the actual domain.
This above arrangement works perfectly fine. But I somehow feel there is a better way to achieve the above in much simplified manner. Please feel free to share your views and all advice is much appreciated.
Since it seems you want to reuse the files/ directory and settings.php from your development domain, I'd suggest using the default/ directory + symlinks to achieve your goals.
ie, during development
sites/default/settings.php
sites/default/files/
sites/client1.domain.com -> sites/default (symbolic link)
once you're ready to switch over to their domain:
sites/client1.com -> sites/default
You can then remove client1.domain.com from your virtual host (or continue with your rewrite, etc...).
It will accomplish the same as your method, but you get the added "protection" of all requests going to default in case you add an additional domain at a later date as an alias (for example).
If you're simply sharing core and module files between the sites, you can use a different symlink layout.
In my setup I have all of the shared files in a common, non-web-accessible directory:
/var/www/drupal
/var/www/drupal/sites/all/modules
then for each deployment, common files and folders are symlinked to those files.
/var/www/client1/public_html/index.php -> /var/www/drupal/index.php
/var/www/client1/public_html/includes -> /var/www/drupal/includes
...
/var/www/client1/public_html/sites/all -> /var/www/drupal/sites/all
Then you can place the site's settings.php and any modules or themes for only that site in the default sites directory
/var/www/client1/public_html/sites/default
This layout also offers you the flexibility to override any common files as necessary, such as .htaccess.
To move from staging to production, you will just have to modify your virtual-host configuration from the staging to production domain name.
If you don't like a ton of symlinks, another option is using the Aliased Multi-Site Support patch:
http://drupal.org/node/231298#comment-1420180
This will allow you to specify in configuration that any requests for client1.domain.com should actually use /sites/client1.com/ instead of /sites/client1.domain.com/.
Then when you move to production, you can just remove the configuration setting (though it doesn't hurt anything if you don't).
This feature is part of Drupal 7, but as a new feature won't be added to Drupal 6. More good news is that you won't even need to use it in D7 just for file paths, since instead of storing the full path to files in the database, they use a schema such as public:// or private:// which Drupal then maps to the correct file system path, allowing multiple storage types/locations with much better portability.

Resources