6 Jun 2007 Drupal Handbook

Table of Contents

Installation and configuration ...... 1 System requirements ...... 2 Client System Requirements ...... 3 Javascript ...... 3 CSS ...... 4 RSS ...... 4 Browser Specifics ...... 4 Browser Popularity ...... 4 Known Problems ...... 4 Validation ...... 4 Caveats ...... 4 HOWTO: Server requirement recommendations for your consulting clients .. . 5 Message to the Client ...... 5 Benchmark ...... 6 What Drupal.org runs on ...... 6 Requirements - older versions ...... 6 Installing Drupal, modules and themes ...... 8 Installing Drupal ...... 8 Formatted Drupal 5.x Installation instructions for better readability .. . . 13 Installation ...... 13 Changes ...... 14 Requirements ...... 14 Optional Requirements ...... 14 Installation ...... 14 Drupal Administration ...... 16 Customizing your theme(s) ...... 16 Multi-site configuration ...... 16 More Information ...... 17 Formatted Drupal 4.7.x Installation instructions for better readability .. . . 17 Installation ...... 17 REQUIREMENTS ...... 18 SERVER CONFIGURATION ...... 18 OPTIONAL COMPONENTS ...... 18 INSTALLATION ...... 19 1. DOWNLOAD DRUPAL ...... 19 2. CREATE THE DRUPAL DATABASE ...... 19 3. LOAD THE DRUPAL DATABASE SCHEME ...... 20 4. CONNECTING DRUPAL ...... 20 5. CONFIGURE DRUPAL ...... 21 6. CRON TASKS ...... 22 DRUPAL ADMINISTRATION ...... 22 CUSTOMIZING YOUR THEME(S) ...... 22 UPGRADING ...... 23 MORE INFORMATION ...... 23

i Drupal Handbook 6 Jun 2007

10 minute install using PuTTY SSH/Telnet client ...... 23. How I installed Drupal: The Eightfold Way ...... 24. Installing virtual hosts for Drupal sites and subsites ...... 25. Mac OS X-specific guidelines ...... 26. Important notes for MySQL install: ...... 27. HOWTO: Create a local server environment for drupal using MAMP .. . . 28. HOWTO: Installing PostgreSQL and MySQL on the same Mac OS X machine .. 29. Installing Drupal on Mac OS X 10.4 Tiger ...... 30. Installing and Configuring MySQL ...... 30. Sending mail ...... 32. Creating the Drupal Database and Database User ...... 32. Installing using CVS repository ...... 33. Prefixed database. for search and replace ...... 36. Setup Drupal on Windows XP Pro using IIS ...... 51. Basic /sites directory setup ...... 52. Special cases ...... 53. Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support .53 Configure .htaccess to allow awstats to work with clean URL’s .. . . . 54. Configuring .htaccess to ignore specific subfolders ...... 55. Ignoring Subfolders that exist in the DocumentRoot ...... 55. Ignoring subfolders that are included via Apache Alias directives .. . . 55. Create a custom .ini ...... 56. How to create a custom php.ini file when nothing else works .. . . . 60. 1. Get and modify your custom php.ini file ...... 60. 2. Creating your CGI script ...... 60. 3. Modifying your .htaccess file ...... 61. 4. Test your site ...... 61. Create Drupal database using Plesk ...... 61. Drupal with safe mode enabled and open basedir ...... 62. Generic Mass SQL Import into Drupal ...... 65. How to degrade your Drupal db from MySQL 4.1.X/5.0.X to MySQL 4.0.X .. 67. How-To: Virtual Hosting with Drupal ...... 68. Introduction ...... 68. Environment ...... 68. Requirements ...... 69. Next pages ...... 69. How-To: Virtual Hosting with Drupal :: Prepare environment .. . . . 69. Introduction ...... 69. The drupal group ...... 70. The temp directory ...... 70. The reference location ...... 70. Navigation ...... 70. How-To: Virtual Hosting with Drupal :: Solution Overview .. . . . 71. Introduction ...... 71. Safe mode ...... 71. Open Basedir ...... 71. Plesk integration ...... 72.

ii 6 Jun 2007 Drupal Handbook

Managed application ...... 72. eAccelerator ...... 72. Each individual vhost requirements ...... 73. Navigation ...... 73. HOWTO: copy a site to a local computer using XAMPP ...... 73. HOWTO: Copy site to another directory for testing ...... 74. HOWTO: Install Drupal 5.x using cPanel ...... 75. HOWTO: Install Drupal using cPanel ...... 77. HOWTO: Site to site transfer with phpMyAdmin and a FTP Client .. . . 80. Import a MySQL data dump with BigDump ...... 82. What is BigDump? ...... 82. Setting up BigDump ...... 83. Uploading the file and bigdump.php to the webserver ...... 83. Running BigDump ...... 84. Installing Drupal behind an Actiontec GT701-WG router ...... 84. Installing Drupal in a subdirectory in 4.6 ...... 85. More than one Drupal site on one machine ...... 85. General rules for multiple Drupal deployments ...... 86. Moving your Drupal installation to a new directory ...... 86. PCRE_UTF8 solution for VPS servers | FreeBSD ...... 87. Known causes of PCRE server errors ...... 88. Redirecting specific pages to new URLs (301 redirects in Drupal) .. . . . 88. How to create 301 redirects in Drupal Apache mod_rewrite .. . . . 89. The tolerant base URL ...... 89. Using .htaccess to stop page caching ...... 90. specific guidelines ...... 90. Installing PHP, MySQL and Apache under Linux ...... 90. XAMPP for Linux Packages ...... 91. Installing XAMPP in Debian ...... 91. Download XAMPP Latest version from the following link ...... 91. Start XAMPP Server ...... 91. Windows-specific guidelines ...... 94. How to install Drupal for newbies using FTP and phpMyAdmin .. . . . 95. Change "/tmp" on your drupal site...... 95. Get Drupal ready ...... 95. Upload the database ...... 96. HOWTO: Create an apache sandbox using Windows and Apache2Triad .. . 96. Before you begin ...... 97. Installing Apache2Triad ...... 97. Installing Drupal ...... 98. Importing and exporting Drupal databases updated with PHPMyAdmin .. 100. To export a database with PHPMyAdmin ...... 100. To import a database with PHPMyAdmin ...... 101. Using bigdump.php to deal with large databases ...... 102. Installing Apache (with PHP) on Windows ...... 102. Installing MySQL on Windows ...... 104. Installing PHP4 on Windows ...... 105.

iii Drupal Handbook 6 Jun 2007

Drupal 4.7 on Windows/IIS Requires PHP in ISAPI mode ...... 105. Installing PostgreSQL on Windows ...... 105. Multiple Drupal Sites under Windows ...... 106. Running multiple sites on a local PC (localhost) from a single codebase, using Windows106 Untar ...... 108. Installing Drupal on Windows ...... 109. PostgreSQL specific guidelines ...... 109. ERROR: DB connect failed ...... 109. ERROR: language "plpgsql" does not exist ...... 110. ERROR: null value in column "uid" violates not-null constraint .. . . . 110. PostgreSQL support in Drupal 4.7.x ...... 110. Drupal 4.5 and PGSQL 8 configuration ...... 110. Installing contributed modules ...... 111. HOWTO: Install glossary module ...... 113. Where is the Glossary? ...... 113. What is the purpose of the Glossary Module, and what does it do? .. . . 113. Installing the Glossary Module ...... 114. Configuring the Glossary ...... 114. Adding Full Page Definitions ...... 115. Adding Glossary To Menus ...... 115. Leech - automating content addition ...... 116. Relationships between modules ...... 116. Installing new modules (Drupal 4.6 or older) ...... 117. Multi-site installation and set-up ...... 118. 10 Minute Multisite Install & Configuration ...... 119. Access all multisites with www. only [.htaccess] ...... 121. Drupal as a library ...... 121. Multi-site setup in 5.x using CPanel ...... 123. Multi-Site, Single Codebase, Shared Database, Shared Sgin-on 5.x .. . . . 124. 1. Prepare database and database user ...... 124. 1.1. create a database and user ...... 124. 2. create and modify site configuration ...... 124. 2.1. duplicate settings folder ...... 124. 2.2. Modify config files ...... 125. 2.2.1. provide DB connection detail ...... 125. 2.2.2. set prefixes for table names ...... 125. 3. create static links ...... 126. 4. install drupal ...... 126. Multi-Site, Single Codebase, Shared Database, Shared Sign-on 4.6 .. . . . 127. Apache (http) Configuration ...... 127. Download and Placement ...... 127. SQL Setup ...... 128. Individual Site Configuration & Theming ...... 129. Some things which can be improved: ...... 130. Multiple domains or vhosts using different databases ...... 130. Sharing Drupal tables between databases using MySQL5 Views .. . . . 131. Multiple domains using the same database ...... 132.

iv 6 Jun 2007 Drupal Handbook

Same codebase, completely different content and users ...... 132. Setup of /sites directory for multi-site ...... 135. Installing new themes ...... 137. Basic site configuration ...... 139. Settings ...... 139. General settings ...... 140. Default front page ...... 140. Examples ...... 141. Clean URLs ...... 141. .htaccess for clean urls on specific shared hosts ...... 143. 403 Permission denied error ...... 146. Apache 2 configuration of clean URLs on Debian ...... 147. Apache 2 on Ubuntu ...... 149. Editing apache2.conf ...... 149. Editing apache2/sites-available ...... 150. Clean URL Support in Abyss ...... 151. Clean URL support in XAMPP ...... 153. Clean URLs in Mac OS X Server ...... 153. Clean URLs with different webservers ...... 153. Microsoft Internet Services Server ...... 153. Lighttpd ...... 153. Clean URLs with Easyphp...... 154. Example Clean URL configuration of httpd.conf for performance .. . . . 155. Existing URLs for server overwrite Drupal paths ...... 156. IIS CleanURLs using some of the available ISAPI filters...... 156. Translating Apache’s rewrite rules ...... 156. Setting up clean URLs above web document root on virtual private servers .. 157. reboot vps after making change ...... 157. Using Clean URLs with IIS ...... 158. Alternate method ...... 159. set your sites 403 and 404 Error pages ...... 159. Configure your sites error reporting ...... 160. Cache support ...... 160. Primary and secondary links ...... 160. General Information: ...... 160. Setting Up Your Primary and Secondary Links: ...... 161. Theming Your Link Menus ...... 161. Set length of trimmed posts and # of posts on front page ...... 161. URL Alias Optimization ...... 161. File system settings ...... 162. Download method ...... 162. Path settings ...... 162. Date and time settings ...... 163. Customizing the interface ...... 163. Customizing user login ...... 164. Beginner’s guide for Cron on a shared hosting provider ...... 165. Check your filters ...... 166.

v Drupal Handbook 6 Jun 2007

Configure user registration ...... 166. Creating a menu structure ...... 167. Creating a menu ...... 167. Simplifying the workflow ...... 168. Helping search engines and robots.txt ...... 168. Controlling what gets indexed -- the robots.txt file ...... 169. Add ’Disallow: /node/’ if your setup has aliases for all nodes .. . . . 170. Selective Bot Crawling ...... 170. Increase upload size in your php.ini ...... 174. Need images etc? - check Filtered HTML ...... 175. Set default content options - Stop automatic promotion to the front page .. . . 176. Show/hide ’Submitted by’ on posts ...... 176. Blocks ...... 177. Block configuration ...... 177. Restricting blocks to certain pages ...... 178. Preventing a block from appearing in Drupal 4.5 ...... 179. Custom blocks ...... 181. Increase memory in your php.ini ...... 181. Database table prefix (and sharing tables across instances) ...... 182. Share tables across instances ...... 183. Setup tip for Drupal 5 ...... 184. Using schema prefixes with PostgreSQL ...... 184. Define shared variables for all sites ...... 186. Drupal Cookbook (for New Drupallers) ...... 187. Purpose ...... 187. Background ...... 187. Myths ...... 187. Using the Drupal Web Site ...... 188. Typing Convention ...... 188. Some Preliminary Advice ...... 188. Drupal Is Supposed to be Easy? ...... 189. A. Getting Started ...... 190. B. Basic Configuration ...... 191. . Creating Multiple Sites On Your Local Computer ...... 192. D. Error Pages ...... 195. Page Not Found ...... 195. Access Denied ...... 195. E. Accessing Your Test Site(s) ...... 196. F. Adding Modules and Themes ...... 196. Installation ...... 197. Modules ...... 197. Modules ...... 197. This Site ...... 198. Themes ...... 198. Themes ...... 198. Logo and Favorite Icon ...... 198. G. Creating Content ...... 199.

vi 6 Jun 2007 Drupal Handbook

Content Types ...... 200. Page ...... 200. Story ...... 200. Book Page ...... 200. Blog Entry ...... 201. G1. Creating a Page ...... 201. G2. Creating a Story ...... 202. What’s a Teaser? ...... 202. G3. Creating a Book Page ...... 203. G4. Creating a Blog entry ...... 203. H. Custom Blocks ...... 204. Address ...... 204. Last Updated ...... 204. I. Working with the Menu ...... 205. Introduction ...... 205. How To Menu ...... 205. Textual Menu ...... 206. Tabbed Menu ...... 206. Books ...... 206. More ...... 207. I2. The Contact Form ...... 207. Set Up ...... 207. Make It Accessible ...... 207. Add "Contact" to the Menu ...... 208. Using It In Content ...... 208. J. URL Aliases ...... 208. K. Moving Entire Drupal Site with Databases ...... 209. Backup Process with phpMyAdmin ...... 211. Backup Process with phpMyAdmin ...... 211. L. Moving Stuff to Your Web Site ...... 214. M. Setting Up Cron ...... 214. N. Categories (Taxonomy) ...... 215. O. Common Problems ...... 217. P. Links and IMG ...... 217. Q. Additional Tips and Tricks ...... 218. Q1. Tracking Module Status ...... 218. Q2. Making Multiple Site Maintenance a Bit Easier ...... 218. Q3. Controlling User Log In ...... 219. How do I disable "Create New Account?" ...... 219. How do I disable User Log In entirely, and how would I get in if I do? .. . 219. R. Keeping Your Local and Remote Sites Synchronized ...... 220. S. More Reading ...... 220. T. Glossary ...... 221. Taking your site live ...... 224. Moving from a temporary location ...... 224. Moving Drupal ...... 224. Redirecting your server ...... 224.

vii Drupal Handbook 6 Jun 2007

Excluding paths from Drupal ...... 225. Core modules ...... 226. Aggregator: publishing syndicated content ...... 226. Old page ...... 227. Open aggregator links in new browser window ...... 227. User Aggregator:user submitted feeds ...... 227. What do I need to subscribe to a feed? ...... 228. Configuring news feeds ...... 228. Filter feeds by keyword, time, by summary ...... 229. Creating categories in the aggregator ...... 229. Tagging individual items in the aggregator ...... 229. Using the news aggregator ...... 229. RSS feed blocks ...... 230. Block: controlling content in the sidebars ...... 230. Module blocks ...... 230. Administrator defined blocks ...... 231. Blog: a blog for every user ...... 231. HOWTO: Configure user blogs ...... 231. Most recent blog post block ...... 232. Navigate throught categories inside a blog ...... 232. What is a blog or weblog? ...... 232. Making user blogs more accessible ...... 233. Additional features ...... 233. BlogApi: post from blog tools ...... 234. Book: structured document publishing ...... 234. Customising the book navigation menu ...... 235. Maintaining a FAQ using a collaborative book ...... 236. Categories (taxonomy): A way to organize your content ...... 237. Modules that do more with categories ...... 240. Content Management System comparison focused on Taxonomy .. . . . 242. Taxonomy - some guidelines for effective design of taxonomies ...... 242. Taxonomy Garden: Managing Categories ...... 244. Taxonomy Garden: Navigation by category ...... 245. Taxonomy Garden: Organize content by category ...... 252. The taxonomy module for Drupal 4.x ...... 258. Understanding categories for new users ...... 259. Using taxonomy to organize content ...... 260. Using vocabularies for navigation ...... 263. Vocabularies and terms ...... 264. Creating a vocabulary ...... 265. Creating terms ...... 265. Advanced taxonomies: using hierarchies ...... 266. More about Taxonomy ...... 266. Creating a Block with links belonging to certain taxonomy terms .. . . . 268. Taxonomy terms on a page ...... 269. Comment: allow comments on content ...... 270. Detailed comment documentation ...... 270.

viii 6 Jun 2007 Drupal Handbook

User control of comment display ...... 270. Additional comment configurations ...... 271. Notification of new comments ...... 271. Comment moderation ...... 272. Moderation votes ...... 272. Moderator vote/values matrix ...... 272. Creating comment thresholds ...... 272. Initial comment scores ...... 273. Aggregator comments ...... 273. Contact: a way for users to get in touch ...... 273. Make your site wide contact form look prettier ...... 274. Drupal: Drupal sites directory server ...... 274. Old page ...... 275. Filter: Input formats for user content ...... 275. Forum: create threaded discussions ...... 276. HOWTO: Create a forum ...... 277. HOWTO: Create forum containers ...... 277. Help: context-sensitive guidance ...... 277. More about the help module ...... 278. Legacy: remapping of old-style URLs ...... 278. Locale: multi-language support ...... 278. Adjusting your php.ini settings for importing .po files ...... 279. Editing text for translation ...... 280. How to create Drupal site in Marathi (Devnagari) ...... 280. How to install a different language ...... 281. HOWTO: Creating a customized language set to replace Drupal terminology .. 281. HOWTO: Use a customized language set to change Drupal text and terminology . 282. Note for the curious ...... 284. Menu: customize site navigation ...... 284. Using named anchors with menus ...... 284. Node: the content ...... 285. Page: post static pages ...... 285. Difference between page and story ...... 286. Specify page by title ...... 286. Path: readable URLs ...... 286. Mass URL aliasing ...... 288. Ping: notify services of changes ...... 289. Write a custom module to ping a set of sites ...... 289. Poll: community voting ...... 290. Profile: extending user account information ...... 291. Enabling user pictures (avatars) ...... 292. HOWTO: Create new profile fields ...... 292. HOWTO: Make a field part of the registration process ...... 293. Form Validation in plugin ...... 293. HOWTO: Create a ’country’ profile field ...... 293. CiviCRM: Tags, Profiles, Groups, advanced community member management .. 294. Search: an internal site search system ...... 294.

ix Drupal Handbook 6 Jun 2007

Add searching to your custom module ...... 296. Statistics: tracking referrers, page hits, etc...... 296. Story: post static pages ...... 297. System: cron and caching ...... 297. Configuring cron jobs ...... 298. Configuring cron jobs on DreamHost ...... 300. Cron Job configuration line by line ...... 301. Cronjobs without wget/lynx or curl ...... 301. Configuring cron jobs on Windows ...... 303. Throttle: congestion control ...... 304. When to use the throttle module? ...... 304. Tracker: viewing new and updated content ...... 305. Upload: collaborate with files ...... 305. User: access and management settings ...... 306. Access Permissions reference ...... 306. block module ...... 306. filter module ...... 307. menu module ...... 307. node module ...... 307. path module ...... 307. user module ...... 308. system module ...... 308. Access rules (email filters) ...... 308. Managing access control with permissions and user roles ...... 308. Assigning permissions and users to roles ...... 309. Taxonomy_access: Restrict user roles to access specific categories only .. . 310. Adjusting permissions after adding modules ...... 310. User authentication ...... 310. Make a Drupal site use Basic Auth/ldap instead of the normal login block .. 311. NTLM Authentication ...... 313. User preferences and profiles ...... 314. Using distributed authentication ...... 315. Distributed authentication ...... 315. Drupal ...... 315. Watchdog: monitor your site ...... 315. End user guide ...... 317. Registering as a user ...... 317. Logging in ...... 318. Changing your account settings ...... 318. Creating new content ...... 319. A step-by-step example ...... 319. Controlling Teaser Location ...... 321. How to add a page to the Handbook ...... 322. Types of content ...... 322. Topics, categories and terms ...... 322. Permissions ...... 322. Moderation and the submission queue ...... 323.

x 6 Jun 2007 Drupal Handbook

Creating comments ...... 323. Alternative ways to enter content ...... 323. HOWTO: Posting and editing blog entries with TextMate ...... 324. Posting and editing content with w.bloggar ...... 325. Posting content with mailhandler ...... 326. Preparing content offline ...... 326. Editing and deleting content ...... 326. Search ...... 327. Beyond the basics ...... 328. Best practices guidelines ...... 329. Back up your Drupal site ...... 329. Backing up the database ...... 329. Backing up the core files ...... 330. Backing up the non-core files ...... 330. Test your backups ...... 331. Backup and restore using bash shell scripts ...... 331. Functional Overview ...... 331. Usage notes and cautions ...... 331. Site backup script ...... 332. Usage notes and warnings: ...... 332. fullsitebackup.sh ...... 333. Updated fullsitebackup.sh ...... 335. Site restore script ...... 337. Usage notes and warnings: ...... 338. fullsiterestore.sh ...... 338. Updated fullsiterestore.sh ...... 341. Accounts and roles ...... 343. Configuring Apache and PHP for Drupal in a Shared Environment .. . . . 344. Creating a Test Site workflow ...... 345. File and directory management ...... 349. Other Tips ...... 350. Test Sites ...... 350. Version update considerations ...... 350. Do not modify core Drupal ...... 351. Security ...... 352. Test php before putting it in blocks ...... 352. HowTo: The Advanced user’s guide ...... 353. HowTo: enable Imagemagick for the Image module ...... 354. Tips and Tricks ...... 354. August 2005: Upgrade, Play B-I-N-G-O!, & E-commerce ...... 354. UPGRADE ...... 354. PLAY B-I-N-G-O! ...... 355. E-COMMERCE ...... 355. Commentator array ...... 355. June 2005: Custom Content Types, WYSIWIG Editors, Organize Your Content & Quick Support ...... 356. September 2005: Newest modules, Change any string, Remote authentication, and

xi Drupal Handbook 6 Jun 2007

tracking project issues ...... 357. Get the newest modules -- fast! ...... 357. Change any string ...... 357. Remote authentication ...... 357. Keep tabs on project issues ...... 358. Winter 2005/2006: Tracking projects with RSS and Module Linking .. . . . 358. Planning a web site ...... 358. Server tuning considerations ...... 362. Identifying Drupal performance goals ...... 362. Analysing your site’s traffic and resource consumption ...... 362. Understanding and configuring your stack for performance ...... 362. Enable default 404 handling for some file types ...... 364. Simple Decision Tree for Drupal Enterprise Scalability ...... 365. Slow contributed modules determined using the developer module .. . . . 366. Squid Caching ...... 366. Tools, tips, and links on optimizing mysql ...... 367. Tuning MySQL for Drupal ...... 369. Tuning PHP ...... 369. Persistent database connections ...... 370. PHP caches ...... 370. APC : Alternative PHP Cache ...... 371. eAccelerator ...... 371. Turck MMCache ...... 371. Useful article on optimizing PHP ...... 373. Tuning Drupal on OS X Tiger ...... 373. Upgrading from previous versions ...... 375. Introduction to upgrading ...... 375. Getting started: Choosing your method and preparing the site ...... 375. Preparing the site ...... 376. Do I need to upgrade my database? ...... 376. Important! : Backing up the database and existing files ...... 376. Backing up your site (GUI) ...... 376. Back up your site (command line) ...... 377. Create a test site first or upgrade your existing site? ...... 378. Copy your live site to a test site (GUI) ...... 378. Copying your live site to a test site (command line) ...... 379. Downloading Drupal and installing the files ...... 381. Downloading Drupal and installing the files (GUI) ...... 381. Downloading Drupal and installing the files (command line) ...... 382. Running update.php ...... 383. Optional configuration steps ...... 384. Post-upgrade steps ...... 385. Testing Your Newly Upgraded Site ...... 385. Copy your test site to a live site ...... 386. Copying your test site to your live site (command line) ...... 387. Copy your test site to a live site (GUI) ...... 387. Version specific upgrades ...... 388.

xii 6 Jun 2007 Drupal Handbook

Upgrading from Drupal 4.4 to 4.5 ...... 388. Upgrading from Drupal 4.5 to 4.6.3 ...... 390. Before you Start ...... 390. Step-by-step Upgrade from Drupal 4.5 to 4.6.3 ...... 390. Finalising your upgrade ...... 392. Rebuilding your Drupal Search Index...... 392. Blocks ...... 392. Permissions ...... 393. Forums ...... 393. Images ...... 393. Events ...... 393. Upgrading from Drupal 4.6.3 to 4.6.5 ...... 394. Before you Start ...... 394. Step-by-step Upgrade from Drupal 4.6.3 to 4.6.5 ...... 394. Upgrading from Drupal 4.6.4 to 4.6.5 ...... 394. Before you Start ...... 395. Step-by-step Upgrade from Drupal 4.6.4 to 4.6.5 ...... 395. Differences from 4.6 to 4.7 ...... 395. Block visibility settings ...... 395. Configure options centralized ...... 396. core module help text linked to the handbook now ...... 396. Creating context sensitive menus with primary and secondary menus .. . . 396. Don’t turn off contributed modules that provide an .install file ...... 397. Module .install files ...... 397. Primary/secondary links now part of the menu system ...... 397. queue module removed from core ...... 397. Removal of base href statement from header ...... 398. Some HTML Tags stripped from mission statement ...... 399. XTemplate engine removed from core ...... 399. Troubleshooting FAQ ...... 400. How to troubleshoot (read this first) ...... 400. Stop and think ...... 400. Read the errors ...... 400. Validate your page ...... 401. Read the README ...... 401. Search the right way ...... 401. Identify the source of the problem ...... 402. Dump some diagnostics ...... 402. Ask the right questions ...... 403. Identify the module that’s giving you problems ...... 403. My admin > modules page is blank ...... 403. How do I get the User Login block back ...... 404. Client does not support authentication protocol requested by server...... 404. Webhosting issues for new Drupal users ...... 405. Brief intro to Unix file permissions ...... 405. Host-specific error messages ...... 407. SELinux may cause mysterious permission problems ...... 407.

xiii Drupal Handbook 6 Jun 2007

Typical webhosting setups ...... 408. Using PHP to change files on the webserver ...... 409. What do all those Unix commands mean? ...... 409. Some Unix command you’ll see mentioned: ...... 409. Special characters: ...... 410. What permissions does Drupal need? ...... 410. Why is this uploading stuff so difficult? ...... 412. "Headers already sent" error ...... 412. "LOCK TABLES sequences WRITE" error ...... 413. "Method POST is not allowed for the URL /index.htm" error (Error 405) .. . . 413. "Page Not Found" error when trying to access a subdirectory ...... 414. Block referrer spam ...... 414. .htaccess sample list plus domain blocking ...... 415. Color picker doesn’t appear on theme configuration page ...... 416. Drupal 4.7 Install inserts CGI-BIN in URL ...... 416. Duplicate entry error ...... 417. E-Mail from Drupal is bouncing or not being sent ...... 419. Relay SMTP mail to external mail server using smtp.class ...... 419. Error 1364 upon importing database.mysql with MySQL 5.0+ ...... 420. Error on installation step 3: Warning: Table ’[database].access’ doesn’t exist [...] .. 421. Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)... . 422. Fatal error: Call to undefined function ...... 422. Fatal error: Call to undefined function: form_*() on Drupal 4.7 ...... 422. Fatal error: Cannot redeclare blah_function() in ../modules/blah.module .. . . 423. Forgotten your Drupal account password ...... 423. Forum overview stopped working ...... 424. The Fix ...... 424. FTP uploads and file permissions using Transmit ...... 425. Help! I enabled a buggy module and now I can’t disable it! ...... 425. How can I adminstrate my navigation on my Drupal site? (version 4.5 or older) .. 425. How do I get rid of the "Welcome to your new Drupal website" on the front page? .. 427. How do I get the Navigation block back ...... 428. How do I unset the clean URLs? ...... 428. How to login once you have turned your site off-line for maintenance .. . . . 428. HOWTO: Download a fresh copy of a missing or corrupted module/image/file .. 429. Installation/configuration ...... 430. 406 Error when XMLRPC is used ...... 430. Junk {head} {styles} codes as output ...... 430. Login after disabling the User login block ...... 431. Login doesn’t work or must be done twice ...... 431. Cookies ...... 431. Cache Problems ...... 431. Logging in at www on a site with no www in the baseurl ...... 432. Login problems on PHP 5.2 ...... 432. My layout collapses - content appears below left column (IE) or overflows over the right (FF) ...... 432. The content is too wide for the space it’s been given ...... 433.

xiv 6 Jun 2007 Drupal Handbook

Validation Woes ...... 433. Mysterious 403, 404, 406 or 500 errors depending on submitted content .. . . 434. Permission denied in includes/file.inc ...... 434. Persistent ’Welcome to Drupal’ for anonymous users ...... 435. phpinfo ...... 436. Plain unstyled HTML output ...... 436. Setting up Clean URLs ...... 437. unblocking account through SQL ...... 438. Weird behaviour - module-theme name collision ...... 438. Where is the taxonomy choice when adding content? ...... 438. Miscellaneous ...... 439. How can I change Drupal’s character encoding? (UTF-8 and ) .. . . 439.

xv

6 Jun 2007 Drupal Handbook

Installation and configuration

Here is a guide for installing and configuring a Drupal site. This guide includes extensive How-to’s for using all core modules and installing themes. It also includes a guide for end users, the people who visit a Drupal site.

Note: Feel free to add handbook pages relevant to this section.

1 Drupal Handbook 6 Jun 2007

System requirements

1. A Web Server that can execute PHP scripts

2. Recommended: Apache.

Drupal will work on Apache 1.3 or Apache 2.x hosted on Unices or Windows. The majority of Drupal development is done using Apache so there is more community experience and testing performed. Optional: You can use the Apache extension mod_rewrite to allow for clean urls.

Optional: IIS

Drupal core will work using IIS5 or IIS6 if PHP is configured correctly. You will need to use a third party solution to achieve Clean URLs. In view of Microsoft’s support life cycle it is suggested you use IIS6. To achieve clean_url’s you will need to use a third party product.

Drupal is being developed to be web server independent but we have limited or no reports of successful use on web servers not listed here.

3. PHP

4. Drupal 4.7 and above require PHP version 4.3.3 or higher. PHP 5.2 is a special case; only Drupal 4.7.5 (and greater) and 5.0 (and greater) run on PHP 5.2, older Drupal versions do not. We recommend using the latest version of PHP 4.x. or 5.x for security and future compatibility.

PHP memory of approximately 8MB for a Drupal core installation. In reality you will probably need to use a higher setting depending on your site and contributed modules you are using. A good starting point is 16-24 MB. PHP XML extension (for blogapi, drupal, and ping modules). This extension is enabled by default in a standard PHP installation; the windows version of PHP has built-in support for this extension. PHP needs the following configuration directives for Drupal to work (only directives that differ from the default php.ini-dist / php.ini-recommended): session.save_handler: user error_reporting set to E_ALL & ~E_NOTICE. Work is ongoing to change this to E_ALL for Drupal 6. In addition, we recommend the following settings: session.cache_limiter: none Some of these settings are contained in the default .htaccess file that ships with Drupal, so you shouldn’t need to set them explicitly. Note, however, that setting PHP configuration options from .htaccess only works:

with Apache (or a compatible web server),

2 6 Jun 2007 Drupal Handbook

if the .htaccess file is actually read, i.e. AllowOverride is not None, if PHP is installed as an Apache module. See the PHP manual for how to change configuration settings for other interfaces to PHP. 5. A PHP-supported Database Server

6. Recommended: MySQL 4.1 or MySQL 5.0.

Drupal will work on v3.23.17 and 4.0 but it is strongly suggested you use 4.1 or 5.0 for future compatibility with Drupal 6 which will drop support for older versions of MySQL. NOTE: Drupal makes use of some features not available on some inexpensive hosting plans so please check that your host allows database accounts with the following rights:

SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES

Note: If your system/host is running MySQL 4.1 or newer and you receive the error "Client does not support authentication protocol requested by server", address the problem by following the instructions provided by MySQL AB. There is a minor OS issue with some MySQL 5+ installations primarily on Windows but affecting some Unices as well.

PostgreSQL, version 7.3 or newer.

Note, some of the contributed modules are not as abstracted from MySQL specific code as everyone would like. If you are familiar with PostgreSQL please file issues with those contributed modules as you find them.

Currently MS SQL and Oracle are not supported but various efforts are underway to supply schemas. Please see discussions in the Enterprise Group if you are interested in working on this.

Client System Requirements

Drupal aims to conform with internet standards and deviate where necessary to comply with popular clients that are not standards compliant.

Javascript

For the Javascript, we currently test for all required API features (DOM APIs) and based on that, enabled or disable all JS functionality. That way, we don’t care about particular browsers, only what they support.

3 Drupal Handbook 6 Jun 2007

CSS

For CSS, the situation is quite similar to Javascript. The only difference is that here there is a strong difference between the standard compliant browsers and Internet Explorer. We can use CSS2 where needed and provide IE6 workarounds if necessary.

RSS

Drupal RSS feeds should work with any RSS feed reader. (note: could use more information).

Browser Specifics

In practice, this means that IE6, FF1.0/1.5, Opera 8-9 and Safari 1.x/2.0 get the whole experience. Konqueror should work if it’s the latest version.

Browser Popularity

The general net usage is 85% IE, 10% Ffox, 3% Safari, 2% Opera or so. For Drupal.org, it is 50% Ffox/Moz, 30% IE, 20% other.

Known Problems

IE5 and IE5.5 will experience some layout issues. IE5.0 will not do any Javascript. We can assume that for Firefox and Opera, the users have a high chance of running the latest version.

IE4 and NS4, we no longer care about because they are no longer maintained and they are not in widespread use.

Validation

Drupal HTML and RSS should validate using the W3C Markup Validation Service.

Caveats

These guidelines are the guide for Drupal core, modules, and themes but are not always completely accurate. In practice, Drupal Core is expected to follow these standards more closely than various contributed pieces of code. If you find a problem with client compatability that deviates from the above client support guidelines, please try to find the root of the problem and submit an issue ideally including a patch to fix the problem.

4 6 Jun 2007 Drupal Handbook

HOWTO: Server requirement recommendations for your consulting clients

When thinking about the server hardware for a Drupal site, there are two important questions to ask:

1. Which modules are you going to use? Certain modules require more server power than others, but generally speaking more modules means more server requirements.

2. How many users will you have and what will they be doing? More users means more of a demand on the server, but especially if these users login and make comments or nodes you will need a more powerful server.

You need to consider these two answers together. For example, you could have a highly complex site with very few users and be able to use a shared hosting environment. You could also use very few modules, only have one editor, use the cache, and have reasonable traffic on a shared environment.

If your project is a more interactive environment with more users logging in and posting to the site you will need to consider more powerful hardware. As you move out of a shared environment there are other options available to you like using the methods described in the handbook to Tune Your Server for optimal Drupal performance. Tuning the server may allow you to continue using the same hardware and not upgrade, but it comes at the cost of time which can be more expensive than simply buying new hardware.

When deciding which parts of your server to upgrade, remember that "Apache is bandwidth limited, PHP is CPU limited, and MySQL is memory limited and disk I/O bound".

Message to the Client

It’s probably best to give the message to the client of a "recommended" installation and a level below that in case their budget is limited and a level above that to provide for future growth with purchasing new hardware and services.

If you are rolling out a new service (as opposed to installing Drupal in place of an existing solution) keep an eye towards a solid upgrade path. You can purchase a single server with the intent of upgrading as your site grows. For example, start with the web server and database on one server that is optimized for web serving. As the site grows in popularity and you need to handle more users you can then move the database to it’s own server separate from the web server. If your site grows beyond a two server "web server" and "database server" configuration then you can consider using a single web server and multiple database servers in a cluster.

5 Drupal Handbook 6 Jun 2007

Benchmark

One benchmark of a server is MBR.org which required serious intervention for optimisation at roughly the 2m pages per month mark, on a server running Apache1.3 and MySQL 4.1 with 1GB of memory. MySQL indexing, database memory use tweaks and abandoning MyISAM for InnoDB brought it under control - the jury’s out on using persistent connections.

There is a need for more case studies like this to be documented on this handbook page

What Drupal.org runs on

As of April 2007 (and for a long time before that) Drupal.org has been running on a group of 3 servers. For details on those servers see Dries post about the "future" drupal.org hardware as it was being delivered.

Requirements - older versions

1. A Web Server that can execute PHP scripts 2. Recommended: Apache. Development is done with version 1.3.x. Successfully tested with version 2.0.x. Optional: IIS. Drupal is being developed with IIS compatibility in mind, and IIS5 and IIS6 work with a correctly configured PHP setup. 3. PHP 4. As of Drupal 4.6, the CMS requires PHP version 4.3.3+ (PHP 5 is supported for the 4.6 release). Drupal 4.2 to 4.5.2 inclusive require PHP version 4.1+. Older versions of Drupal will run on PHP 4.0.6+. We recommend using the latest version of PHP 4.x. PHP XML extension (for blogapi, drupal, and ping modules). This extension is enabled by default in a standard PHP installation; the windows version of PHP has built-in support for this extension. PHP memory of 8MB for a Drupal core install. If you install additional contributed modules you may need to raise your php allowed memory. Prepackaged Drupal distributions such as CivicSpace may have higher PHP memory requirements then a Drupal core install.

PHP needs the following configuration directives for drupal to work: session.save_handler: user In addition, we recommend the following settings: session.cache_limiter: none (We only mention directives that differ from the default php.ini-dist / php.ini-recommended starting with PHP 4.0.6) These settings are contained in the default .htaccess file that ships with Drupal, so you shouldn’t need to set them explicitly. Note, however, that setting PHP configuration options from .htaccess only works:

6 6 Jun 2007 Drupal Handbook

with Apache (or a compatible web server), if the .htaccess file is actually read, i.e. AllowOverride is not None, if PHP is installed as an Apache module. See here for how to change configuration settings for other interfaces to PHP. Using a PEAR-supported Database (see below) requires (of course) PEAR to be installed. A PHP-supported Database Server

Recommended: MySQL, v3.23.17 or newer (for our use of INNER JOIN’s with join_condition’s). MySQL 4 is fine. Drupal makes use of features not available on some inexpensive hosting plans, like LOCK TABLE Working well since 4.7: PostgreSQL, version 7.3 or newer (7.2 will probably work too, but you’ll get some errors when updating from 4.6). Experiences with other databases are greatly welcome.

Note: If your system/host is running MySQL 4.1 or newer, a link in the troubleshooting section (http://drupal.org/node/35226) points to this page, which has some helpful info on addressing this problem with PHP 4.x and PHP5. There is a minor OS issue with some MySQL 5+ installations primarily on Windows but affecting some *nix installs as well.

Also, xTemplate (the default theme engine for Drupal 4.6.x and previous) is reported to have issues with PHP 5.0.5 and 5.1. Converting your themes to the phpTemplate engine (default in 4.7) will work around this issue.

7 Drupal Handbook 6 Jun 2007

Installing Drupal, modules and themes

Installing Drupal, new modules and themes uses roughly the same process so once you are familiar with it you can repeat as needed.

After you successfully install Drupal, you will want to perform some basic site configuration starting with the settings menu.

Installing and configuring your site is only part of your responsibilities. You must remember to backup, test and maintain it as well. Please stop by the Best Practices section for some important tips on this and sign up for the security newsletter

Installing Drupal This page is autogenerated from the current development text in CVS. See the various other provided instructions linked in the menu on the left for additional environments. // $Id: INSTALL.txt,v 1.39 2007/01/08 11:59:16 dries Exp $ CONTENTS OF THIS FILE ------* Changes * Requirements * Optional requirements * Installation * Drupal administration * Customizing your theme(s) * Multisite Configuration * More Information CHANGES ------As of Drupal 5.0 installation has been automated by an install script. It is no longer necessary to manually edit the "settings.php" file, and database tables are created automatically. REQUIREMENTS ------Drupal requires a web server, PHP4 (4.3.3 or greater) or PHP5 (http://www.php.net/) and either MySQL (http://www.mysql.com/) or PostgreSQL (http://www.postgresql.org/). The Apache web server and MySQL database are recommended; other web server and database combinations such as IIS and PostgreSQL have been tested to a lesser extent. When using MySQL, version 4.1 or greater is recommended to assure you can safely transfer the database.

8 6 Jun 2007 Drupal Handbook

For more detailed information about Drupal requirements, see "Requirements" (http://drupal.org/requirements) in the Drupal Handbook. Guidelines for setting up a server environment with a variety of operating systems and in special cases are available in the Drupal handbook (http://drupal.org/node/260) OPTIONAL REQUIREMENTS ------To use XML-based services such as the Blogger API, Jabber, and RSS syndication, you will need PHP’s XML extension. This extension is enabled by default. - If you want support for clean URLs, you’ll need mod_rewrite and the ability to use local .htaccess files. INSTALLATION ------1. DOWNLOAD DRUPAL You can obtain the latest Drupal release from http://drupal.org/. The files are in .tar.gz format and can be extracted using most compression tools. On a typical Unix command line, use: wget http://drupal.org/files/projects/drupal-x.x.tar.gz tar -zxvf drupal-x.x.tar.gz This will create a new directory drupal-x.x/ containing all Drupal files and directories. Move the contents of that directory into a directory within your web server’s document root or your public HTML directory: mv drupal-x.x/* drupal-x.x/.htaccess /var/www/ 2. CREATE THE DRUPAL DATABASE Drupal requires access to a database in order to be installed. Your database user will need sufficient privileges to run Drupal. Additional information about privileges, and instructions to create a database using the command line are available in INSTALL.mysql.txt (for MySQL) or INSTALL.pgsql.txt (for PostgreSQL). To create a database using PHPMyAdmin or a web-based control panel consult the documentation or ask your webhost service provider. Take note of the username, password, database name and hostname as you

9 Drupal Handbook 6 Jun 2007

create the database. You will enter these items in the install script. 3. RUN THE INSTALL SCRIPT The install script will set the base URL, connect Drupal to the database, and create tables in the database. To run the install script point your browser to the base url of your website (i.e. http://www.example.com). You will be presented with the "Database Configuration" page. The install script will attempt to write-protect the settings.php after updating it with the information you provide in the installation routine. If you make manual changes to that file later, be sure to protect it again after making your modifications. Failure to remove write permissions to that file is a security risk. The default location for the settings.php file is at sites/default/settings.php, but it may be in another location if you use the multi-site setup, as explained below. 4. CONFIGURE DRUPAL When the install script succeeds, you will be directed to the "Welcome" page. In "step one" click "create the first account" which will become the main administrator account with total control. Login as the administrator and complete the initial configuration steps on the "Welcome" page. Consider creating a "files" subdirectory in your Drupal installation directory. This subdirectory stores files such as custom logos, user avatars, and other media associated with your new site. The sub-directory requires "read and write" permission by the Drupal server process. You can change the name of this subdirectory at "administer > site configuration > file system". 5. CRON TASKS Many Drupal modules (such as the search functionality) have periodic tasks that must be triggered by a cron job. To activate these tasks, call the cron

10 6 Jun 2007 Drupal Handbook

page by visiting http://www.example.com/cron.php --this will pass control to the modules and the modules will decide if and what they must do. Most systems support the crontab utility for scheduling tasks like this. The following example crontab line will activate the cron tasks automatically on the hour: 0 * * * * wget -O - -q http://www.example.com/cron.php More information about the cron scripts are available in the admin help pages and in the Drupal handbook at drupal.org. Example scripts can be found in the scripts/ directory. DRUPAL ADMINISTRATION ------A new installation of Drupal defaults to a very basic configuration with only a few active modules and minimal user access rights. Use your administration panel to enable and configure services. For example: General Settings administer > site configuration > site information Enable Modules administer > site configuration > modules Set User Permissions administer > users management > access control Configure Themes administer > site building > themes For more information on configuration options, read the instructions which accompany the different configuration settings and consult the various help pages available in the administration panel. Community-contributed modules and themes are available at http://drupal.org/. CUSTOMIZING YOUR THEME(S) ------Now that your installation is running, you will want to customize the look of your site. Several sample themes are included and more can be downloaded from drupal.org. Simple customization of your theme can be done using only CSS. Further changes require understanding the phptemplate engine that is now part of Drupal. See http://drupal.org/handbook/customization to find out more. MULTISITE CONFIGURATION ------

11 Drupal Handbook 6 Jun 2007

A single Drupal installation can host several Drupal-powered sites, each with its own individual configuration. Additional site configurations are created in subdirectories within the ’sites’ directory. Each subdirectory must have a ’settings.php’ file which specifies the configuration settings. The easiest way to create additional sites is to copy the ’default’ directory and modify the ’settings.php’ file as appropriate. The new directory name is constructed from the site’s URL. The configuration for www.example.com could be in ’sites/example.com/settings.php’ (note that ’www.’ should be omitted if users can access your site at http://example.com/). Sites do not have to have a different domain. You can also use subdomains and subdirectories for Drupal sites. For example, example.com, sub.example.com, and sub.example.com/site3 can all be defined as independent Drupal sites. The setup for a configuration such as this would look like the following: sites/default/settings.php sites/example.com/settings.php sites/sub.example.com/settings.php sites/sub.example.com.site3/settings.php When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration it finds: sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php sites/example.com.site3/settings.php sites/www.sub.example.com/settings.php sites/sub.example.com/settings.php sites/example.com/settings.php sites/default/settings.php If you are installing on a non-standard port, the port number is treated as the deepest subdomain. For example: http://www.example.com:8080/ could be loaded from sites/8080.www.example.com/. The port number will be removed according to the pattern above if no port-specific configuration is found, just like

12 6 Jun 2007 Drupal Handbook

a real subdomain. Each site configuration can have its own site-specific modules and themes in addition to those installed in the standard ’modules’and ’themes’ directories. To use site-specific modules or themes, simply create a ’modules’ or ’themes’ directory within the site configuration directory. For example, if sub.example.com has a custom theme and a custom module that should not be accessible to other sites, the setup would look like this: sites/sub.example.com/: settings.php themes/custom_theme modules/custom_module NOTE: for more information about multiple virtual hosts or the configuration settings, consult the Drupal handbook at drupal.org. MORE INFORMATION ------For platform specific configuration issues and other installation and administration assistance, please consult the Drupal handbook at http://drupal.org/handbook. You can view the wide range of other support options available at http://drupal.org/support.

Formatted Drupal 5.x Installation instructions for better readability Installation

// $Id: INSTALL.txt,v 1.39 2007/01/08 11:59:16 dries Exp $

Table of Contents

1. Changes 2. Requirements 3. Optional requirements 4. Installation 5. Drupal administration 6. Customizing your theme(s) 7. Multisite Configuration 8. More Information

13 Drupal Handbook 6 Jun 2007

Changes

As of Drupal 5.0 installation has been automated by an install script. It is no longer necessary to manually edit the "settings.php" file, and database tables are created automatically. Requirements

Drupal requires a web server, PHP4 (4.3.3 or greater) or PHP5 (http://www.php.net/) and either MySQL (http://www.mysql.com/) or PostgreSQL (http://www.postgresql.org/). The Apache web server and MySQL database are recommended; other web server and database combinations such as IIS and PostgreSQL have been tested to a lesser extent. When using MySQL, version 4.1 or greater is recommended to assure you can safely transfer the database.

For more detailed information about Drupal requirements, see "Requirements" (http://drupal.org/requirements) in the Drupal Handbook.

Guidelines for setting up a server environment with a variety of operating systems and in special cases are available in the Drupal handbook (http://drupal.org/node/260) Optional Requirements

- To use XML-based services such as the Blogger API, Jabber, and RSS syndication, you will need PHP’s XML extension. This extension is enabled by default.

- If you want support for clean URLs, you’ll need mod_rewrite and the ability to use local .htaccess files. Installation

1. Download Drupal

You can obtain the latest Drupal release from http://drupal.org/. The files are in .tar.gz format and can be extracted using most compression tools. On a typical Unix command line, use:

wget http://drupal.org/files/projects/drupal-x.x.tar.gz tar -zxvf drupal-x.x.tar.gz

This will create a new directory drupal-x.x/ containing all Drupal files and directories. Move the contents of that directory into a directory within your web server’s document root or your public HTML directory:

mv drupal-x.x/* drupal-x.x/.htaccess /var/www/html

2. Create the Drupal database

Drupal requires access to a database in order to be installed. Your database user will need sufficient privileges to run Drupal. Additional information about privileges, and instructions to create a database using the command line are available in INSTALL.mysql.txt (for MySQL) or

14 6 Jun 2007 Drupal Handbook

INSTALL.pgsql.txt (for PostgreSQL).

To create a database using PHPMyAdmin or a web-based control panel consult the documentation or ask your webhost service provider.

Take note of the username, password, database name and hostname as you create the database. You will enter these items in the install script.

3. Run the install script

The install script will set the base URL, connect Drupal to the database, and create tables in the database.

To run the install script point your browser to the base url of your website (i.e. http://www.example.com). You will be presented with the "Database Configuration" page.

The install script will attempt to write-protect the settings.php after updating it with the information you provide in the installation routine. If you make manual changes to that file later, be sure to protect it again after making your modifications. Failure to remove write permissions to that file is a security risk. The default location for the settings.php file is at sites/default/settings.php, but it may be in another location if you use the multi-site setup, as explained below.

4. Configure Drupal

When the install script succeeds, you will be directed to the "Welcome" page. In "step one" click "create the first account" which will become the main administrator account with total control. Login as the administrator and complete the initial configuration steps on the "Welcome" page.

Consider creating a "files" subdirectory in your Drupal installation directory. This subdirectory stores files such as custom logos, user avatars, and other media associated with your new site. The sub-directory requires "read and write" permission by the Drupal server process. You can change the name of this subdirectory at "administer > site configuration > file system".

5. Cron Tasks

Many Drupal modules (such as the search functionality) have periodic tasks that must be triggered by a cron job. To activate these tasks, call the cron page by visiting http://www.example.com/cron.php --this will pass control to the modules and the modules will decide if and what they must do.

Most systems support the crontab utility for scheduling tasks like this. The following example crontab line will activate the cron tasks automatically on the hour:

0 * * * * wget -O - -q http://www.example.com/cron.php

More information about the cron scripts are available in the admin help pages and in the Drupal handbook at drupal.org. Example scripts can be found in the scripts/ directory.

15 Drupal Handbook 6 Jun 2007

Drupal Administration

A new installation of Drupal defaults to a very basic configuration with only aw active modules and minimal user access rights.

Use your administration panel to enable and configure services. For example:

General Settings administer > site configuration > site information Enable Modules administer > site configuration > modules Set User Permissions administer > users management > access control Configure Themes administer > site building > themes

For more information on configuration options, read the instructions which accompany the different configuration settings and consult the various help pages available in the administration panel.

Community-contributed modules and themes are available at http://drupal.org/. Customizing your theme(s)

Now that your installation is running, you will want to customize the look of your site. Several sample themes are included and more can be downloaded from drupal.org.

Simple customization of your theme can be done using only CSS. Further changes require understanding the phptemplate engine that is now part of Drupal. See http://drupal.org/handbook/customization to find out more. Multi-site configuration

A single Drupal installation can host several Drupal-powered sites, each with its own individual configuration.

Additional site configurations are created in subdirectories within the ’sites’ directory. Each subdirectory must have a ’settings.php’ file which specifies the configuration settings. The easiest way to create additional sites is to copy the ’default’ directory and modify the ’settings.php’ file as appropriate. The new directory name is constructed from the site’s URL. The configuration for www.example.com could be in ’sites/example.com/settings.php’ (note that ’www.’ should be omitted if users can access your site at http://example.com/).

Sites do not have to have a different domain. You can also use subdomains and subdirectories for Drupal sites. For example, example.com, sub.example.com, and sub.example.com/site3 can all be defined as independent Drupal sites. The setup for a configuration such as this would look like the following: sites/default/settings.php sites/example.com/settings.php sites/sub.example.com/settings.php sites/sub.example.com.site3/settings.php

16 6 Jun 2007 Drupal Handbook

When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration it finds: sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php sites/example.com.site3/settings.php sites/www.sub.example.com/settings.php sites/sub.example.com/settings.php sites/example.com/settings.php sites/default/settings.php

If you are installing on a non-standard port, the port number is treated as the deepest subdomain. For example: http://www.example.com:8080/ could be loaded from sites/8080.www.example.com/. The port number will be removed according to the pattern above if no port-specific configuration is found, just like a real subdomain.

Each site configuration can have its own site-specific modules and themes in addition to those installed in the standard ’modules’and ’themes’ directories. To use site-specific modules or themes, simply create a ’modules’ or ’themes’ directory within the site configuration directory. For example, if sub.example.com has a custom theme and a custom module that should not be accessible to other sites, the setup would look like this: sites/sub.example.com/: settings.php themes/custom_theme modules/custom_module

NOTE: for more information about multiple virtual hosts or the configuration settings, consult the Drupal handbook at drupal.org. More Information

For platform specific configuration issues and other installation and administration assistance, please consult the Drupal handbook at http://drupal.org/handbook. You can view the wide range of other support options available at http://drupal.org/support.

Formatted Drupal 4.7.x Installation instructions for better readability Installation

// $Id: INSTALL.txt,v 1.6 2004/11/27 11:28:55 dries Exp $

This document outlines the standard installation process.

17 Drupal Handbook 6 Jun 2007

1. REQUIREMENTS 2. SERVER CONFIGURATION 3. OPTIONAL COMPONENTS 4. INSTALLATION 5. DRUPAL ADMINISTRATION 6. CUSTOMIZING YOUR THEME(S) 7. UPGRADING 8. MORE INFORMATION

REQUIREMENTS

1. Drupal requires a web server, PHP4 (http://www.php.net/) and either MySQL, PostgreSQL or a database server supported by the PHP PEAR API (http://pear.php.net/). 2. To Install you will need an FTP program to upload files to the server, or shell access if you wish to install using the commands listed below; access to run database scripts directly or a tool such as PHPMyAdmin to manage a database; knowledge of how to use either FTP programs or shell access to set permissions on directories, and how to run database scripts. 3. NOTE: The Apache web server and MySQL database are strongly recommended; other web server and database combinations such as IIS and PostgreSQL are possible but tested to a lesser extent.

SERVER CONFIGURATION

Your PHP must have the following settings: session.save_handler user

In addition, we recommend the following settings: session.cache_limiter none

These values are set in php.ini and can be overwritten in a .htaccess file; you can print out your local PHP settings with PHP’s phpinfo() function.

OPTIONAL COMPONENTS

To use XML-based services such as the Blogger API, Jabber, RSS syndication, you will need PHP’s XML extension. This extension is enabled by default in standard PHP4 installations. If you want support for clean URLs, you’ll need mod_rewrite and the ability to use local .htaccess files. (More information can be found in the Drupal handbook on drupal.org.)

18 6 Jun 2007 Drupal Handbook

INSTALLATION 1. DOWNLOAD DRUPAL

You can obtain the latest Drupal release from http://drupal.org/. Download the current tar.gz format and extract the files:

$ wget http://drupal.org/files/project/drupal-x.x.x.tgz $ tar -zxvf drupal-x.x.x.tgz

This will create a new directory drupal-x.x.x/ containing all Drupal files and directories. Move the contents of that directory into a directory within your web server’s document root or your public HTML directory:

$ mv drupal-x.x.x/* drupal-x.x.x/.htaccess /var/www/html

2. CREATE THE DRUPAL DATABASE

These instructions are for MySQL. If you are using another database, check the database documentation. In the following examples, "dba_user" is an example MySQL user which has the CREATE and GRANT privileges. You will need to use the appropriate user name for your system.

First, you must create a new database for your Drupal site:

$ mysqladmin -u dba_user -p create drupal

MySQL will prompt for the dba_user database password and then create the initial database files. Next you must login and set the access database rights:

$ mysql -u dba_user -p

Again, you will be asked for the dba_user database password. At the MySQL prompt, enter following command:

GRANT ALL PRIVILEGES ON drupal.* TO nobody@localhost IDENTIFIED BY ’password’; where

’drupal’ is the name of your database ’nobody@localhost’ is the userid of your webserver MySQL account ’password’ is the password required to log in as the MySQL user

19 Drupal Handbook 6 Jun 2007

If successful, MySQL will reply with

Query OK, 0 rows affected to activate the new permissions you must enter the command flush privileges; and then enter ’\q’ to exit MySQL. 3. LOAD THE DRUPAL DATABASE SCHEME

Once you have a database, you must load the required tables:

$ mysql -u nobody -p drupal < database/database.mysql

4. CONNECTING DRUPAL

The default configuration can be found in the ’sites/default/settings.php’ file within your Drupal installation. Before you can run Drupal, you must set the database URL and the base URL to the web site. Open the configuration file and edit the $db_url line to match the database defined in the previous steps:

$db_url = "mysql://username:password@localhost/drupal";

Set $base_url to match the address to your web site:

$base_url = "http://www.example.com";

In addition, a single Drupal installation can host several Drupal-powered sites, each with its own individual configuration. If you don’t need to run multiple Drupal sites, you can skip to the next section.

Additional site configurations are created in subdirectories within the ’sites’ directory. Each site subdirectory must have a ’settings.php’ file which specifies the configuration settings. The easiest way to create additional sites is to copy the ’default’ directory and modify the ’settings.php’ file as appropriate. The new directory name is constructed from the site’s URL. The configuration for www.example.com could be in ’sites/example.com/settings.php’ (note that ’www.’ should be omitted if users can access your site at http://example.com/).

Sites do not each have to have a different domain. You can use subdomains and subdirectories for Drupal sites also. For example, example.com, sub.example.com, and sub.example.com/site3 can all be

20 6 Jun 2007 Drupal Handbook

defined as independent Drupal sites. The setup for a configuration such as this would look like the following:

sites/default/settings.php sites/example.com/settings.php sites/sub.example.com/settings.php sites/sub.example.com.site3/settings.php When searching for a site configuration (for example www.sub.example.com/site3), Drupal will search for configuration files in the following order, using the first configuration file it finds: sites/www.sub.example.com.site3/settings.php sites/sub.example.com.site3/settings.php sites/example.com.site3/settings.php sites/www.sub.example.com/settings.php sites/sub.example.com/settings.php sites/example.com/settings.php sites/default/settings.php

Each site configuration can have its own site-specific modules and themes that will be made available in addition to those installed in the standard ’modules’ and ’themes’ directories. To use site-specific modules or themes, simply create a ’modules’ or ’themes’ directory within the site configuration directory. For example, if sub.example.dom has a custom theme and a custom module that should not be accessible to other sites, the setup would look like this:

sites/sub.example.com/: settings.php themes/: custom_theme modules/: custom_module

NOTE: for more information about multiple virtual hosts or the configuration settings, consult the Drupal handbook at drupal.org. 5. CONFIGURE DRUPAL

You can now launch your browser and point it to your Drupal site.

Create an account and login. The first account will automatically become the main administrator account.

21 Drupal Handbook 6 Jun 2007

6. CRON TASKS

Many Drupal modules have periodic tasks that must be triggered by a cron job. To activate these tasks, you must call the cron page; this will pass control to the modules and the modules will decide if and what they must do.

The following example crontab line will activate the cron script on the hour:

0 * * * * wget -O - -q http://HOSTNAME/cron.php

More information about the cron scripts are available in the admin help pages and in the Drupal handbook at drupal.org. Example scripts can be found in the scripts/ directory.

DRUPAL ADMINISTRATION

Upon a new installation, your Drupal website defaults to a very basic configuration with only a few active modules, one theme, and no user access rights.

Use your administration panel to enable and configure services. For example, set some general settings for your site with "Administration - configuration". Enable modules via "Administration - configuration - modules". User permissions can be set with "Administration - accounts - permissions".

For more information on configuration options, read through the instructions which accompany the different configuration settings and consult the various help pages available in the administration panel.

Note that additional community-contributed modules and themes are available at http://drupal.org/.

CUSTOMIZING YOUR THEME(S)

Now that your server is running, you will want to customize the look of your site. Several sample themes are included in the Drupal installation and more can be downloaded from drupal.org.

Customizing each theme depends on the theme. In general, each theme contains a PHP file themename.theme which defines a function header() that can be changed to reference your own logos.

22 6 Jun 2007 Drupal Handbook

Most themes also contain stylesheets or PHP configuration files to tune the colors and layouts; check the themes/ directory for README files describing each alternate theme.

UPGRADING

1. Backup your database and Drupal directory - especially your configuration file (www.example.com.conf or includes/conf.php). 2. Log on as the user with user ID 1. 3. Remove all the old Drupal files then unpack the new Drupal files into the directory that you run Drupal from. 4. Modify the new configuration file to make sure it has the correct information. 5. Run update.php by visiting http://www.example.com/update.php.

MORE INFORMATION

For platform specific configuration issues and other installation and administration assistance, please consult the Drupal handbook at http://drupal.org/. You can also find support at the Drupal support forum or through the Drupal mailing lists.

10 minute install using PuTTY SSH/Telnet client

I’ve been developing best practices for my development company and wanted to share/collaborate on some of them.

Development environment:

Server: LAMP SSH/Telenet Client: PuTTY Server Interface: WHM Must have root access.

10 minute Install:

[login root via PuTTY] # cd /home/youraccountname # wget http://ftp.osuosl.org/pub/drupal/files/projects/drupal-x.x.tar.gz [Note: the "x.x" should be replaced with the version of drupal you’re installing, e.g. "5.1"] # tar -zxvf drupal-5.1.tar.gz # mv drupal-x.x/* drupal-x.x/.htaccess /home/youraccountname/public_html [Note: See the note above regarding "x.x"]

23 Drupal Handbook 6 Jun 2007

# rm drupal-x.x.tar.gz # cd public_html # mkdir files # chmod 777 files # cd sites/all # mkdir modules # mkdir themes # cd modules # mkdir custom # mkdir drupal-contrib # cd ../ # cd themes # mkdir custom # mkdir drupal-contrib # cd ../ # cd ../ # cd default # chmod 777 settings.php # mysql mysql> CREATE DATABASE youraccountname_drupal; mysql> GRANT ALL PRIVILEGES ON youraccountname_drupal.* TO ’your accountname_yourusername’@’localhost’ IDENTIFIED BY ’yourpassword’; mysql> \q [open your browser. enter your site’s URL, and enter database information] [go back to PuTTY to chmod on "settings.php"] # chmod 755 settings.php # logout [back to browser, refresh browser, and then "visit new site" (or whatever the link says to new website), create first "superuser" account, etc.]

How I installed Drupal: The Eightfold Way

Try this for a supereasy install.

This installation is for a test site.

The aim is to have a test site: \http://drupal.yoursite.com\

When the test site is functioning, the drupal subdomain prefix will be deleted. Therefore the domain name in the root will be mysite.com The DNS servers will automatically point to this (hopefully!). This is what worked for me:

1) Downloaded Drupal 5.0 2) Created a subdomain ("drupal") via my webhost’s control panel 3) Created a database ("dbname") via my webhost’s control panel (note the user name and

24 6 Jun 2007 Drupal Handbook

password). Noted the hostname, e.g., testsite.yoursite.com 4) Using browser, pointed to URL \http://drupal.yoursite.com\ 5) The install.php script automatically installed Drupal 6) Entered information. Database name ("dbname"), username, password 7) Clicked "Advanced options" 8) Entered hostname (e.g., testsite.yoursite.com). Went to testsite.yoursite.com in browser.

Installing virtual hosts for Drupal sites and subsites

The purpose of this guide is to concisely summarize how to implement apache vhost settings for each site or subsite.

All steps for this tutorial were implemented with Debian using Apache version 2.0.54.

1. Gain entrance into your shell system, and su to root or another user that can edit apache2 configuration files. 2. Go to your apache configuration files: cd /etc/apache2/sites-available 3. Create a configuration file for your new site. For an example site, www.example.com, we make the site as such: nano example.com

ServerAdmin me@myserver DocumentRoot /home/web/drupal/ ServerName www.example.com ServerAlias example.com *.example.com RewriteEngine On RewriteOptions inherit CustomLog /var/log/apache2/example.com.log combined ServerAdmin me@myserver DocumentRoot /home/web/drupal/ ServerName www.example.com ServerAlias example.com *.example.com RewriteEngine On RewriteOptions inherit CustomLog /var/log/apache2/example.com.log combined # SSL Specific options SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile /etc/ssl/apache/CA.crt SSLCertificateKeyFile /etc/ssl/apache/CA.key SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown

25 Drupal Handbook 6 Jun 2007

Activate the site’s configuration: a2ensite www.example.com Reload Apache’s configuration: /etc/init.d/apache2 force-reload

Done!

Please post any changes or concerns,

Tarek : )

Mac OS X-specific guidelines

Install and configure Mysql and PHP, if necessary. Server Logistics provides nice pre-compiled packages and instructions. PHP is also available from Marc Liyanage. PHP may already be installed on your system, so check first.

The stock version of Apache should be fine (typically 1.33).

Turn on "personal web sharing" in the sharing panel of System Preferences to start Apache. Now comes the more involved part- changing the webserver configuration.

To make changes to the Apache configuration you should NOT edit /etc/httpd/httpd.conf but instead edit files in /private/etc/httpd/users/. Any file in the directory /private/etc/httpd/users/ ending with â.confâ will effectively be appended to /etc/httpd/httpd.conf. So any changes you want to make should be made in one or more configuration files of your own construction. System updates will leave these files untouched. You can create a file /private/etc/httpd/users/drupal.conf for all your Drupal-specific changes (even if you have no user named Drupal) and they will be loaded when Apache starts up.

Note: for Mac OS X Server 10.4 (Tiger Server) and most likely previous versions as well, do not make changes to /etc/httpd/httpd.conf expecting the AllowOverride All directive to work. The correct file to add the AllowOverride All directive is in the directory /etc/httpd/sites/. In that directory are the virtual host configuration files. Each virtual server has a configuration file in that directory so it is in those files that you must enable AllowOverride All. If you only have one web server on your server configured, then the file you want to modify is /etc/httpd/sites/0000_any_80_.conf.

To enable clean URLs you will need the following code in your conf file. You’ll need to be root (or sudo) to do this. Don’t forget to restart apache after modifying httpd.conf (turn personal web sharing off, then back on again, or use /usr/sbin/apachectl restart).

# # This controls which options the .htaccess files in directories can # override. Can also be "All", or any combination of "Options", "FileInfo", # "AuthConfig", and "Limit" #

26 6 Jun 2007 Drupal Handbook

# AllowOverride None AllowOverride All

You may also need to edit this file to enable the PHP module for Apache. You have to uncomment two lines. First in this section:

# # Dynamic Shared Object (DSO) Support #

Uncomment this line (around line 235) by removing the #:

#LoadModule php4_module libexec/httpd/libphp4.so

Then go below to this section:

# Reconstruction of the complete module list from all available modules # (static and shared ones) to achieve correct module execution order. and uncomment this line (around line 278) by removing the #:

#AddModule mod_php4.c

Drupal goes into /Library/WebServer/Documents/, or ~/Sites. If you use ~/Sites, you may also have to edit the .conf file in /etc/httpd/users that corresponds to your user account. You must AllowOverride in this file for your ~/Sites for clean URLs to work there.

After any edits to your .conf files, be sure to restart Apache (as described above).

MacZeaolots has a good tutorial on installing Drupal on Mac OS X 10.4. The same tutorial applies to 10.3 as well. While the tutorial talks about Drupal 4.6, the setup of the server environment is the same for any version of Drupal. Important notes for MySQL install:

The version of PHP that Apple included with Mac OS X 10.4.4 has mysql.default_socket set to "/var/mysql/mysql.sock", while the binary version of MySQL from mysql.com uses "/tmp/mysql.sock". This will cause PHP to fail to connect to mysql with a message in Drupal like

can’t connect to local MySQL server through socket ’/var/lib/mysql/mysql.sock’ (2)

Make PHP look for "/tmp/mysql.sock" by setting this in /etc/php.ini:

; Default socket name for local MySQL connects. If empty, uses the built-in ; MySQL defaults. mysql.default_socket = /tmp/mysql.sock

27 Drupal Handbook 6 Jun 2007

You can instead set this in /etc/my.cnf.

#Name of the socket file to use. socket=/var/mysql/mysql.sock

Both work, but the second one may make the MySQL preference pane stop working.

You may also need to restart apache to have this take effect.

Restart from the terminal:

$ sudo apachectl restart or restart by disabling and re-enabling personal web sharing. HOWTO: Create a local server environment for drupal using MAMP

MAMP creates a local server environment on Mac OS X by installing PHP, MySQL, and Apache all at once. This will hopefully make Drupal much easier to install because the components don’t have to be installed separately. This page is to be used in conjunction with the installation instructions for Drupal on Mac OS X.

1. Download MAMP (This will install Apache, MySQL, and PHP in one step.) Find the latest version here: http://www.mamp.info/ Download and drag to Applications folder to install. Open MAMP and click "start servers," then "Open start page."

2. Download Drupal Find the latest Drupal release here: http://drupal.org/.

Move the directory containing the Drupal files into the MAMP htdocs directory: mv drupal-x.x.x/* drupal-x.x.x/.htaccess /Applications/MAMP/htdocs/

3. Create the Drupal database

Go to the MAMP start page and click "phpMyAdmin." Create a new database and follow the instructions in INSTALL.mysql.txt to upload the required files from your Drupal installation.

4. Connect Drupal Set the database URL in the ’sites/default/settings.php’ file in your Drupal installation using the information provided on the MAMP start page and the name you used for the database you created in step 3.

$db_url = "mysql://username:password@localhost/databasename";

28 6 Jun 2007 Drupal Handbook

5. Start configuring Drupal! Go to http://localhost:8888/drupal-x.x.x/ and create the first account. Continue with instructions in INSTALL.txt. HOWTO: Installing PostgreSQL and MySQL on the same Mac OS X machine

If you’re interested in helping to ensure that Drupal and its contributed modules are compatible with both MySQL and PostgreSQL (also known as "pgsql"), you should consider setting up local test sites using both database back ends on the same machine. You can even configure both sites to point to the same Drupal installation, using symbolic links.

Unfortunately, the version of PHP that ships with Mac OS by default is not compatible with PostgreSQL, so to do this, you will need to compile both pgsql and php from source. While you’re at it, you might want to upgrade to a newer version of MySQL, as well.

1. Make a directory where you can build all of these programs. For example: mkdir /usr/local/src cd /usr/local/src

Download the latest copies of everything you need: PHP -- http://www.php.net/downloads.php MySQL -- http://www.mysql.com/downloads PostgreSQL -- http://www.postgresql.org/download Unpackage all of these inside /usr/local/src Configure and build MySQL. Good instructions can be found on this page: MySQL on Mac OS X. The important thing is that when you run configure you use a reasonable value for the --prefix flag. For example: ./configure --prefix=/usr/local/mysql Configure and build PostgreSQL. Once again, useful installation docs can be found here: PostgreSQL on Mac OS X, though the section about "Postgres and PHP" isn’t what you want to read. Again, be sure you use a reasonable value for the--prefix flag. For example: ./configure --prefix=/usr/local/pgsql Configure and build PHP. After some trial and error, getting PHP working properly with both MySQL and PostgreSQL required a carefully crafted configure line: ./configure --with-pgsql=/usr/local/pgsql --with-mysql=/usr/local/mysql --with-apxs --with-kerberos=/usr --with-zlib-dir=/usr --enable-cli --enable-trans-sid --with- --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-dbx --enable-sockets --with-iodbc=/usr --with-curl=/usr --with-config-file-path=/etc --sysconfdir=/private/etc --with-mysql-sock=/var/mysql/mysql.sock Some noteworthy things about this command:

This matches the flags used for the default PHP installed on Mac OS X as closely as possible, while also enabling PostgreSQL support.

29 Drupal Handbook 6 Jun 2007

The path you use for --with-pgsql must match whatever you specified for --prefix when building PostgreSQL. The path you use for --with-mysql must match whatever you specified for --prefix when building MySQL. The path you use for --with-mysql-sock should match whatever you specified for --with-unix-socket-path when building MySQL.

Additional information about building PHP on Mac OS X machines can be found on the developer.apple.com site: PHP on Mac OS X Installing Drupal on Mac OS X 10.4 Tiger

Mac OS X 10.4 Tiger comes with PHP (though it’s disabled by default) and without MySQL. Here’s how to get Drupal up and running from a stock Tiger installation.

Installing and Configuring MySQL

Downloaded the latest MySQL installer from dev.mysql.com. I chose the Mac OS X Installer Package for 10.3.

I double-clicked the file that I downloaded (mysql-standard-4.1.11-apple-darwin7.8.0-powerpc.dmg), then double-clicked the mysql-standard-4.1.11-apple-darwin7.8.0-powerpc.pkg icon to run the installer and install MySQL.

Next, I installed the MySQLStartupItem.pkg because I want MySQL to start up when I start my Mac.

Then, I copied the MySQL.prefPane into the PreferencePanes folder in my Library folder at the root level of my hard drive. Tiger asked me to authenticate when I did this. Upon opening my System Preferences, I can indeed see a pretty MySQL icon.

I wanted to test to see if MySQL would really start up, so I restarted. Sure enough, MySQL was running.

Next, it was time to set initial passwords for MySQL. To do that, I opened the Terminal (in the Utilities folder). Then I typed in the following: export PATH="$PATH:/usr/local/mysql/bin"

This tells your computer that when it interprets commands, it should also look in the freshly created MySQL installation for MySQL commands. If you want it added permanently instead of just for this terminal session, you could edit the third line of /etc/profile to read

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/mysql/bin"

30 6 Jun 2007 Drupal Handbook

and then start a new Terminal window.

Next, we want to make MySQL secure by setting a MySQL root password. Fortunately a handy utility is provided to make that easy. I typed in: mysql_secure_installation

Interacting with the script looked like this (note that at the first prompt I just pressed enter since no root password has been set yet:

Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. Set root password? [Y/n] Y New password: zoinks Re-enter new password: zoinks Password updated successfully! Reloading privilege tables.. ... Success! By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y ... Success! Normally, root should only be allowed to connect from ’localhost’. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y ... Success! By default, MySQL comes with a database named ’test’ that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y - Dropping test database...... Success! - Removing privileges on test database...... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you’ve completed all of the above steps, your MySQL

31 Drupal Handbook 6 Jun 2007

installation should now be secure. Thanks for using MySQL!

I verified that MySQL was running:

$ mysqladmin -u root -p status Enter password: zoinks Uptime: 938 Threads: 1 Questions: 16 Slow queries: 0 Opens: 21 Flush tables: 1 Open tables: 0 Queries per second avg: 0.017

It was running fine. Now on to the task of setting up MySQL for Drupal.

Sending mail

Current versions of OS X use Postfix as the mail server but you have to enable it.

For a detailed how-to, see: http://www.stepwise.com/Articles/Workbench/eart.index.html

Or save yourself lots of frustration and time and spend $10 for Postfix Enabler and get running in a couple of minutes. http://cutedgesystems.com/software/PostfixEnabler/

Creating the Drupal Database and Database User

Now that MySQL is installed and we have a root password established for it, it’s time to create the database that Drupal will use:

$ mysqladmin -u root -p create drupal Enter password: zoinks

The database was created. Time to create the user. The user in this example will be called drupaldbuser and the password for that user will be fuffy.

$ mysql -u root -p Enter password: zoinks Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 to server version: 4.1.11-standard Type ’help;’ or ’\h’ for help. Type ’\c’ to clear the buffer. mysql> GRANT ALL PRIVILEGES ON drupal.* TO drupaldbuser@localhost IDENTIFIED BY ’fuffy’; Query OK, 0 rows affected (0.04 sec)

If you are using MySQL 4.1 or later, the following command is necessary because Tiger comes with PHP 4, and the MySQL libraries for PHP 4 use a different authentication protocol. mysql> SET PASSWORD FOR ’drupaldbuser’@’localhost’ = OLD_PASSWORD(’fuffy’); Query OK, 0 rows affected (0.00 sec)

32 6 Jun 2007 Drupal Handbook

Now we apply the new settings: mysql> flush privileges; Query OK, 0 rows affected (0.19 sec) mysql> \q Bye

Now I paused to rejoice. MySQL was installed and ready for Drupal. Now it was time to install Drupal itself.

Installing using CVS repository

Development of the Drupal codebase is fairly quick, with a new release every six months or so. So I decided to use the CVS repository to download Drupal. That way I can use the "cvs update" command to keep my Drupal installation current with bug fixes and improvements.

I have the cvs option available to me because I installed the developer tools that were included on the OS 10.4 DVD. If you don’t have them installed, or don’t want to install them, you could always download Drupal directly and place the resulting directory inside

/Library/WebServer/Documents

First, I navigated to where I want my Drupal installation. Just to be consistent with Mac OS 10.4, I used /Library/WebServer/Documents: cd /Library/WebServer/Documents

And now I pulled down the latest version of the Drupal 4.6 release: cvs -z9 -d:pserver:anonymous:[email protected]:/cvs/drupal checkout -r DRUPAL-4-6 drupal

This created a directory called drupal that contains the latest code for version 4.6. If, next week, I hear that a bugfix has been issued for 4.6, all I have to do is cd /Library/WebServer/Documents cvs update

By default, Apache on the Mac runs as user ’www’ with group ’www’, so you probably need to do the following in order to allow drupal to create directories and files: chown -R www drupal chgrp -R www drupal

Now it was time to create all the database tables that Drupal needs:

$ mysql -u drupaldbuser -p drupal < /Library/WebServer/Documents/drupal/database/database.mysql Enter password: fuffy

33 Drupal Handbook 6 Jun 2007

Now I had MySQL running, and had a Drupal database populated by Drupal’s fields. It was time to tell Drupal how to find that database.

In the Finder, I went to /Library/WebServer/Documents/Drupal/sites and duplicated the folder called default, and renamed it localhost. Then inside the new localhost directory I edited the settings.php file, changing line 81 to read:

$db_url = ’mysql://drupaldbuser:fuffy@localhost/drupal’; and changing line 90 to read:

$base_url = ’http://localhost/drupal’;

The reason I duplicated the "default" settings folder was to avoid conflicts when I update CVS in the future, since CVS would have seen the changed settings.php file and tried to merge it with the original one. By keeping my settings file separate, I avoid this. As long as I access my Drupal installation through the URL http://localhost/drupal it will use the settings in the localhost folder.

PHP is not enabled by default on OS 10.4. So I enabled it by editing Apache’s configuration file. I used BBEdit, but you can use any you want. For example, you could choose Go To Folder from the Finder’s Go menu and type in /etc/httpd, then double-click on httpd.conf and OS 10.4 will prompt you for an application to edit the file with. Here’s me opening the file for editing in BBEdit: sudo bbedit /etc/httpd/httpd.conf

Then I removed the # from in front of line 240:

#LoadModule php4_module libexec/httpd/libphp4.so and line 284:

#AddModule mod_php4.c and line 406:

AllowOverride All

After changing the configuration file, I stopped, then started the Personal Web Sharing service in the Sharing pane of System Preferences. This forces Apache to reread the configuration file and apply the changes. So now PHP was enabled.

Now, with my hands shaking from excitement, I entered http://localhost/drupal into my web browser. I was greeted with Drupal’s welcome page:

34 6 Jun 2007 Drupal Handbook

I clicked on the link entitled "create the first account", and saw:

Since this was the first account I created on Drupal, I knew it would have special privileges, so I named it admin and typed in my e-mail address. (Warning: naming your administrative account "admin" is bad security! Don’t do this!) Then I clicked on the "Create new account" button. Drupal responded with a randomly generated password and an opportunity to log in immediately:

35 Drupal Handbook 6 Jun 2007

I took the opportunity to log in immediately by clicking the "Log in" button. On the resulting screen I changed my password to something I could remember and clicked Submit.

Now I’ve got Drupal running on Mac OS 10.4. Time to celebrate with a swig of flavinoid-laden grape juice.

Prefixed database.mysql for search and replace

Use a texteditor with search & replace functionality to replace ’prefix’ with your own eg. site1, site2. This is database.mysql from 4.6.5. Contributed by Shane Birley.

-- MySQL dump 8.22 -- -- Host: localhost Database: drupal_devel -- Server version 3.23.52-nt -- -- Table structure for table ’access’ -- CREATE TABLE prefix_access ( aid tinyint(10) NOT NULL auto_increment, mask varchar(255) NOT NULL default ’’, type varchar(255) NOT NULL default ’’, status tinyint(2) NOT NULL default ’0’, PRIMARY KEY (aid) ) TYPE=MyISAM; -- -- Table structure for table ’accesslog’ -- CREATE TABLE prefix_accesslog ( aid int(10) NOT NULL auto_increment, title varchar(255) default NULL, path varchar(255) default NULL, url varchar(255) default NULL,

36 6 Jun 2007 Drupal Handbook

hostname varchar(128) default NULL, uid int(10) unsigned default ’0’, timestamp int(11) unsigned NOT NULL default ’0’, KEY accesslog_timestamp (timestamp), PRIMARY KEY (aid) ) TYPE=MyISAM; -- -- Table structure for table ’aggregator_category’ -- CREATE TABLE prefix_aggregator_category ( cid int(10) NOT NULL auto_increment, title varchar(255) NOT NULL default ’’, description longtext NOT NULL, block tinyint(2) NOT NULL default ’0’, PRIMARY KEY (cid), UNIQUE KEY title (title) ) TYPE=MyISAM; -- -- Table structure for table ’aggregator_category_feed’ -- CREATE TABLE prefix_aggregator_category_feed ( fid int(10) NOT NULL default ’0’, cid int(10) NOT NULL default ’0’, PRIMARY KEY (fid,cid) ) TYPE=MyISAM; -- -- Table structure for table ’aggregator_category_item’ -- CREATE TABLE prefix_aggregator_category_item ( iid int(10) NOT NULL default ’0’, cid int(10) NOT NULL default ’0’, PRIMARY KEY (iid,cid) ) TYPE=MyISAM; -- -- Table structure for table ’aggregator_feed’ -- CREATE TABLE prefix_aggregator_feed ( fid int(10) NOT NULL auto_increment, title varchar(255) NOT NULL default ’’, url varchar(255) NOT NULL default ’’, refresh int(10) NOT NULL default ’0’, checked int(10) NOT NULL default ’0’, link varchar(255) NOT NULL default ’’, description longtext NOT NULL, image longtext NOT NULL, etag varchar(255) NOT NULL default ’’, modified int(10) NOT NULL default ’0’,

37 Drupal Handbook 6 Jun 2007

block tinyint(2) NOT NULL default ’0’, PRIMARY KEY (fid), UNIQUE KEY link (url), UNIQUE KEY title (title) ) TYPE=MyISAM; -- -- Table structure for table ’aggregator_item’ -- CREATE TABLE prefix_aggregator_item ( iid int(10) NOT NULL auto_increment, fid int(10) NOT NULL default ’0’, title varchar(255) NOT NULL default ’’, link varchar(255) NOT NULL default ’’, author varchar(255) NOT NULL default ’’, description longtext NOT NULL, timestamp int(11) default NULL, PRIMARY KEY (iid) ) TYPE=MyISAM; -- -- Table structure for table ’authmap’ -- CREATE TABLE prefix_authmap ( aid int(10) unsigned NOT NULL auto_increment, uid int(10) NOT NULL default ’0’, authname varchar(128) NOT NULL default ’’, module varchar(128) NOT NULL default ’’, PRIMARY KEY (aid), UNIQUE KEY authname (authname) ) TYPE=MyISAM; -- -- Table structure for table ’blocks’ -- CREATE TABLE prefix_blocks ( module varchar(64) DEFAULT ’’ NOT NULL, delta varchar(32) NOT NULL default ’0’, status tinyint(2) DEFAULT ’0’ NOT NULL, weight tinyint(1) DEFAULT ’0’ NOT NULL, region tinyint(1) DEFAULT ’0’ NOT NULL, custom tinyint(2) DEFAULT ’0’ NOT NULL, throttle tinyint(1) DEFAULT ’0’ NOT NULL, visibility tinyint(1) DEFAULT ’0’ NOT NULL, pages text NOT NULL, types text NOT NULL ) TYPE=MyISAM; -- -- Table structure for table ’book’ --

38 6 Jun 2007 Drupal Handbook

CREATE TABLE prefix_book ( nid int(10) unsigned NOT NULL default ’0’, parent int(10) NOT NULL default ’0’, weight tinyint(3) NOT NULL default ’0’, log longtext, PRIMARY KEY (nid), KEY parent (parent) ) TYPE=MyISAM; -- -- Table structure for table ’boxes’ -- CREATE TABLE prefix_boxes ( bid tinyint(4) NOT NULL auto_increment, title varchar(64) NOT NULL default ’’, body longtext, info varchar(128) NOT NULL default ’’, format int(4) NOT NULL default ’0’, PRIMARY KEY (bid), UNIQUE KEY title (title), UNIQUE KEY info (info) ) TYPE=MyISAM; -- -- Table structure for table ’cache’ -- CREATE TABLE prefix_cache ( cid varchar(255) NOT NULL default ’’, data longtext, expire int(11) NOT NULL default ’0’, created int(11) NOT NULL default ’0’, headers text, PRIMARY KEY (cid), INDEX expire (expire) ) TYPE=MyISAM; -- -- Table structure for table ’comments’ -- CREATE TABLE prefix_comments ( cid int(10) NOT NULL auto_increment, pid int(10) NOT NULL default ’0’, nid int(10) NOT NULL default ’0’, uid int(10) NOT NULL default ’0’, subject varchar(64) NOT NULL default ’’, comment longtext NOT NULL, hostname varchar(128) NOT NULL default ’’, timestamp int(11) NOT NULL default ’0’, score mediumint(9) NOT NULL default ’0’, status tinyint(3) unsigned NOT NULL default ’0’,

39 Drupal Handbook 6 Jun 2007

format int(4) NOT NULL default ’0’, thread varchar(255) NOT NULL, users longtext, name varchar(60) default NULL, mail varchar(64) default NULL, homepage varchar(255) default NULL, PRIMARY KEY (cid), KEY lid (nid) ) TYPE=MyISAM; -- -- Table structre for table ’node_last_comment’ -- CREATE TABLE prefix_node_comment_statistics ( nid int(10) unsigned NOT NULL auto_increment, last_comment_timestamp int(11) NOT NULL default ’0’, last_comment_name varchar(60) default NULL, last_comment_uid int(10) NOT NULL default ’0’, comment_count int(10) unsigned NOT NULL default ’0’, PRIMARY KEY (nid), KEY node_comment_timestamp (last_comment_timestamp) ) TYPE=MyISAM; -- -- Table structure for table ’directory’ -- CREATE TABLE prefix_directory ( link varchar(255) NOT NULL default ’’, name varchar(128) NOT NULL default ’’, mail varchar(128) NOT NULL default ’’, slogan longtext NOT NULL, mission longtext NOT NULL, timestamp int(11) NOT NULL default ’0’, PRIMARY KEY (link) ) TYPE=MyISAM; -- -- Table structure for table ’files’ -- CREATE TABLE prefix_files ( fid int(10) unsigned NOT NULL default ’0’, nid int(10) unsigned NOT NULL default ’0’, filename varchar(255) NOT NULL default ’’, filepath varchar(255) NOT NULL default ’’, filemime varchar(255) NOT NULL default ’’, filesize int(10) unsigned NOT NULL default ’0’, list tinyint(1) unsigned NOT NULL default ’0’, PRIMARY KEY (fid) ) TYPE=MyISAM; --

40 6 Jun 2007 Drupal Handbook

-- Table structure for table ’filter_formats’ -- CREATE TABLE prefix_filter_formats ( format int(4) NOT NULL auto_increment, name varchar(255) NOT NULL default ’’, roles varchar(255) NOT NULL default ’’, cache tinyint(2) NOT NULL default ’0’, PRIMARY KEY (format) ) TYPE=MyISAM; -- -- Table structure for table ’filters’ -- CREATE TABLE prefix_filters ( format int(4) NOT NULL default ’0’, module varchar(64) NOT NULL default ’’, delta tinyint(2) DEFAULT ’0’ NOT NULL, weight tinyint(2) DEFAULT ’0’ NOT NULL, INDEX (weight) ) TYPE=MyISAM; -- -- Table structure for table ’flood’ -- CREATE TABLE prefix_flood ( event varchar(64) NOT NULL default ’’, hostname varchar(128) NOT NULL default ’’, timestamp int(11) NOT NULL default ’0’ ) TYPE=MyISAM; -- -- Table structure for table ’forum’ -- CREATE TABLE prefix_forum ( nid int(10) unsigned NOT NULL default ’0’, tid int(10) unsigned NOT NULL default ’0’, PRIMARY KEY (nid), KEY tid (tid) ) TYPE=MyISAM; -- -- Table structure for table ’history’ -- CREATE TABLE prefix_history ( uid int(10) NOT NULL default ’0’, nid int(10) NOT NULL default ’0’, timestamp int(11) NOT NULL default ’0’, PRIMARY KEY (uid,nid) ) TYPE=MyISAM; -- -- Table structure for table ’locales_meta’

41 Drupal Handbook 6 Jun 2007

-- CREATE TABLE prefix_locales_meta ( locale varchar(12) NOT NULL default ’’, name varchar(64) NOT NULL default ’’, enabled int(2) NOT NULL default ’0’, isdefault int(2) NOT NULL default ’0’, plurals int(1) NOT NULL default ’0’, formula varchar(128) NOT NULL default ’’, PRIMARY KEY (locale) ) TYPE=MyISAM; -- -- Table structure for table ’locales_source’ -- CREATE TABLE prefix_locales_source ( lid int(11) NOT NULL auto_increment, location varchar(255) NOT NULL default ’’, source blob NOT NULL, PRIMARY KEY (lid) ) TYPE=MyISAM; -- -- Table structure for table ’locales_target’ -- CREATE TABLE prefix_locales_target ( lid int(11) NOT NULL default ’0’, translation blob NOT NULL, locale varchar(12) NOT NULL default ’’, plid int(11) NOT NULL default ’0’, plural int(1) NOT NULL default ’0’, KEY lid (lid), KEY lang (locale), KEY plid (plid), KEY plural (plural) ) TYPE=MyISAM; -- -- Table structure for table ’menu’ -- CREATE TABLE prefix_menu ( mid int(10) unsigned NOT NULL default ’0’, pid int(10) unsigned NOT NULL default ’0’, path varchar(255) NOT NULL default ’’, title varchar(255) NOT NULL default ’’, description varchar(255) NOT NULL default ’’, weight tinyint(4) NOT NULL default ’0’, type int(2) unsigned NOT NULL default ’0’, PRIMARY KEY (mid) ) TYPE=MyISAM; --

42 6 Jun 2007 Drupal Handbook

-- Table structure for table ’moderation_filters’ -- CREATE TABLE prefix_moderation_filters ( fid int(10) unsigned NOT NULL auto_increment, filter varchar(255) NOT NULL default ’’, minimum smallint(6) NOT NULL default ’0’, PRIMARY KEY (fid) ) TYPE=MyISAM; -- -- Table structure for table ’moderation_roles’ -- CREATE TABLE prefix_moderation_roles ( rid int(10) unsigned NOT NULL default ’0’, mid int(10) unsigned NOT NULL default ’0’, value tinyint(4) NOT NULL default ’0’, KEY idx_rid (rid), KEY idx_mid (mid) ) TYPE=MyISAM; -- -- Table structure for table ’moderation_votes’ -- CREATE TABLE prefix_moderation_votes ( mid int(10) unsigned NOT NULL auto_increment, vote varchar(255) default NULL, weight tinyint(4) NOT NULL default ’0’, PRIMARY KEY (mid) ) TYPE=MyISAM; -- -- Table structure for table ’node’ -- CREATE TABLE prefix_node ( nid int(10) unsigned NOT NULL auto_increment, type varchar(16) NOT NULL default ’’, title varchar(128) NOT NULL default ’’, uid int(10) NOT NULL default ’0’, status int(4) NOT NULL default ’1’, created int(11) NOT NULL default ’0’, changed int(11) NOT NULL default ’0’, comment int(2) NOT NULL default ’0’, promote int(2) NOT NULL default ’0’, moderate int(2) NOT NULL default ’0’, teaser longtext NOT NULL, body longtext NOT NULL, revisions longtext NOT NULL, sticky int(2) NOT NULL default ’0’, format int(4) NOT NULL default ’0’, PRIMARY KEY (nid),

43 Drupal Handbook 6 Jun 2007

KEY node_type (type(4)), KEY node_title_type (title,type(4)), KEY status (status), KEY uid (uid), KEY node_moderate (moderate), KEY node_promote_status (promote, status), KEY node_created (created), KEY node_changed (changed), KEY node_status_type (status, type, nid) ) TYPE=MyISAM; -- -- Table structure for table ‘node_access‘ -- CREATE TABLE prefix_node_access ( nid int(10) unsigned NOT NULL default ’0’, gid int(10) unsigned NOT NULL default ’0’, realm varchar(255) NOT NULL default ’’, grant_view tinyint(1) unsigned NOT NULL default ’0’, grant_update tinyint(1) unsigned NOT NULL default ’0’, grant_delete tinyint(1) unsigned NOT NULL default ’0’, PRIMARY KEY (nid,gid,realm) ) TYPE=MyISAM; -- -- Table structure for table ’profile_fields’ -- CREATE TABLE prefix_profile_fields ( fid int(10) NOT NULL auto_increment, title varchar(255) default NULL, name varchar(128) default NULL, explanation TEXT default NULL, category varchar(255) default NULL, page varchar(255) default NULL, type varchar(128) default NULL, weight tinyint(1) DEFAULT ’0’ NOT NULL, required tinyint(1) DEFAULT ’0’ NOT NULL, register tinyint(1) DEFAULT ’0’ NOT NULL, visibility tinyint(1) DEFAULT ’0’ NOT NULL, options text, KEY category (category), UNIQUE KEY name (name), PRIMARY KEY (fid) ); -- -- Table structure for table ’profile_values’ -- CREATE TABLE prefix_profile_values ( fid int(10) unsigned default ’0’,

44 6 Jun 2007 Drupal Handbook

uid int(10) unsigned default ’0’, value text, KEY uid (uid), KEY fid (fid) ); -- -- Table structure for table ’url_alias’ -- CREATE TABLE prefix_url_alias ( pid int(10) unsigned NOT NULL auto_increment, src varchar(128) NOT NULL default ’’, dst varchar(128) NOT NULL default ’’, PRIMARY KEY (pid), UNIQUE KEY dst (dst) ) TYPE=MyISAM; -- -- Table structure for table ’permission’ -- CREATE TABLE prefix_permission ( rid int(10) unsigned NOT NULL default ’0’, perm longtext, tid int(10) unsigned NOT NULL default ’0’, KEY rid (rid) ) TYPE=MyISAM; -- -- Table structure for table ’poll’ -- CREATE TABLE prefix_poll ( nid int(10) unsigned NOT NULL default ’0’, runtime int(10) NOT NULL default ’0’, polled longtext NOT NULL, active int(2) unsigned NOT NULL default ’0’, PRIMARY KEY (nid) ) TYPE=MyISAM; -- -- Table structure for table ’poll_choices’ -- CREATE TABLE prefix_poll_choices ( chid int(10) unsigned NOT NULL auto_increment, nid int(10) unsigned NOT NULL default ’0’, chtext varchar(128) NOT NULL default ’’, chvotes int(6) NOT NULL default ’0’, chorder int(2) NOT NULL default ’0’, PRIMARY KEY (chid), KEY nid (nid) ) TYPE=MyISAM; --

45 Drupal Handbook 6 Jun 2007

-- Table structure for table ’queue’ -- CREATE TABLE prefix_queue ( nid int(10) unsigned NOT NULL, uid int(10) unsigned NOT NULL, vote int(3) NOT NULL default ’0’, PRIMARY KEY (nid, uid) ) TYPE=MyISAM; -- -- Table structure for table ’role’ -- CREATE TABLE prefix_role ( rid int(10) unsigned NOT NULL auto_increment, name varchar(32) NOT NULL default ’’, PRIMARY KEY (rid), UNIQUE KEY name (name) ) TYPE=MyISAM; -- -- Table structure for table ’search_index’ -- CREATE TABLE prefix_search_index ( word varchar(50) NOT NULL default ’’, sid int(10) unsigned NOT NULL default ’0’, type varchar(16) default NULL, fromsid int(10) unsigned NOT NULL default ’0’, fromtype varchar(16) default NULL, score int(10) unsigned default NULL, KEY sid (sid), KEY fromsid (fromsid), KEY word (word) ) TYPE=MyISAM; -- -- Table structure for table ’search_total’ -- CREATE TABLE prefix_search_total ( word varchar(50) NOT NULL default ’’, count int(10) unsigned default NULL, PRIMARY KEY word (word) ) TYPE=MyISAM; -- -- Table structure for table ’sessions’ -- CREATE TABLE prefix_sessions ( uid int(10) unsigned NOT NULL, sid varchar(32) NOT NULL default ’’, hostname varchar(128) NOT NULL default ’’, timestamp int(11) NOT NULL default ’0’,

46 6 Jun 2007 Drupal Handbook

session longtext, KEY uid (uid), PRIMARY KEY (sid), KEY timestamp (timestamp) ) TYPE=MyISAM; -- -- Table structure for table ’sequences’ -- CREATE TABLE prefix_sequences ( name varchar(255) NOT NULL default ’’, id int(10) unsigned NOT NULL default ’0’, PRIMARY KEY (name) ) TYPE=MyISAM; -- -- Table structure for table ’node_counter’ -- CREATE TABLE prefix_node_counter ( nid int(11) NOT NULL default ’0’, totalcount bigint(20) unsigned NOT NULL default ’0’, daycount mediumint(8) unsigned NOT NULL default ’0’, timestamp int(11) unsigned NOT NULL default ’0’, PRIMARY KEY (nid), KEY totalcount (totalcount), KEY daycount (daycount), KEY timestamp (timestamp) ) TYPE=MyISAM; -- -- Table structure for table ’system’ -- CREATE TABLE prefix_system ( filename varchar(255) NOT NULL default ’’, name varchar(255) NOT NULL default ’’, type varchar(255) NOT NULL default ’’, description varchar(255) NOT NULL default ’’, status int(2) NOT NULL default ’0’, throttle tinyint(1) DEFAULT ’0’ NOT NULL, bootstrap int(2) NOT NULL default ’0’, PRIMARY KEY (filename) ) TYPE=MyISAM; -- -- Table structure for table ’term_data’ -- CREATE TABLE prefix_term_data ( tid int(10) unsigned NOT NULL auto_increment, vid int(10) unsigned NOT NULL default ’0’, name varchar(255) NOT NULL default ’’, description longtext,

47 Drupal Handbook 6 Jun 2007

weight tinyint(4) NOT NULL default ’0’, PRIMARY KEY (tid), KEY vid (vid) ) TYPE=MyISAM; -- -- Table structure for table ’term_hierarchy’ -- CREATE TABLE prefix_term_hierarchy ( tid int(10) unsigned NOT NULL default ’0’, parent int(10) unsigned NOT NULL default ’0’, KEY tid (tid), KEY parent (parent) ) TYPE=MyISAM; -- -- Table structure for table ’term_node’ -- CREATE TABLE prefix_term_node ( nid int(10) unsigned NOT NULL default ’0’, tid int(10) unsigned NOT NULL default ’0’, KEY nid (nid), KEY tid (tid), PRIMARY KEY (tid,nid) ) TYPE=MyISAM; -- -- Table structure for table ’term_relation’ -- CREATE TABLE prefix_term_relation ( tid1 int(10) unsigned NOT NULL default ’0’, tid2 int(10) unsigned NOT NULL default ’0’, KEY tid1 (tid1), KEY tid2 (tid2) ) TYPE=MyISAM; -- -- Table structure for table ’term_synonym’ -- CREATE TABLE prefix_term_synonym ( tid int(10) unsigned NOT NULL default ’0’, name varchar(255) NOT NULL default ’’, KEY tid (tid), KEY name (name(3)) ) TYPE=MyISAM; -- -- Table structure for table ’users’ -- CREATE TABLE prefix_users ( uid int(10) unsigned NOT NULL default ’0’, name varchar(60) NOT NULL default ’’,

48 6 Jun 2007 Drupal Handbook

pass varchar(32) NOT NULL default ’’, mail varchar(64) default ’’, mode tinyint(1) NOT NULL default ’0’, sort tinyint(1) default ’0’, threshold tinyint(1) default ’0’, theme varchar(255) NOT NULL default ’’, signature varchar(255) NOT NULL default ’’, created int(11) NOT NULL default ’0’, changed int(11) NOT NULL default ’0’, status tinyint(4) NOT NULL default ’0’, timezone varchar(8) default NULL, language varchar(12) NOT NULL default ’’, picture varchar(255) NOT NULL DEFAULT ’’, init varchar(64) default ’’, data longtext, PRIMARY KEY (uid), UNIQUE KEY name (name), KEY changed (changed) ) TYPE=MyISAM; -- -- Table structure for table ’users_roles’ -- CREATE TABLE prefix_users_roles ( uid int(10) unsigned NOT NULL default ’0’, rid int(10) unsigned NOT NULL default ’0’, PRIMARY KEY (uid, rid) ) TYPE=MyISAM; -- -- Table structure for table ’variable’ -- CREATE TABLE prefix_variable ( name varchar(48) NOT NULL default ’’, value longtext NOT NULL, PRIMARY KEY (name) ) TYPE=MyISAM; -- -- Table structure for table ’vocabulary’ -- CREATE TABLE prefix_vocabulary ( vid int(10) unsigned NOT NULL auto_increment, name varchar(255) NOT NULL default ’’, description longtext, help varchar(255) NOT NULL default ’’, relations tinyint(3) unsigned NOT NULL default ’0’, hierarchy tinyint(3) unsigned NOT NULL default ’0’, multiple tinyint(3) unsigned NOT NULL default ’0’, required tinyint(3) unsigned NOT NULL default ’0’,

49 Drupal Handbook 6 Jun 2007

module varchar(255) NOT NULL default ’’, weight tinyint(4) NOT NULL default ’0’, PRIMARY KEY (vid) ) TYPE=MyISAM; -- -- Table structure for table ’vocabulary_node_types’ -- CREATE TABLE prefix_vocabulary_node_types ( vid int(10) unsigned NOT NULL DEFAULT ’0’, type varchar(16) NOT NULL DEFAULT ’’, PRIMARY KEY (vid, type) ) TYPE=MyISAM; -- -- Table structure for table ’watchdog’ -- CREATE TABLE prefix_watchdog ( wid int(5) NOT NULL auto_increment, uid int(10) NOT NULL default ’0’, type varchar(16) NOT NULL default ’’, message longtext NOT NULL, severity tinyint(3) unsigned NOT NULL default ’0’, link varchar(255) NOT NULL default ’’, location varchar(128) NOT NULL default ’’, hostname varchar(128) NOT NULL default ’’, timestamp int(11) NOT NULL default ’0’, PRIMARY KEY (wid) ) TYPE=MyISAM; -- -- Insert some default values -- INSERT INTO prefix_system VALUES (’modules/block.module’,’block’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES (’modules/comment.module’,’comment’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES (’modules/filter.module’,’filter’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES (’modules/help.module’,’help’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES (’modules/node.module’,’node’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES (’modules/page.module’,’page’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES (’modules/story.module’,’story’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES (’modules/system.module’,’system’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES

50 6 Jun 2007 Drupal Handbook

(’modules/taxonomy.module’,’taxonomy’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES (’modules/user.module’,’user’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES (’modules/watchdog.module’,’watchdog’,’module’,’’,1,0,0); INSERT INTO prefix_system VALUES (’themes/bluemarine/xtemplate.xtmpl’,’bluemarine’,’theme’,’themes/engines/xtemplate/xtemplate.engine’,1,0,0); INSERT INTO prefix_system VALUES (’themes/engines/xtemplate/xtemplate.engine’,’xtemplate’,’theme_engine’,’’,1,0,0); INSERT INTO prefix_users (uid, name, mail) VALUES (’0’, ’’, ’’); INSERT INTO prefix_users_roles (uid, rid) VALUES (0, 1); INSERT INTO prefix_role (rid, name) VALUES (1, ’anonymous user’); INSERT INTO prefix_permission VALUES (1,’access content’,0); INSERT INTO prefix_role (rid, name) VALUES (2, ’authenticated user’); INSERT INTO prefix_permission VALUES (2,’access comments, access content, post comments, post comments without approval’,0); REPLACE prefix_variable SET name=’update_start’, value=’s:10:"2005-03-21";’; REPLACE prefix_variable SET name=’theme_default’, value=’s:10:"bluemarine";’; REPLACE prefix_blocks SET module = ’user’, delta = ’0’, status = ’1’; REPLACE prefix_blocks SET module = ’user’, delta = ’1’, status = ’1’; INSERT INTO prefix_sequences (name, id) VALUES (’menu_mid’, 1); INSERT INTO prefix_node_access VALUES (0, 0, ’all’, 1, 0, 0); INSERT INTO prefix_filter_formats VALUES (1,’Filtered HTML’,’,1,2,’,1); INSERT INTO prefix_filter_formats VALUES (2,’PHP code’,’’,0); INSERT INTO prefix_filter_formats VALUES (3,’Full HTML’,’’,1); INSERT INTO prefix_filters VALUES (1,’filter’,0,0); INSERT INTO prefix_filters VALUES (1,’filter’,2,1); INSERT INTO prefix_filters VALUES (2,’filter’,1,0); INSERT INTO prefix_filters VALUES (3,’filter’,2,0); INSERT INTO prefix_variable (name,value) VALUES (’filter_html_1’,’i:1;’); INSERT INTO prefix_locales_meta (locale, name, enabled, isdefault) VALUES (’en’, ’English’, ’1’, ’1’);

Setup Drupal on Windows XP Pro using IIS

While trying to install Drupal on stand alone machine with Windows XP Pro & IIS I was unable to find all the installation information at one place therefore I am sharing my experiences and solutions to the problems. I think it will be useful for people who are new to Drupal because Drupal on stand alone machine reduces the learning curve.

Setup Drupal on Windows XP Pro using IIS: 1. Download Mysql server and install. (I have used ver. 5.0) 2. Download PHP and install. (I have used ver. 4) 3. Download Drupal (I have used ver. 4.7.3).

51 Drupal Handbook 6 Jun 2007

4. Create a folder with any name for example Drupal in Inetpub folder in C: drive. 5. Open IIS and create virtual folder giving alias and path of the Drupal folder which you have just created in Inetpub. 6. Untar (you can use Winrar for this) the downloaded drupal file contents in Drupal folder. 7. Create a schema/database with any name example drupaldata and create a user. 8. Now grant privileges to this user. Grant ALL ON databasename.* TO ’username’@’localhost’ IDENTIFIED BY ’password’; Flush privileges;

9. Modify the file C:\Inetpub\wwwroot\[YOURDIRNAME]\sites\default\settings.php by giving user name, password and database name.

10. Now browse this virtual folder with its alias name in IE example http://localhost/"aliasname"

11. If following error is displayed; Client does not support authentication protocol requested by server; consider upgrading MySQL client

Then use these commands; SET PASSWORD FOR ’some_user’@’some_host’ = OLD_PASSWORD(’newpwd’); Flush privileges;

12. Repeat step 10, I hope its working â¦.

Have a look at one of the pretty clean theme implementation in drupal - ENJOY . . .

Basic /sites directory setup

Version 5.x supports a new /sites/all directory. Best practice for basic initial setup is the following placements in the /sites directory:

Directory Contents /modules /drupal/sites/all /themes /drupal/sites/default settings.php /tmp /drupal/sites/example.com /files (but see below)

Understand the different common locations. The /sites/all and the /sites/default directories are exclusive, and are intended for the above items. The critical principle is to keep all your site customizations within the /sites directory so that it is easy to upgrade when a new minor version of the Drupal core code is released (e.g. to update from 5.1 to 5.2).

52 6 Jun 2007 Drupal Handbook

Contributed and custom modules should be placed in /drupal/sites/all/modules. Additional and custom themes should be placed in /drupal/sites/all/themes.

The /files directory is usually best placed in the /sites/example.com directory, which you will have to create. Then set the ’File system path’ at administer > site configuration > file system. This is ideal if a second site will likely need a separate /files directory; just create a second site-specific /files directory at /sites/example2.com/files. The same applies for the /tmp directory.

Upon initial installation the /files directory is set to /sites/default/files (you will need to create the actual directory). It can be fine to leave it there (or even to use /sites/files) if you are 100% you will never want to use multi-site features. However, this location shares the /files directory in a multi-site setup , which may or may not be desired. See "Setup of /sites directory for multi-site."

Backup is simplified by use of the /sites directory for all customizations. You can then easily backup all non-core material by backing up the /sites directory and the database.

For multi-site setup, see Multi-site installation and set-up, the sub-topic Setup of /sites directory for multi-site, and the installation instructions (INSTALL.txt). As stated above, there are two common locations in Drupal 5.x and above: /sites/default (for settings.php) and/sites/all (for common /modules and /themes). This allows a new site to be set up using the multi-site features by simply copying the /sites/default directory to /sites/example2.com

Version 4.6 and 4.7: To simplify backups and updates, the best practice (for a single-site install) is to place contributed modules in /sites/default/modules/, contributed or custom themes in /sites/default/themes/, and files in /sites/default/files (or even /sites/files). The /sites/all/ feature was added in Drupal 5.x. It will also work, but be more difficult to update your site, if contributed modules are placed in /drupal/modules, additional themes were placed in /drupal/themes, and files are stored in /drupal/files. If you expect to use multi-sites, then you should make use of /sites/example.com as explained in the "Setup of /sites directory for multi-site." Using /drupal/modules and /drupal/themes will also still work in 5.x, but the best practice above allows easier backup and expansion to multi-site.

Special cases

Various special situations (e.g., installing Drupal behind a firewall, installing Drupal in a subdirectory of the webserver’s document root) are discussed in this section. Information specific to particular operating systems or database platforms may be found elsewhere. Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support

This error occurrs on release 4.6.1 onwards.

Note: This issue is fixed by default on all VPS3 and new VPS2 servers, resolve-able on VPS1 and old VPS2 (with some updating).

53 Drupal Handbook 6 Jun 2007

This fix works for Verio VPS2 Servers which are installed with PCRE 6.4 by default (at this time). I see no reason why it should not work for all unix servers (perhaps with directory changes etc).

The fix is to uninstall pcre and install the correct version as follows: login as root Type: # pkg_info which will show you the installed packages. type: # pkg_delete pcre-6.4 (assuming you see pcre-6.4 as the installed version, change as required) change to the directory where your ports collection is. on FreeBSD it is: /ports/devel/pcre-utf8 so type into your shell prompt: # cd /ports/devel/pcre-utf8 # make # make install # make clean then restart the apache server... something like this (this is a VPS2 specific script, yours may be different): # restart_apache Configure .htaccess to allow awstats to work with clean URL’s

When I installed Drupal with clean url’s it made my Awstats (within the cgi-bin) not work and just return a Drupal page not found error.

Drupal is installed in the root directory (public_html) of my web space so is the cgi-bin folder that Awstats is in.

I fixed the problem by changing the protect files and adding 1 rewriteCond line to the .htaccess file as follows:

In the FilesMatch section, find " |code-style\.pl " without the quotes and remove it from the following code:

# Protect files and directories from prying eyes. Order deny,allow Deny from all

Now add this line (RewriteCond %{REQUEST_URI} "!cgi-bin/") to the following:

54 6 Jun 2007 Drupal Handbook

# Rewrite current-style URLs of the form ’index.php?q=x’.

RewriteCond %{REQUEST_URI} "!cgi-bin/" RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

This was all done on the default install of Drupal w/.htaccess. Configuring .htaccess to ignore specific subfolders Ignoring Subfolders that exist in the DocumentRoot

With clean URL’s enabled, when running other software applications in subfolders (subdirectories) of a Drupal root installation. your .htaccess file may rewrite those URL’s to Drupal. This may be a particular problem for those with a Drupal installation in the root of their domain using Cpanel and Fantastico where Fantastico installs other software into subfolders. For example, phpSurveyor’s admin interface as installed by Fantastico will not work with Drupal’s default .htaccess settings. The URL for the admin interface is inaccessible and will return a "page not found" page in your Drupal site.

The trick is to modify .htaccess to ignore specific files/folders. So for example, if you have two folders, and in the root of your Drupal installation, modify your .htaccess file by inserting the following code:

======[ start of .htaccess snippet]====== RewriteEngine on # # stuff to let through (ignore) RewriteCond %{REQUEST_URI} "/folder1/" [OR] RewriteCond %{REQUEST_URI} "/folder2/" RewriteRule (.*) $1 [L] # ======[ end ]======

For each folder you want to bypass, add a RewriteCond line, and end all but the final RewriteCond with [OR]. Note that the [L] in the rewrite rule tells it to stop there and bypass the rest of the rewrite rules.

Ignoring subfolders that are included via Apache Alias directives

As of 4.7, files and directories should be automatically allowed through in drupal’s .htaccess setup. Thats what the !-f and !-d lines do.

However if you are working with Apache Alias or similar directives the file doesn’t actually exist so drupal will take over like it should. The best way around it is to just add one more conditional that matches your location and make it skip it too. Thats what the ! means. Please see

55 Drupal Handbook 6 Jun 2007

below:

RewriteCond %{REQUEST_URI} !^/yourDirectoryName RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

It essentially means Apply this rule if the REQUEST_URI doesn’t start with /yourDirectoryName and the REQUEST_FILENAME isn’t a real file or a real folder. Which is exactly what you want. There is an implied "AND" between the lines of that rule. The ! says "not like this".

Special thanks to Mike Smullin for help on this fix. Create a custom php.ini

This article explains how to set up a custom php.ini that overides your servers default php.ini, providing an easier alternative (in the long run) than using .htaccess to overide php.ini settings. Itassumes that you have a ssh account set-up and are using a ssh client (e.g. putty - link to be added). You are also expected to logically replace directory structures given here, with your own, if they are different.

Procedure for allowing php.ini configuration for a website (shows changing file upload max)

1/ Create a cgi-bin Directory

First you’ll need a cgi-bin directory: mkdir ~/[your website directory]/cgi-bin/

This directory will be hosting your copy of php and your php.ini file.

2/ Create a script to retrieve the latest copy of php.cgi and php.ini

Make a file in ~/ called php-copy.sh containing the following, where 100M contains whatever file size limit you like, and [your website directory] is appropriately substituted.

For PHP4:

#!/bin/sh CGIFILE="$HOME/[your website directory]/cgi-bin/php.cgi" INIFILE="$HOME/[your website directory]/cgi-bin/php.ini" rsync -a /dh/cgi-system/php.cgi "$CGIFILE" # REMOVE THE FOLLOWING LINE TO CREATE THE UPDATE-ONLY SCRIPT: cp /etc/php/cgi/php.ini "$INIFILE" -p -i -e ’ s/.*post_max_size.*/post_max_size = 100M/; s/.*upload_max_filesize.*/upload_max_filesize = 100M/; ’ "$INIFILE"

56 6 Jun 2007 Drupal Handbook

For PHP5:

#!/bin/sh CGIFILE="$HOME/[your website directory]/cgi-bin/php.cgi" INIFILE="$HOME/[your website directory]/cgi-bin/php.ini" rsync -a /dh/cgi-system/php5.cgi "$CGIFILE" # REMOVE THE FOLLOWING LINE TO CREATE THE UPDATE-ONLY SCRIPT: cp /etc/php5/cgi/php.ini "$INIFILE" perl -p -i -e ’ s/.*post_max_size.*/post_max_size = 100M/; s/.*upload_max_filesize.*/upload_max_filesize = 100M/; ’ "$INIFILE"

A more general script with options (for references purposes only, do not do this):

#!/bin/sh test $# = 0 && exit 1 while test "$1";do case $1 in -php5) PHP=php5 ;; -sm) shift; SM=$1 ;; -rg) shift; RG=$1 ;; -pms) shift; PMS=$1 ;; -umfs) shift; UMFS=$1 ;; -mqg) shift; MQG=$1 ;; -met) shift; MET=$1 ;; -mit) shift; MIT=$1 ;; -ml) shift; ML=$1 ;; *) D=$1 ;; esac shift done test "$D" || exit 1 test -d "$HOME/$D" || exit 1 CGI="$HOME/$D/cgi-bin" mkdir -m0755 -p $CGI || exit 2 PHP=${PHP:-php} SM=${SM:-On} RG=${RG:-Off} PMS=${PMS:-8M} UMFS=${UMFS:-7M} MQG=${MQG:-Off} MET=${MET:-30} MIT=${MET:-60} ML=${ML:-8M} CGIFILE="$CGI/$PHP.cgi" INIFILE="$CGI/php.ini"

57 Drupal Handbook 6 Jun 2007

echo "CGI=$CGI MQG=${MQG} UMFS=${UMFS} PMS=${PMS} RG=${RG} SM=${SM} MET=${MET} MIT=${MIT} ML=${ML}" >&2 rsync -au /dh/cgi-system/$PHP.cgi "$CGIFILE" [ -s /etc/$PHP/cgi/php.ini ] && \ sed -e "s/^safe_mode[ ]*=.*/safe_mode = $SM/" \ -e "s/register_globals[ ]*=.*/register_globals = $RG/" \ -e "s/magic_quotes_gpc[ ]*=.*/magic_quotes_gpc = $MQG/" \ -e "s/.*post_max_size.*/post_max_size = $PMS/" \ -e "s/.*upload_max_filesize.*/upload_max_filesize = $UMFS/" \ -e "s/.*max_execution_time.*/max_execution_time = $MET/" \ -e "s/.*max_input_time.*/max_input_time = $MIT/" \ -e "s/.*memory_limit.*/memory_limit= $ML/" \ # REMOVE THE FOLLOWING LINE TO CREATE THE UPDATE-ONLY SCRIPT: /etc/$PHP/cgi/php.ini > "$INIFILE" chmod 0755 "$CGIFILE" chmod 0644 "$INIFILE" [ -s $CGI/.htaccess ] || echo "Options -Indexes" > $CGI/.htaccess touch $HOME/$D/.htaccess if grep -q ’^Options’ $HOME/$D/.htaccess; then grep -q ’+ExecCGI’ $HOME/$D/.htaccess || \ sed -i ’s/^Options\(.*\)/Options\1 +ExecCGI/’ $HOME/$D/.htaccess else echo "Options +ExecCGI" >> $HOME/$D/.htaccess fi grep -q ’^AddHandler[ ]\+php-cgi[ ]\+.php’ $HOME/$D/.htaccess || echo "AddHandler php-cgi .php" >> $HOME/$D/.htaccess if grep -q ’^Action[ ]\+php-cgi’ $HOME/$D/.htaccess; then sed -i "s@^Action[ ]\+php-cgi.*@Action php-cgi /cgi-bin/$PHP.cgi@" \ $HOME/$D/.htaccess else echo "Action php-cgi /cgi-bin/$PHP.cgi" >> $HOME/$D/.htaccess fi

3/ Prepare script for execution

Execute the following commands into the shell. This will give you permission to execute the php-copy.sh that we just created. chmod +x php-copy.sh

This calls our new to copy the php.cgi and php.ini files into our cgi-bin directory.

./php-copy.sh

If you get the error message: "bad interpreter: No such file or directory", there is probably an unseen problem with the formatting of the file.

58 6 Jun 2007 Drupal Handbook

Run the following command to convert it to proper Unix format before calling the script again: dos2unix php-copy.sh

4/ Test your new PHP setup

Open one of your existing PHP pages in your browser to ensure that your newly-installed local copy of PHP is functioning properly. If there is a problem, go back over the prior steps and use your debugging skills and your mastery of PHP, shell scripts and Linux to get your newly-copied PHP interpreter working! Once everything works properly, go on to the next step.

5/ Create a shell script to make a fresh copy of php (for future use) cp php-copy.sh php-update.sh

Open the newly-created php-update.sh script in your favorite text editor and find this line:

# REMOVE THE FOLLOWING LINE TO CREATE THE UPDATE-ONLY SCRIPT:

Delete that line as well as the line following it. Then save php-update.sh

If you got a "bad interpreter: No such file or directory" error message when you executed ./php-copy.sh previously, remember to convert the new file to unix format by running the following command: dos2unix php-update.sh

6/ Set up a cron task to keep php up to date

Type: crontab -e

And then enter the following in the text editor that shows up (replacing ’myusername’ with your specific username):

@weekly /home/myusername/php-update.sh

This will update the php binary and config file once a week.

7/ Configure your website to use new the php.ini that we just set up

Create the file ~/[your website directory]/.htaccess which contains the lines:

Options +ExecCGI AddHandler php-cgi .php Action php-cgi /cgi-bin/php.cgi

This is telling Apache (the webserver) to use the php.cgi and php.ini that php-update.sh copied into ~/[your website directory]/cgi-bin.

59 Drupal Handbook 6 Jun 2007

How to create a custom php.ini file when nothing else works

I recently needed to increase the memory_limit, upload_max_filesize and post_max_size values to something higher than the measly amount set by a particular webhost’s default php.ini file. This account was set up with cPanel and overriding the php.ini defaults the usual way (by adding various lines to the .htaccess or settings.php files) didn’t work at all. If you’ve had the same experience, you may find that this how-to works for you.

This how-to is for any version of Drupal running on Linux and Apache. No Drupal modules are needed, but the devel module certainly helps.

1. Get and modify your custom php.ini file

It’s best to use a php.ini file that somewhat resembles the one already running on your server. You can probably find one at /usr/local/lib/php.ini or /usr/local/Zend/etc/php.ini and just copy it into your account’s web folder (it may be called "public_html" or "www" or "htdocs" -- you know the one).

Edit your php.ini file and save your changes. There are handbook pages on increasing memory and upload size if you need help on the syntax.

2. Creating your CGI script

Now create a small script and put it in your cgi-bin directory. In your web folder, create another folder called "cgi-bin" if it’s not there already. Using your preferred text editor, create a file name "php.cgi" and put the following into it:

#!/bin/sh exec /usr/local/cpanel/cgi-sys/php5 -c /path/to/drupal/

If you don’t have cPanel on your account, try /etc/php5 instead. In any case, replace the /path/to/drupal/ part with the full path to your Drupal installation, such as /home/youraccount/public_html/ or /home/youraccount/public_html/drupal/

Since this is a script that needs to run as an executable file, use the chmod command and type this at the command line: chmod -x php.cgi

Don’t have shell access? That’s outside the scope of this how-to, but you can use an FTP program that can change permissions of files, ask your webhost to make the php.cgi script executable for you, or make it executable with some PHP code (perhaps with the devel module’s Execute PHP block).

60 6 Jun 2007 Drupal Handbook

3. Modifying your .htaccess file

Add this one line to your .htaccess file:

Action application/x-httpd-php5 /cgi-bin/php.cgi

This tells Apache to perform an action each time it encounters a file of file type "application/x-httpd-php5" -- if you’re using a version of PHP older than PHP5, you’ll need to change this to "application/x-httpd-php" (or upgrade to PHP5 -- ask your webhost).

Finally, scroll down to the part that says "# Protect files and directories from prying eyes" and add "ini|" to the directive so it looks something like:

Order allow,deny

Notice the "ini|" on the first line? This will prevent your custom php.ini file (and anything else ending in .ini) from being accessible to the entire world. (The character after the "ini" part is a pipe, by the way, not an L.)

4. Test your site

Load up your website and see if it works. If it does, good job! If it doesn’t, go back to step 2 or 3 and check to see what version of PHP your site is using. You can also ask your webhost for help.

If you increased your post_max_size or upload_max_size, then look at your admin/settings/uploads admin page and see how big your uploads can be. If you increased your memory_limit, check phpinfo or devel module’s phpinfo() page at admin/logs/status/php

Create Drupal database using Plesk

Create the database Login and select Services » Databases

This loads a page with an overview of databases. Depending on your host a database may already have been created. This is often the case with low-budget hosts, where you are limited to one database. In that case, use table prefixing. If no limits exists it is best to create a new database for Drupal via: Add New Database.

Click on the name of the database you wish to use. In the overview page you’ll see all users for this database. Again, depending on your host, you need to create a new user via: Add New Database User.

61 Drupal Handbook 6 Jun 2007

If you do not have the option to create new database users, use a pre-existing one.

Load the Drupal database scheme From the database users overview page click DB WebAdmin

The icon is a blue stack with a monkey wrench. Note that this opens phpmyadmin in a pop-up that may be blocked by your browser.

First make sure the relevant database is selected. If necessary, click Databases in the phpmyadmin start screen and then the database name.

Go to the SQL screen via a small button labelled SQL in the left pane of the phpmyadmin screen.

If you’ve created a new user for the Drupal database, you need to grant priviliges to the user: execute the SQL query:

GRANT ALL PRIVILEGES ON databasename.* TO username@localhost IDENTIFIED BY ’password’; where

’databasename’ is the name of your database ’username@localhost’ is the username of your MySQL account ’password’ is the password required for that username

This may not complete successfully; in that case you’ll have to assume / hope the user was created with the necessary privileges.

To create the database layout, select the tab import files. Upload the file database/database.mysql with the database scheme. Drupal with safe mode enabled and open basedir

This is still undergooing some changes as I’m doing more tests... But it works on a clean drupal 4.7.3 install...

I haven’t tested all modules yet, so please help me out...

Simply: use safe mode based on groups rather then owner and give access to my central code base for virtual hosts so that open base dir works...

You need to be logged in using ssh as root... And mind you my examples are from a plesk based system... With a central code base located in /var/www/apps/drupal and the virtual hosts directory in /var/www/vhosts/{domain}.{tld}/httpdocs/

1) create a group and a user called drupal... After -d you can put any home directory you like, but I choose the directory where my drupal code is installed... after the passwd you need to give a GOOD password for the user...

62 6 Jun 2007 Drupal Handbook

groupadd drupal useradd -d /var/www/apps/drupal -g drupal drupal passwd drupal

2) Change the owner and the group of the single code base... If you don’t have a single code base, only changing the group (chgrp) is enough chgrp drupal -R /var/www/apps/drupal chown drupal -R /var/www/apps/drupal

3) For the virtual hosts, change the group of the sites directory Also all directories under sites should be chmod to 2775: 2 puts all new subfiles created automatically into the group of the folder they are placed in (drupal in our case) + 7 for owner (root or drupal or ftpusername) + 7 for group (drupal) + 5 for guests If you have any more directories under sites, chmod them too chgrp drupal -R /var/www/vhosts/{domain}.{tld}/httpdocs/sites chmod 2775 /var/www/vhosts/{domain}.{tld}/httpdocs/sites chmod 2775 /var/www/vhosts/{domain}.{tld}/httpdocs/sites/default

4) Add the users to the group Plesk has a psaserv group don’t worry if you don’t have it... The drupal group needs the psaadm and psaftp only if you run plesk vi /etc/group psaserv:x:2523:apache,psaftp,psaadm,drupal drupal:x:10002:drupal,apache,psaftp,psaadm,{user_of_ftp_account_of_virtual_host} restart service apache

5) correct the tmp dir by creating a sub directory and putting the drupal group and user on it... mkdir /tmp/drupal chmod 2775 /tmp/drupal chgrp drupal /tmp/drupal ==> in admin change to /tmp/drupal

6) alter the code of file.inc so directories are made using 2775 rather then 775 find: @chmod($directory, 0775); replace: @chmod($directory, 02775); Actually my version of PHP has a bug and doesn’t put the 2!!! I have to remember to chmod myself then...

7) change your virtual host settings of httpd.conf In plesk this is done in: /var/www/vhosts/{domain}.{tld}/conf/vhost.conf Other systems might have another place for the conf which is the configuration for your httpd server.. With this code I have made sure that only the drupal directories benefit from group based safe

63 Drupal Handbook 6 Jun 2007

mode (safe_mode_gid)... all other directories still use the default safe mode Remove the second DirectoryMatch in case you want all files and folders to benefit from group based safe mode... As I have a central code base in /var/www/apps/drupal, I need to add this dir to the open basedir... and again only for the drupal directories off course...

# # allow all documents below this dir access to drupal core # php_admin_flag safe_mode on php_admin_flag safe_mode_gid on php_admin_value open_basedir "/var/www/apps/drupal:/var/www/vhosts/{domain}.{tld}/httpdocs:/tmp" php_admin_flag safe_mode on php_admin_flag safe_mode_gid on php_admin_value open_basedir "/var/www/apps/drupal:/var/www/vhosts/{domain}.{tld}/httpdocs:/tmp" # # now limit for all directories below root that are not includes or modules # users want other apps installed too... so no access to drupal # php_admin_flag safe_mode on php_admin_flag safe_mode_gid off php_admin_value open_basedir "/var/www/vhosts/{domain}.{tld}/httpdocs:/tmp" php_admin_flag safe_mode on php_admin_flag safe_mode_gid off php_admin_value open_basedir "/var/www/vhosts/{domain}.{tld}/httpdocs:/tmp"

64 6 Jun 2007 Drupal Handbook

Generic Mass SQL Import into Drupal # General Notes for Mass Import into Drupal # # The below is a template for an SQL import file to programmatically # add nodes into Drupal version 4.7.0. # # - Currently not tested on 4.7.3, but there does not seem to be any # radical changes in the Database structure that would break this. # # - You will probably need to create a separate program to parse # your existing content and create the needed looping structures # to properly create the SQL import file for you system. # # - You must follow SQL rules for data entry, see your SQL # documentation. Incorrect escaping will cause truncated fields. # # - Copyright ReasonToFreedom.com # - Personal use: Free of charge. # - Professional use: Only with USD $20 donated # to Drupal.org per domain you use it on.* # # - This header and all copyright notices must remain intact # upon any reprint/redistribution. # # - *Don’t stiff Drupal.org, if you’re using this professionally # on five domains, you can afford to send Drupal.org $100. # # ======Set Once Vars ======set @uid_value = 7; # Author ID (User ID) set @format = 3; # 1 => Filtered HTML | 2 => PHP code | 3 => Full HTML # ======End Set Once Vars ======# ======Set Per Node Vars ======/* set some variables to zero */ set @node_value = 0, @node_rev_vid_value = 0; # load these values as we execute. /* Set some default values */ set @title_value = ’The Title’; /* May also set entry_date_time like curr_date_time below */ set @entry_date_time = unix_timestamp(’2002-05-20 12:00:00’); # get specific date and time as number of seconds from 01/01/1970. set @url_dest = ’the_url.html’; set @teaser_value = ’

Teaser Para 1.

Teaser Para 2.

’; set @body_value = ’

Body Para 1.

Body Para 2.

65 Drupal Handbook 6 Jun 2007

Body Para 3.

Body Para, ad nauseam

’; set @curr_date_time = unix_timestamp(); # get current date and time as number of seconds from 01/01/1970. START TRANSACTION; /* Increment node_nid field in sequences. */ update sequences set id = id + 1 where name = ’node_nid’; /* Get new node_nid value from sequences for later */ select @node_value := max(id) from sequences where name = ’node_nid’; /* Increment node_revisions_vid field in sequences. */ update sequences set id = id + 1 where name = ’node_revisions_vid’; /* Get node_revisions_vid value from sequences for later */ select @revisions_value := max(id) from sequences where name = ’node_revisions_vid’; COMMIT; START TRANSACTION; Insert into node (nid, type, title, uid, status, created, changed, comment, promote, moderate, sticky, vid) VALUES (@node_value, ’story’, @title_value, @uid_value, 1, @entry_date_time, @curr_date_time, 2, 1, 0, 0, @revisions_value); Insert into node_comment_statistics (nid, last_comment_timestamp, last_comment_name, last_comment_uid, comment_count) VALUES (@node_value, @curr_date_time, NULL, @uid_value, 0); Insert into node_revisions (nid, vid, uid, title, body, teaser, timestamp, format, log) VALUES (@node_value, @revisions_value, @uid_value, @title_value, @body_value, @teaser_value, @curr_date_time, @format, ""); Insert into history (uid, nid, timestamp) VALUES (@uid_value, @node_value, @curr_date_time); Insert into node_counter (nid, totalcount, daycount, timestamp) VALUES (@node_value, 1, 1, @curr_date_time); COMMIT; set @url_src = concat( "node/", @node_value ) ; Insert into url_alias (src,dst) VALUES (@url_src, @url_dest);

66 6 Jun 2007 Drupal Handbook

# ======End Set Per Node Vars ======# ======Set multiple Terms per Node ======/* set term_value and insert as many times as you need */ set @term_value = 50; Insert into term_node (nid,tid) VALUES (@node_value, @term_value); set @term_value = 48; Insert into term_node (nid,tid) VALUES (@node_value, @term_value); # ======End Set multiple Terms per Node ======# EOF # How to degrade your Drupal db from MySQL 4.1.X/5.0.X to MySQL 4.0.X

I came across this issue when was developing a site for a client. I have MySQL 5.0.X at my localhost and staging host but client’s hosting still uses MySQL 4.0.X.

So here is the solution:

0. Always make backup first.

1. Drop tables "accesslog", "cache" and "watchdog"

(DROP TABLE accesslog, cache, watchdog;)

2. Recreate tables from Drupal mysql dump for v4.0

CREATE TABLE accesslog ( aid int(10) NOT NULL auto_increment, sid varchar(32) NOT NULL default ’’, title varchar(255) default NULL, path varchar(255) default NULL, url varchar(255) default NULL, hostname varchar(128) default NULL, uid int(10) unsigned default ’0’, timer int(10) unsigned NOT NULL default ’0’, timestamp int(11) unsigned NOT NULL default ’0’, KEY accesslog_timestamp (timestamp), PRIMARY KEY (aid) ); CREATE TABLE cache ( cid varchar(255) NOT NULL default ’’,

67 Drupal Handbook 6 Jun 2007

data longblob, expire int(11) NOT NULL default ’0’, created int(11) NOT NULL default ’0’, headers text, PRIMARY KEY (cid), INDEX expire (expire) ); CREATE TABLE watchdog ( wid int(5) NOT NULL auto_increment, uid int(10) NOT NULL default ’0’, type varchar(16) NOT NULL default ’’, message longtext NOT NULL, severity tinyint(3) unsigned NOT NULL default ’0’, link varchar(255) NOT NULL default ’’, location varchar(128) NOT NULL default ’’, referer varchar(128) NOT NULL default ’’, hostname varchar(128) NOT NULL default ’’, timestamp int(11) NOT NULL default ’0’, PRIMARY KEY (wid) ); 3. Make a dump for MySQL 4.0.X mysqldump -u root -p -h localhost --compatible=mysql40 mydatabase > mydatabase.sql

4. Upload this dump to your MySQL 4.0.X server.

5. Refresh your browser a couple of times. Enjoy! How-To: Virtual Hosting with Drupal Introduction

This book explaines how I’ve enabled Drupal hosting for my customers. I hope it is helpfull for other Drupal hosters...

Environment this is the environment used to setup my drupal hosting

linux RHEL 4 plesk 8.0.1 php 4.3.9 mysql 4.1.12 apache 2.0.52 drupal 4.7.x

68 6 Jun 2007 Drupal Handbook

Requirements

keep safe mode on at all times without the need for chmod 777 keep base dir restriction on at all times integrate into plesk so that backup, databases, quotas, etc keeps working drupal must run as managed application updates done once for all vhosts :: use single code base approved modules and themes available for vhosts to select from pre-activate drupal modules that enhance basic content management: SEO, security, ... eaccelerator must speed up php processing efficiently :: use single code base Each individual vhost should be able to use its own themes and modules should be accessible trough different URLs :: drupal multisite option should also be able to use other applications then drupal within the same site should experience drupal no different as if we would install drupal for each vhost seperatly Enhance security if needed on the drupal package Single code base should be included in the normal backup mechanism available in plesk

Next pages

As the book seems to order the sub pages by date, I list here the order of further reading:

1. Solution overview: http://drupal.org/node/90144 2. Prepare environment: http://drupal.org/node/90207

How-To: Virtual Hosting with Drupal :: Prepare environment Introduction

On this page I will explain some preparations of the environment like creating the drupal group, a tempory files location, application reference location, etc.

Please read previous pages:

Requirements: http://drupal.org/node/80472 Solution overview: http://drupal.org/node/90144

69 Drupal Handbook 6 Jun 2007

The drupal group

As we will enable the safe mode in group mode, we are in need of a system group. SSH into the server as SU (super user or root) add the group

$ groupadd drupal add the apache, psaftp and psaadm users to the group the group id (10002) could be different $ vi /etc/group drupal:x:10002:apache,psaftp,psaadm

The temp directory

Also within the temp directory we need a matching group because uploaded files are temporarly saved there and then copied to the final destination. Therefore we will create a seperate directory and chmod it so that each file created their automatically receives the drupal group. The latter is achieved by addin 2000 to the chmod command.

$ mkdir /tmp/drupal $ chmod 2775 /tmp/drupal $ chgrp drupal /tmp/drupal You will see an s appear instead of the x at the group part: drwxrwsr-x 2 root drupal 4096 Oct 16 15:09 drupal

The reference location

This is a directory where all symlinks are placed that point to the current version of an application. It is this location that all vhosts will reference so that they don’t depend on the current version. When switching versions, we only need to alter the symlinks at this location and all vhosts will be updated automatically. See further pages for more info. SSH into the server as SU (super user or root)

$ mkdir /var/www/apps

Navigation

As the book seems to order the sub pages by date, I list here the order of further reading:

Previous: Solution Overview: http://drupal.org/node/90144 Next: Single code base: Comming soon...

70 6 Jun 2007 Drupal Handbook

How-To: Virtual Hosting with Drupal :: Solution Overview Introduction

On this page I will explain in general what solutions are provided for the different requirements

Please read previous Requirements page: http://drupal.org/node/80472

Safe mode

Enabling Safe Mode imposes several restrictions on PHP scripts. These restrictions are mostly concerned with file access, access to environment variables and controlling the execution of external processes. There are problems which may be encountered when this mechanism is turned on, notably when attempting to work with files owned by different users and files which have been created at runtime by the script (which will be owned by the owner of the web server process).

In Plesk (and most other virtual hosts system) each vhost gets its own owner (FTP user) that is set when files are uploaded to the server. As we want a single code base located in a central place, the owner of the files within that central place will be different then the owner of the files in the vhost’s location.

In order to work around these issues, a relaxed form of the file permission checking is also provided by Safe Mode. Using the php.ini directive safe_mode_gid, it is possible to relax the user ID check to a group ID check. That is, if the script has the same group ID as the file on which a file operation was requested, the operation will succeed. If the script owners and the web server are members of the same group, and all hosted files are owned by this group, the file operations will succeed regardless of user ID.

Thus, we will create a group "drupal" that will cover all drupal related files accross vhosts and enable the safe_mode_gid. By doing so we will still have a more secure system then when we would disable the safe mode.

Information taken from here: http://www.acunetix.com/websitesecurity/php-security-5.htm

Open Basedir

Open Basedir limits the files that can be opened by PHP to the specified directory-tree, including the file itself. This directive is NOT affected by whether Safe Mode is turned On or Off.

When a script tries to open a file with, for example, fopen() or gzopen(), the location of the file is checked. When the file is outside the specified directory-tree, PHP will refuse to open it. All symbolic links are resolved, so it’s not possible to avoid this restriction with a symlink.

71 Drupal Handbook 6 Jun 2007

In Plesk (and most other virtual hosts system) each vhost gets its own open_basedir restriction that restruicts the opening of files to the httpdocs directory and the /tmp directory. As we want a single code base located in a central place, that location will not be accepted trough this restriction.

Thus, we will alter the open basedir restriction so that it includes the single code base location. But as we want other applications to be installed within the same vhost, we will add the location only for directories using drupal.

Plesk integration

The plesk control panel works great as long as you keep the directory structure and security as it is provided by plesk. Therefore we need to merge the single code base and each vhost within the provided structure.

The single code base will be installed as a normal vhost but limiting web access to the domain. As such a backup of the single code base can be sheduled and FTP can be enable to upload new modules and themes. Each vhost will have his own local "sites" directory and will create its database trough the plesk interface.

Managed application

As the single code base resides as a single vhost, we can upgrade the code, add modules and themes into one location. To make upgrading easier we need to make sure that each vhost that uses drupal, references one single point independend of the drupal version.

We will make subdirectories per drupal version in the single code base location and have one single reference that we can switch when going to a new version. Thus their will be a symbolic link called "drupal" pointing towards a drupal version "drupal-4.7.3" and each vhost that uses drupal will have symbolic links pointing towards the "drupal" symbolic link. When we change version, we only need to change the "drupal" symbolic link once and all vhosts will be adjusted accordingly. eAccelerator

The eAccelerator speeds up the execution of the php script by precompiling them and putting them into memory. The dissadvantage is that you need to have the memory and the more you have the more php files can be kept for fast execution. Therefore we need to limit the number of php files on the server.

By using the single code base, every vhosts uses the same files and thus memory usage can be limited and all php scripts run faster.

72 6 Jun 2007 Drupal Handbook

more on eAccelerator can be found here: http://eaccelerator.net

Each individual vhost requirements as noted above in the "Plesk Integration" part, each vhost gets his own "sites" directory that enables them to add their own modules and themes. Also as natavely available by drupal, the multisites mechanism will work for the same reason. Using symbolic links and this "sites" directory will give the user the feeling that it is a full drupal install on their system.

The local "sites" directory will allow the flexability required

Navigation

As the book seems to order the sub pages by date, I list here the order of further reading:

Previous: Requirements: http://drupal.org/node/80472 Next: Prepare environment: http://drupal.org/node/90207 HOWTO: copy a site to a local computer using XAMPP

Here are the steps you need to take to get a copy of a Drupal website onto your local computer for development purposes, using the XAMPP stack and a variety of tools. Many of the steps taken here have been made so that you can keep your PHP files outside the standard htdocs DocumentRoot directory of the Apache server while maintaining whatever else you have running on your XAMPP installation.

1) Install XAMPP software. This gets you Apache, MySQL and PHP all set up in a few clicks. Skip this step if you have them already set up (Drupal needs things like php and mod_rewrite in your Apache build.)

2) Download a copy of your production ’drupal’ database to your local MySQL server. If your production server has phpMyAdmin you can export your database using it and then import using your local phpMyAdmin. You may also use a program like Navicat MySQL since it handles UTF-8 data properly (unfortunately my favorite free MySQL client, SQLyog, seems to lack proper UTF-8 support).

3) Create a user on your local mysql database to match the remote connection settings and give them full permissions: % mysql> GRANT ALL PRIVILEGES ON drupal.* TO ’drupaluser’@’localhost’ IDENTIFIED BY ’drupalpassword’ WITH GRANT OPTION; FLUSH PRIVILEGES;

4) Get a copy of the production Drupal site files and folders (In my case, I use a source control system client like ) and copy them to a location you want to do your work in. An example: C:/p4/atlas-drupal/drupal. I will call this location %your_drupal_files% from here out.

73 Drupal Handbook 6 Jun 2007

5) Edit %your_drupal_files%/sites/default/settings.php and change the base URL to $base_url = ’http://localhost/drupal’; You should still be able to leave the $db_url connection setting alone.

6) Edit %your_xampp_location%\apache\conf\extra\httpd-xampp.conf and add the following lines according to where your copy of drupal lives on your computer:

Alias /drupal "%your_drupal_files%/" AllowOverride AuthConfig FileInfo Order allow,deny Allow from all You’ll need that "FileInfo" directive if you are getting 500 errors in your Apache error log like "RewriteEngine not allowed here". You could also add these lines in standard httpd.conf if you are not using XAMPP but just plain Apache.

7) (Skip this step if you are using regular Apache and not XAMPP) Edit %your_xampp_location%\apache\conf\httpd.conf and uncomment out the line LoadModule rewrite_module modules/mod_rewrite.so You need this so Drupal can have "clean links".

8) Edit %your_drupal_files%/.htaccess and change the RewriteBase to /drupal.

9) Restart the Apache service (with the XAMPP control panel if you are using XAMPP)

You now should be able to navigate to your sandbox development copy of the site via http://localhost/drupal

HOWTO: Copy site to another directory for testing

System: Apache + PHP + MySQL + Linux

I had my site at, say, example.com and wanted to set up beta.example.com as a duplicate site to test some ideas. This meant duplicating the database and code to a separate database and code tree. That way I could modify beta.example.com without harming example.com.

In my case I’m on a virtual-private-server (same thing as a dedicated server) and have full control over the system. If you’re on a shared hosting account the steps will be different. Unfortunately the details of how share hosting accounts are setup vary so widely, I’m not going to try and generalize the instructions for that.

1. In the DNS, create the beta.example.com subdomain. Remember it can take a little while for the DNS entries to propogate properly. 2. Duplicate the database tables ... I’m on Mac OS X and used the navicat program to do so, but you should be able to use mysqldump or other similar programs. That is, create a new database and copy the tables and data from the example.com database to the one for

74 6 Jun 2007 Drupal Handbook

beta.example.com. 3. Make a directory for the docroot of beta.example.com, and copy the files as so: (cd example.com/ROOT; tar cf - .) | (cd beta.example.com/ROOT; tar xvf -) If you only have FTP access this is a little harder. First FTP the files to your local computer, then FTP those files into the new docroot directory. You can also edit the files on your local computer, and then re-FTP them whenever you change something. 4. Config apache’s httpd.conf for a second VirtualHost with beta.example.com in it. Make sure the VirtualHost entry for beta.example.com preceeds the one for example.com. Make sure the docroot for beta.example.com is a different directory. 5. Edit sites/default/settings.php and change base_url and the database URL. $base_url = ’beta.example.com’; $db_url = ’mysql://username:password@localhost/new-database’; 6. It’s also helpful to override the site name so that the heading on the site glaringly reminds you that you’re on the BETA site: $conf = array(’site_name’ => ’BETA this sites name’); HOWTO: Install Drupal 5.x using cPanel

Many hosting providers use a control panel to shield users from the complexity of their servers. cPanel is one of those control panels. This small guide explains how to setup Drupal with CPanel.

Not everything in this guide may be applicable to your situation, because some hosting providers limit the options available to their users.

The basic assumptions: you have a domain name (http://www.example.com) and want to install Drupal at the document root, (usually public_html or htdocs), where it is reachable via the URL http://example.com or http://www.example.com. In order to accomplish this, the Drupal files such as .htaccess and index.php have to be placed into your server’s document root, along with the Drupal subdirectories such as includes, modules, themes, etc.

Note that other files present may be overwritten. Make backups before installing Drupal and remove files that may interfere with installation (e.g. index.php or .htaccess). If the pre-existing .htaccess file is necessary for other parts of your site, merge it with the one provided with Drupal.

If you have folders with names like admin/, image/, blog/, etc., these can conflict with Drupal and stop you from accessing areas of your Drupal site.

If your version of CPanel comes with Fantastico, you can use it to easily install Drupal. However, this installation does not come with update.php, a file necessary for updating your database when newer versions of modules are uploaded into your site.

Upload the Drupal files and folders

75 Drupal Handbook 6 Jun 2007

Download the newest version of Drupal.

Upload this to your hosting space using an FTP Program or CPanel’s built in File Manager.

Using the File Manager, extract the contents of the file: click on the file’s name and then select extract in the menu that pops up on the right.

This will extract the entire archive into a folder named drupal-x.x.x. You will then need to move the files out of this directory and into your document root directory (such as www or public_html).

You can also extract all the files and upload them this way; however, this takes much longer.

Create a database

1. Open cPanel 2. Go to MySQL Databases 3. Choose a databasename* for the new database and press "Add Database" 4. Choose a username* and password for the new database user and press "Add User" 5. Grant permissions to the user; select the username and database name, check ’ALL’ and press ’Grant permissions’

*Note: cPanel usually adds the cPanel username as a prefix to the newly created names.

Install Drupal

Drupal 5.x now comes with an automated installer. You no longer have to manually load the database tables -- Drupal does it for you.

Go to http://www.example.com/install.php

Here you will be asked for the database name, database user, and password.

If you need to use this database for more than one installation of Drupal (such as with hosting packages with a limited number of MySQL databases), you may want to click on the Advanced options and select a prefix for the tables you will be creating (such as "site_" or "main_"),

This will then install Drupal for you, creating and filling all needed tables in your database.

Once it is complete, you can go onto your site and set up the first user.

Setting up your first user account

The first user in your site (often referred to as user/1) is the "super user" on your site. It is automatically granted all admin and view permissions for your site. As such, it is important to immediately register on the site, which creates the first user.

76 6 Jun 2007 Drupal Handbook

After submitting your user name and e-mail, you’ll be given the option of changing the password for the account from the one the Drupal created for you.

Cron tasks

Many Drupal modules (such as the search functionality) have periodic tasks that must be triggered by a cron job. To activate these tasks, call the cron page by visiting http://www.example.com/cron.php -- this will pass control to the modules and the modules will decide if and what they must do. To call cron.php periodically you need to setup a cron job. cPanel offers a way to set cronjobs via Server » Cron jobs. Carefully read the instructions on the screen; they may differ from the following example.

To run cron.php every day set the Minute and Hour fields to 0 and the rest of the fields to *. The command to run is:

GET http://www.example.com/cron.php > /dev/null

Additional modules

Drupal comes with a limited number of modules. To expand the functionality of your Drupal site, you’ll need to download and add modules to your site.

View the listing of modules and download the ones you want to use.

Be careful to only download those that are for Drupal 5.x, as earlier modules will not work with your site.

Also, be sure to read the description, as some modules require additional modules to be installed in order for them to work. HOWTO: Install Drupal using cPanel

Many hosting providers use a control panel to shield users from the complexity of their servers. cPanel is one of those control panels. This small guide explains how to setup Drupal with CPanel.

Not everything in this guide may be applicable to your situation, because some hosting providers limit the options available to their users.

The basic assumptions: you have a domain name (http://www.example.com) and want to install Drupal at the document root, (usually public_html or htdocs), where it is reachable via the URL http://example.com or http://www.example.com. In order to accomplish this, the Drupal files such as .htaccess and index.php have to be placed into your server’s document root, along with the Drupal subdirectories such as includes, modules, themes, etc.

77 Drupal Handbook 6 Jun 2007

Note that other files present may be overwritten. Make backups before installing Drupal and remove files that may interfere with installation (e.g. index.php or .htaccess). If the pre-existing .htaccess file is necessary for other parts of your site, merge it with the one provided with Drupal.

Upload the Drupal files and folders

The first step is to download the drupal distritbution archive "drupal-x.x.x.tar.gz" onto your local computer, and then unpack it using a program such as 7zip, WinZip, WinRAR or tar.

The second step is to upload the drupal files to your server. There are three options for uploading the files, two that use cPanel’s built-in File Manager, and one that uses an FTP-client. The latter depends on FTP access provided by your host.

FTP (easiest) - After unpacking the drupal archive on your local computer, upload the files and folders in the resulting drupal-x.x.x directory to the document root of your webspace. cPanels built-in File Manager, option 1 - After unpacking the drupal archive on your local computer, recompress the files and folders in the resulting drupal-x.x.x directory into a file or into a new tar file. The result should be that the top-level directory "drupal-x.x.x" is no longer present in this archive. Upload this new archive to the document root on the server and extract its contents. The Drupal files and folders should now be located in the document root. cPanels built-in File Manager, option 2 - Upload the entire drupal distribution archive "drupal-x.x.x.tar.gz" to the document root of the server and extract its contents. Then use File Manager to move all the files and folders in the resulting drupal-x.x.x directory to the the server’s document root.

Because you need some files from the drupal archive in a later stage, it’s a good idea to decompress it locally anyway.

Create a database

This step may not be necessary; some hosting firms provide only one pre-made database.

Before you proceed you should know:

"username" - the username for connecting to the database "password" - the password for that username "databasename" - the name of the database

1. Open cPanel 2. Go to Server » MySQL Databases 3. Choose a databasename* for the new database and press "Add Database" 4. Choose a username* and password for the new database user and press "Add User" 5. Grant permissions to the user; select the username and database name, check ’ALL’ and press ’Grant permissions’

78 6 Jun 2007 Drupal Handbook

*Note: cPanel usually adds the cPanel username as a prefix to the newly created names.

Create database layout

1. Open phpmyadmin (Server » PhpMyadmin) 2. Select the newly created database 3. Depending on the phpmyadmin version select the tab SQL or import 4. Choose the file database/database.mysql and press ’Go’ 5. Alternatively copy-paste the contents of database/database.mysql in the query textfield and press ’Go’

Connecting Drupal The default configuration file can be found in sites/default/settings.php. Before you can run Drupal you have to set the database URL and the base URL to the website.

$db_url = ’mysql://username:password@localhost/databasename’;

Set the $base_url to match your websites URL:

$base_url = ’http://www.example.com’;

See INSTALL.txt for more information. Modify settings.php locally, then upload the modified file. Alternatively use cPanels text-editor to change the file on the server. Make sure to delete all trailing whitespace from settings.php when using the latter option or you will encounter the infamous ’headers already sent’ warnings.

Create the first account Point your webbrowser to your site (http://www.example.com/) and follow the instructions on the welcome screen.

Cron tasks Many Drupal modules (such as the search functionality) have periodic tasks that must be triggered by a cron job. To activate these tasks, call the cron page by visiting http://www.example.com/cron.php -- this will pass control to the modules and the modules will decide if and what they must do. To call cron.php periodically you need to setup a cron job. cPanel offers a way to set cronjobs via Server » Cron jobs. Carefully read the instructions on the screen; they may differ from the following example.

To run cron.php every day set the Minute and Hour fields to 0 and the rest of the fields to *. The command to run is:

GET http://www.example.com/cron.php > /dev/null

79 Drupal Handbook 6 Jun 2007

HOWTO: Site to site transfer with phpMyAdmin and a FTP Client

Preparation:

1) Turn OFF Clean URL’s function

FTP Steps: (for downloading and uploading Drupal program files) Going to assume you have one and know how to use an FTP Client. FileZilla is free and popular. This is pretty easy stuff and you probably already know most of it. If you don’t know it. DO ânotâ recommend transferring site, as first lesson with FTP’ing.

NOTE: Do not delete old site until you are 200% sure new site is ok.

1. Download all the Drupal program files from OLD site, to local Hard Drive, using FTP program. (Don’t worry about mySQL files yet) 2.

3. Be sure to get .htaccess too (it’s a Hidden File that can be found by checking the View Hidden Files Box on FTP Client. 4.

5. Edit settings.php and cron scripts to reflect new site. 6.

7. FTP files to new site phpMyAdmin Steps: (for mySQL export and import) We’re going to assume you know how to use phpMyAdmin for the basic stuff. This is pretty easy stuff and you probably already know most of it. If you don’t know it. I would ânotâ recommend transferring my site, as my first lesson with phpMyAdmin

NOTE: Do not delete old site until you are 200% sure new site is ok.

Export:

1. Find database in phpMyAdmin 2.

3. Click the Export Tab (we’re going to do a dump of data to local hard drive) 4.

5. In the âExportâ box â check âselect allâ and be sure the radio button is checked for SQL 6.

80 6 Jun 2007 Drupal Handbook

7. Check the âStructureâ and âDataâ boxes

8. (this ensures that both the structure of the database and the tables, and the content you have on site - is with you!)

Check âdrop tableâ (so that if the new site is installed already, you can install database on top of that. "drop table" simply ensures that if the table exists - it will be replaced by the one you backed up.)

Check âcomplete insertsâ ( to make sure it does not miss anything when rebuilding the site )

Check âSendâ box (this makes the data go to a file instead of the screen)

You can modify the File Name if you wish. (don’t recommend deleting anything that might be in the file name box already â just add something to it. I usually add MonthDay â Mar09)

You can check âcompressionâ if you so desire.

Click the âGOâ button and you will soon see a pop-up asking you where to save file.

Importing: (with phpMyAdmin)

1. Find NEW database with phpMyAdmin 2.

3. Click the tab SQL (just like when you are adding a module) 4.

5. Go to the âOr Location of the text file:â (just like you would for adding a module) 6.

7. âBrowseâ to local hard drive and find file. 8.

9. Click âGOâ

81 Drupal Handbook 6 Jun 2007

10.

11. It’s going to take a few minutes for everything to come over.

Final process:

1. Check new site and I do mean check everything, until you’re bored 2.

3. Since I usually do this stuff at night. I check everything that night and then I check once more in the morning. !Checking data is a lot faster than repairing or re-entering data :-) 4.

5. Turn Clean URL’s back on

Problems you might encounter

with phpMyAdmin

1. phpMyAdmin has some limitations on the size of file that can be transferred. My Host has it set to 10Mb, others might be lower or higher limits. If file is bigger than limits you have to make some choices. 2. You can save the file as âcompressedâ (but you might time out on the upload) 3. You can âEmptyâ (NOT DROP) a few of tables. Below are some the tables you might want to think about cleaning up before you make data dump. (Not in any order.) a. Aggregator Items (the data from news feeds) b. Accesslog c. Cache d. Watchdog e. Search_Index

with FTP (still working on this section)

NOTES:

1. If you run cron make sure to change this also in /scripts/cron-lynx.sh - so it points to cron at new site. Import a MySQL data dump with BigDump What is BigDump?

Importing large SQL dumps (when replicating or moving a database) can be difficult for those with only web access to the MySQL server. phpMyAdmin has certain shortcomings when importing files of more than a modest size. BigDump can be a helpful utility in such cases. From the BigDump website:

82 6 Jun 2007 Drupal Handbook

Staggered import of large and very large MySQL Dumps (like phpMyAdmin 2.x Dumps) even through the web-servers with hard runtime limit and those in safe mode. The script executes only a small part of the huge dump and restarts itself. The next session starts where the last was stopped.

Setting up BigDump

Download BigDump from http://www.ozerov.de/bigdump.php. Once downloaded you need to open the file bigdump.php in any simple text editor (or php editor) to modify the variables required for your server and database.

Commencing at line 78 with "// Database configuration" you need to setup the usual variables to connect to your database (same as are required for Drupal). There is one extra piece of information which the script needs to work well and that is the name of the sql file to be used to setup the database. Tip: Make sure you upload the file containing the SQL export of your database and bigdump.php to the same directory (root is best) on your webserver.

Save the file once you have set the above (best in the same folder as your sql file backup).

Uploading the sql file and bigdump.php to the webserver

Open your FTP program and open a new session connecting to your webserver root directory and the folder where the sql file and prepared bigdump.php reside on your computer.

Upload both files in ASC11 mode to the webserver root directory.

83 Drupal Handbook 6 Jun 2007

Running BigDump

Once the files are uploaded you simply need to connect to the bigdump.php script by using the URL http://www.your_domain.com/bigdump.php

If successfully connected bigdump will greet you with a screen like the below.

BigDump: Staggered MySQL Dump Importer ver. 0.21b Start Import from "the_file_you_wish_to_execute.sql" into "your_DB_name" at "localhost" © 2003-2005 Alexey Ozerov - BigDump Home

If it all looks good (ie: all the relavent names are correct) then click "Start Import" and the database will be setup by running in short automated stages to prevent server timeouts.

At the completion BigDump will notify you that it is finished.

That’s it! You have now copied, moved, migrated, synchronized or duplicated your mySQL database. Well Done!

Thanks go to markus_petrux for the original tip about BigDump Installing Drupal behind an Actiontec GT701-WG router

The popular Actiontec GT701-WG (and possibly other routers) DSL modem/router has a peculiar behavior that affects how base_url must be set up in sites/default/settings.php. The solution is to replace the PHP code that sets base_url with some code that is available below.

Here’s the scenario: you are using computer A to access and use your Drupal site, computer B is the server that is hosting the Drupal site, and both computers are plugged into a GT701 router, which in turn is linked to the Internet. Internet users can access your server from the outside by typing in www.example.com (because you set up port forwarding on the GT701). However, the GT701 will not allow you to type that address in from computer A, because the GT701 interprets such an action as a request to view the GT701’a administrative interface. Instead, you must type in the local network IP address (usually 192.168.0.xxx) of computer B to access and use your Drupal site.

However, this causes a problem because base_url is used by Drupal to create all the site’s links. If base_url is set for www.example.com, you will be unable to use the site from computer A (even if you type in the local IP). If base_url is set for the local network IP address, Internet users will not be able to use the site.

In other words, base_url has to be different for internal network users (computer A) and Internet users. To do this, replace the line $base_url = "http://www.example.com"; with the following PHP code:

84 6 Jun 2007 Drupal Handbook

Here, replace www.example.com with the actual URL and local network IP address with the proper IP address (something like 192.168.xxx.xxx). It is possible that your local network IP addresses do not begin with 192.168; in that case, you would need to change the code to look for the local IP range accordingly.

With this setup, you can access the Drupal site using computer A by typing in Computer B’s local IP address in your browser, while Internet users can continue to access it by typing in www.example.com Installing Drupal in a subdirectory in 4.6

If you install Drupal in a subdirectory, you need to alter the .htaccess file in Drupal’s root.

Change ErrorDocument to:

# Customized server error messages: ErrorDocument 404 /subdirectory/index.php

Change RewriteBase to:

# Modify the RewriteBase if you are using Drupal in a subdirectory and the # rewrite rules are not working properly: RewriteBase /subdirectory Remove any #’s in front of the RewriteBase line in case it’s commented out.

Make sure your $base_url in conf.php is set correctly as well. More than one Drupal site on one machine

There are several possible configurations for running multiple Drupal servers on the same hardware. You can separate them by directories or by vhosts, they can share configurations or split them or, in some cases, have a mixture, but all of these methods have at their heart the ./sites/domain_or_host_name/settings.php configuration file and the search-sequence where the Drupal program will search first for a configuration named for the current page and then to the current host before settling for the default.

85 Drupal Handbook 6 Jun 2007

General rules for multiple Drupal deployments

Each of the possible multi-drupal scenarios is discussed in more detail in the sections that follow, but the general form for the alternate configuration filename is:

./sites/vhost.uri/settings.php

Note how the path separator (’/’) must be changed to a dot. As an example, the vhost drupal.mysite.net may have one primary drupal server at the DOCUMENT_ROOT location, but a second site may begin at DOCUMENT_ROOT/altserver. For this case, the configuration file would be ./sites/drupal.mysite.net.altserver/settings.php

Within that configuration file, the most common and minimal option is to set the $db_url that specifies the host, database and login for the Drupal tables, as well as the $base_url. But you can also include assignments to override anything in the VARIABLES table. This allows you to redefine the theme, the site footer and contact email, blocks per-page limits, even the name you use for anonymous.

Drupal IDs: When using multiple drupal servers on the same hardware, each new configuration will result in a new host component for the username@host Drupal login ID (used when logging into a foreign Drupal server). For example, if you have a directory partitioned host at drupal.mysite.net/altserver your usename to login to some other Drupal server would be [email protected]/altserver.

Prefixing Database Tables to put them in One Database If you only have one database then it is necessary to use database table prefixing. See this handbook page for details on how to achieve that. Moving your Drupal installation to a new directory

If for instance you need to move your installation from www.mysite.com/development/ to the root directory of www.mysite.com, just follow these simple steps:

Copy Files

Copy the files of your Drupal installation from the old directory to your new directory. Make sure you include .htaccess.

Change Path

In your new directory, open the file (4.5 or earlier) includes/conf.php or (4.6) sites/default/settings.php

Look for a line that begins with "$base_url = ", update this so that $base_url equals the path to your new directory. Save the file and close it.

86 6 Jun 2007 Drupal Handbook

You might need to modify the .htaccess file as well.

Update Cron

If you set up Cron on your old installation, make sure you update it to point to your new installation.

Delete Old Directory

Test that everything is working in your new installation. If so, it is now safe to delete the files in your old Drupal directory. PCRE_UTF8 solution for VPS servers | FreeBSD installation PROBLEMS? - PCRE_UTF8 support on VPS server accounts? Look here! I receive the same error on every page with a basic install however everything seems to be functioning otherwise fine. warning: preg_match(): Compilation failed: this version of PCRE is not compiled with PCRE_UTF8 support at offset 0 in /home/brandform/www/drupal.brandform.net/includes/unicode.inc on line 32.

The solution was much more difficult to find than i had hoped so maybe this post will be useful to some others as well. I had to uninstall the pcre package and reinstall the proper one with utf-8. heres the procedure: login to server via shell, on VPS2 accounts, # su root then type password basically you want to be root user. then type: # pkg_info which will show you the installed packages. type: # pkg_delete pcre-6.4 for me it was 6.4 but yours may be different. make sure to enter the proper version of pcre displayed in pkg_info. then you want to change to the directory where your ports collection is. on FreeBSD it is: /ports/devel/pcre-utf8 so type into your shell prompt:

# cd / # cd ports/devel/pcre-utf8 # make

87 Drupal Handbook 6 Jun 2007

# make install # make clean then youll want to restart the apache server... something like this: # restart_apache thats it... fixed everything for me. after over a day of pulling my hair out and almost abandoning the effort......

Known causes of PCRE server errors

In the event that you see the following error: warning: preg_match: internal pcre_fullinfo() error -3 in /SERVER_PATH/includes/common.inc on line 592.

Be aware that this issue exists at the server level, outside of Drupal code. Put plainly, the error means that the server’s PCRE (Perl Compatible ) library is not configured correctly.

This error may be caused any time a Drupal module calls a PCRE function. Typically, the error appears within common.inc, but this is not always the case.

Depending on the server environment, there are several different causes (including a reported bug in some versions of PHP 5).

This manual page is designed to capture known instances of this bug,

Known Causes

An upgrade of RedHat included a bad library and required a patch. (Details to follow)

Recommendations

Send the content of the error to your system admin and have them debug your PHP’s PCRE module. Redirecting specific pages to new URLs (301 redirects in Drupal)

If you are porting over an existing website to Drupal, one consideration is how you redirect the old page URLs to the appropriate pages on the Drupal version of the site. If you don’t want to create custom rewrite paths within Drupal for those nodes -- or perhaps cannot due to clean URLs or filename suffixes -- then 301 redirects are considered the best way to handle redirected pages, for they inform search engines to update their databases with the new paths. This way, you should not risk your search engine pagerank or lose site visitors with 404 "not found" errors.

88 6 Jun 2007 Drupal Handbook

However, 301 redirects cannot be done using the common approach. Yet establishing 301 redirects is quite easy, provided you have mod_rewrite enabled in your .htaccess file.

How to create 301 redirects in Drupal Apache mod_rewrite

Edit your .htaccess file in a text editor. [Note: Be sure to save the file in "UTF-8" format.]

In the file, you will find the commands:

# Various rewrite rules. RewriteEngine on # Modify the RewriteBase if you are using Drupal in a subdirectory and # the rewrite rules are not working properly. #RewriteBase /drupal RewriteBase /

Immediately after that code -- and before the Drupal-provided "Rewrite old-style URLs" commands -- add your rewrite rules using the following format:

#custom redirects RewriteRule ^old/URL/path$ http://yourdomain.com/new/path [R=301,L] #end custom redirects

Note the convention: The old path is simply the path off the root. The new path is the full path, including the domain. The [R=301,L] code is the 301 redirect instruction. (axbom notes: "The 301 tells browsers and spiders it is a permanent redirect, and the L ensures that no other rewrites are processed on the URL before it reaches Drupal; Hence place this code above Drupal ’s own URL rewrite, but below the command RewriteEngine on.")

If you have more paths to add, insert the rewrite commands as their own line as above.

For more information, see the forum thread at http://drupal.org/node/16084 [from where I drew this information] The tolerant base URL

Note: 4.7 already has this feature built in

Instead of using a hard coded domain as your $base_url in the settings.php file, you might want to use

89 Drupal Handbook 6 Jun 2007

$base_url .= "/$dir"; } ?>

This has the advantage that whatever domain the user used to get to the site, he will maintain throughout his session.

Warning

Email notifcations may be issued under the domain which is used by the poster. If you access your site using http://localhost, you could send emails with that invalid URL. The only module which behaves this way today that I know of is subscription.module from Contrib. Using .htaccess to stop page caching

If your Drupal site is being accessed on a LAN with a proxy server to cache pages, you may find that user identities become confused. A user may login under their username, but when they access another page, the proxy server sends the cached page of another user, effectively switching the identities of the user as far as Drupal is concerned.

Proxy servers can be instructed to stop caching pages for a Drupal site using HTML Meta Tags and/or HTTP Headers. While using meta tags may be more convenient (one need only modify the theme header), some proxy servers only respond to instructions embedeed in the HTTP headers sent by the webserver. Apache webservers can use mod_expires to send this instruction. Assuming that mod_expires is enabled on your web server, try adding the following lines to your .htaccess file to stop the proxy server from caching Drupal pages:

ExpiresActive on ExpiresDefault "access plus 0 seconds"

Linux specific guidelines Installing PHP, MySQL and Apache under Linux

Installing MySQL shouldn’t be too much of a burden, when using a Linux distribution that can handle RPMs. All you have to do is grab the RPMs from the MySQL website. Please do note that you’ll also need the MySQL client RPM, not only the MySQL server one. Once MySQL has been installed, download Apache and PHP, and unpack them in the same directory. To install Apache together with PHP and MySQL, follow the "quick install"-instructions in the INSTALL-file located in your PHP directory. When configuring PHP do not forget to replace ’apache_1.3.x’ with your version of Apache.

After the compilation process you have to set the DocumentRoot in Apache’s httpd.conf to the path of your drupal-directory. Make sure your Apache is setup to allow .htaccess files so drupal can override Apache options from within the drupal directories. Therefore, set AllowOverride to "All" instead of "None". Somewhat down httpd.conf they ask you to set Directory to whatever

90 6 Jun 2007 Drupal Handbook

you set DocumentRoot to. The last thing to do is to add index.php in IfModule mod_dir.c behind DirectoryIndex. Apache will then look for index.php in the DocumentRoot and will display it as its main page. XAMPP for Linux Packages

The distribution for Linux systems (tested for SuSE, RedHat, Mandrake and Debian) contains: Apache, MySQL, PHP & PEAR, Perl,ProFTPD, phpMyAdmin, OpenSSL, GD, Freetype2, libjpeg, libpng, gdbm, zlib, expat, Sablotron, libxml, Ming, Webalizer, pdf class, ncurses, mod_perl, FreeTDS, gettext, mcrypt, mhash, eAccelerator, SQLite and IMAP C-Client.

Installing XAMPP in Debian Download XAMPP Latest version from the following link http://sourceforge.net/project/showfiles.php?group_id=61776&package_id=6...

At the time of writing this article XAMPP version is 1.5.3a

#wget http://kent.dl.sourceforge.net/sourceforge/xampp/xampp-linux-1.5.3a.tar....

Now you should be having xampp-linux-1.5.3a.tar.gz file in your downloaded location

Go to a Linux shell and login as root:

$su -

Extract the downloaded archive file to /opt

#tar xvfz xampp-linux-1.5.3a.tar.gz -C /opt

XAMPP is now installed below the /opt/lampp directory.

Start XAMPP Server

To start XAMPP simply call this command:

#/opt/lampp/lampp start Starting XAMPP for Linux 1.5.3a... XAMPP: Starting Apache with SSL (and PHP5)... XAMPP: Starting MySQL... XAMPP: Starting ProFTPD... XAMPP for Linux started.

Test Your XAMPP Installation

91 Drupal Handbook 6 Jun 2007

OK, that was easy but how can you check that everything really works? Just type in the following URL at your favourite web browser: http://localhost

XAMPP Security Configuration

As mentioned before, XAMPP is not meant for production use but only for developers in a development environment. The way XAMPP is configured is to be open as possible and allowing the developer anything he/she wants. For development environments this is great but in a production environment it could be fatal.

Here a list of missing security in XAMPP:

The MySQL administrator (root) has no password.

The MySQL daemon is accessible via network.

ProFTPD uses the password "lampp" for user "nobody".

PhpMyAdmin is accessible via network.

Examples are accessible via network.

MySQL and Apache running under the same user (nobody).

To fix most of the security weaknesses simply call the following command:

#/opt/lampp/lampp security

It starts a small security check and makes your XAMPP installation more secure.

Start And Stop Server Services start

Starts XAMPP. stop

Stops XAMPP. restart

Stops and starts XAMPP. startapache

92 6 Jun 2007 Drupal Handbook

Starts only the Apache. startssl

Starts the Apache SSL support. This command activates the SSL support permanently, e.g. if you restarts XAMPP in the future SSL will stay activated. startmysql

Starts only the MySQL database. startftp

Starts the ProFTPD server. Via FTP you can upload files for your web server (user "nobody", password "lampp"). This command activates the ProFTPD permanently, e.g. if you restarts XAMPP in the future FTP will stay activated. stopapache

Stops the Apache. stopssl

Stops the Apache SSL support. This command deactivates the SSL support permanently, e.g. if you restarts XAMPP in the future SSL will stay deactivated. stopmysql

Stops the MySQL database. stopftp

Stops the ProFTPD server. This command deactivates the ProFTPD permanently, e.g. if you restarts XAMPP in the future FTP will stay deactivated. security

Starts a small security check programm.

For example: To start Apache with SSL support simply type in the following command (as root):

#/opt/lampp/lampp startssl

You can also access your Apache server via SSL under https://localhost.

Important Configuration Files And Directories opt/lampp/bin/ - The XAMPP commands home. /opt/lampp/bin/mysql calls for example the MySQL monitor.

93 Drupal Handbook 6 Jun 2007

/opt/lampp/htdocs/ - The Apache DocumentRoot directory.

/opt/lampp/etc/httpd.conf - The Apache configuration file.

/opt/lampp/etc/my.cnf - The MySQL configuration file.

/opt/lampp/etc/php.ini - The PHP configuration file.

/opt/lampp/etc/proftpd.conf - The ProFTPD configuration file. (since 0.9.5)

/opt/lampp/phpmyadmin/config.inc.php - The phpMyAdmin configuration file.

If you want to confiure apache2 you have to use /opt/lampp/etc/httpd.conf(If you want to change Apache DocumentRoot directory you can chage in this file).If you want to configure namebased and ip based virtual hosts check here

If you want to configure proftpd check here

If you want to configure mysql check here

Stopping XAMPP

To stop XAMPP simply call this command:

#/opt/lampp/lampp stop

You should now see:

Stopping LAMPP 1.5.3a... LAMPP: Stopping Apache... LAMPP: Stopping MySQL... LAMPP: Stopping ProFTPD... LAMPP stopped.

And XAMPP for Linux is stopped.

Uninstall XAMPP From your Machine

To uninstall XAMPP just type in this command

#rm -rf /opt/lampp

Windows-specific guidelines

Several packages exist which install Apache, PHP, and MySQL in one easy download. These include the following:

94 6 Jun 2007 Drupal Handbook

ApacheFriends XAMPP Miniserver Foxserv PHPHome

If you want to install them separately, see the guidelines below. How to install Drupal for newbies using FTP and phpMyAdmin

There are three things to do: upload the database, get drupal ready and change "/tmp" on your drupal site.

Change "/tmp" on your drupal site.

1. Open a browser and go to your new drupal site, whatever its domain is. 2. Create a new user account. You enter a username and password and now you are the admin for your new site. Important: the first user you create has access to every administration setting on your Drupal site. 3. On the left side of your screen, there is a link, "administer." Click "administer," then "settings." 4. Scroll down to "File system settings" and in the "Temporary directory" field you will see "/tmp." Remove the "/" from in front of "tmp." So now in "Temporary directory" the field should only contain "tmp." Click "Save configuration," at the bottom of the screen.

Get Drupal ready

1. Download Drupal 2. Extract Drupal to your desktop (or wherever you like on your computer). You need to have a program like 7-zip or Winzip installed first. You will have to extract the files twice. 3. Edit conf.php. It’s in the drupal-4.5.2/includes directory after you extract the files. You have to edit two lines in this file. 4. To edit the file, you may need to load your text editor (Windows comes with Notepad and Wordpad, either of which will do fine) first then find the file by clicking the File menu, then Open. 5. Change: $db_url = "mysql://user:password@localhost/drupal"; You must replace "user" and "password" with your username and password for your phpMyAdmin login and "drupal" with your database’s name. 6. Change: $base_url = "http://www.example.com"; You must replace "example.com" with your domain name. 7. Put drupal on your server. You need an FTP program like FileZilla. Open your FTP program and navigate to the directory where your index.htm file would normally go. This is usually called public_html/ or www/ This is where you put the drupal files. The drupal files that go there are the contents of drupal-4.5.2, that you extracted. You don’t put the folder itself on the server, just the contents. That

95 Drupal Handbook 6 Jun 2007

means you are uploading six folders (database, includes, etc.) and ten files (.htaaccess, cron.php, etc.). 8. Create a new directory on your server. In your FTP program, right click on the server side, select "create directory" and name the new directory "files." You want "files" in the main directory. After you create it, you should see it in between "database" and "includes." 9. Now you open up your new directory, "files," and create a new directory inside called, "tmp." 10. Change the file attributes of both "files" and "tmp" by right clicking on them one at a time, selecting "file attributes" and entering "755" in the "numeric value" field (if you see errors on your drupal site later saying "files" and "tmp" are not writeable you have to change the file attributes to "777," which is less secure).

Upload the database

1. Login to your phpMyAdmin (on your server). 2. Click "Create new database." 3. - name it "drupal" (or whatever you like). 4. You should see "drupal" at the top of the left column. Click "drupal." 5. In the center column you should see some tabs to choose from. Click "SQL." 6. At the bottom of the box that comes up it says, "Location of the textfile:" and there’s a button that says, "Browse". Click "Browse" and navigate to the file "database.mysql." Its on your computer inside the folder you extracted, "drupal.4.5.2," inside the "database" folder. Select "database.mysql" and click "open." HOWTO: Create an apache sandbox using Windows and Apache2Triad

One of the most useful and productive techniques for working with Drupal is to install it on your own computer. Having Drupal installed on your local computer allows you to rapidly prototype Drupal sites using any combination of contributed modules and themes, dry-run upgrade installations of Drupal without interrupting production sites, and perform any other Drupal task much more quickly by allowing you to work locally instead of remotely. This tutorial addresses a simple method of setting up a web server on your own computer that functions identically to many commercial web hosting services, however it is not intended as a tutorial for turning your computer into a web server or using it to host a site. This tutorial focuses on installing the web server software as a means of working on a copy or prototype Drupal site, i.e. the result is not part of the internet, and can’t be accessed from the internet. The advantage is that the software runs much faster on your own computer.

While Drupal will work with Microsoft’s Internet Information Services (IIS), this tutorial will focus on a specific package, apache2triad, available for download from sourceforge.net. Though all that is needed to run Drupal is a web browser, apache, PHP4 (4.3.3) or higher and mySQL, apache2triad comes with a variety of other features that will not be covered in this tutorial.

96 6 Jun 2007 Drupal Handbook

Best of all, however, apache2triad requires no additional configuration in order to set up and install Drupal, making it an ideal choice for novice web site creators wishing to learn to set up and use a Drupal site with only very modest skills and almost no previous experience.

Tools needed to complete this tutorial: A web browser. An archive program capable of extracting .tar and .gz files, such as 7-Zip. An FTP client like coreFTP (optional).

Before you begin

Apache2Triad comes in three different configurations; a legacy version for Windows 9x systems, and PHP4 and PHP5 versions for Windows XP. If you intend to work on a copy of Drupal that you plan to transfer to a production server provided by your web hosting service, you may wish to find out which versions of PHP and MySQL are installed. If your web hosting service is currently providing PHP/MySQL 4.x, you may wish to download the corresponding version of Apache2Triad, in order to avoid compatibility issues. If so, you may also wish to inquire your hosts’ timetable for upgrading PHP and MySQL since 4.x versions are no longer supported by their respective development teams.

As of this writing, the following versions of Apache2Triad were available for download from Sourceforge:

Edge (Apache2.2 PHP5 MySQL5) v1.5.4 95.8MB space required 348.7MB Stable (Apache2.0 PHP4 MySQL4) v1.4.4 75.3MB (somewhere between "edge" and "legacy") Legacy for Win9X (limited Apache2.0 PHP4 MySQL4) v1.2.3 48.0MB space required 200.3MB

While each version of Apache2Triad shown has been tested with various versions of Drupal in recent years, this tutorial focuses on using the "edge" version as installed under Windows XP.

Installing Apache2Triad

1) Download the version of Apache2Triad that best suits your needs. 2) Double-click the icon from the file you downloaded. This opens a small configuration window to begin the Apache2Triad installation. Leave the default settings as they are and click the button labeled "next". 3) The next dialog window allows you to set the destination folder, which for most people will be "C:\apache2triad", but it works equally well installed wherever you like (provided there is room available, see space requirements above). It is recommended that Apache2Triad be installed at the "root level" of the drive chosen, for example, "C:\apache2triad" as opposed to "C:\Program Files\apache2triad\", as this will save you typing later on. 4) The next dialog asks you to set a password of no less than eight characters. It will be important to know this password as you will need it later on. Select an eight character password (ideally one easily remembered), write it down, then click the button labeled "next", then the button labeled "I Agree" on the following dialog to complete the license agreement and begin the installation. 5) After the files have been installed to the directory of your choice, a dialog will open that alerts you that post configuration is needed. Click the button labeled "OK" to continue. Several

97 Drupal Handbook 6 Jun 2007

windows will open and close as the installer automatically configures most options for you, eventually stopping at a CMD window asking you to type your password from step 4. Do so now and press the "enter" key; post-configuration will complete itself, and at last open a window requesting that you reboot, which is necessary to start apache, php and mysql as Windows services.

Note that depending on how Windows is configured for your computer, you may notice that there is now a "user" account named apache2triad; ignore this and log on with your regular account.

Installing Drupal

1) Obtain a copy of Drupal 4.6x, 4.7.x or 5.0 (cvs) from drupal.org as well as any contributed modules or themes you wish to use. 2) Use your archive program to extract any files from step 1; note that because the files are stored in both .gz and .tar formats, it may be necessary to extract them twice. You may wish to create a directory named DrupalX, where ’X’ is the version of Drupal, and unarchive your files to this location in order to stay organized; by copying the files you wish to use instead of using the originals, it is safe to move the archived versions to the recycle bin if you like. 3) Browse to the location you installed Apache2Triad and open it’s folder, then look for the folder labeled "htdocs". This folder is where you will place your Drupal files in order to access them through apache and your web browser. You may wish to place a shortcut to htdocs on your desktop, or create a shortcut in a toolbar with bookmarks and other shortcuts to tools. See the Support and Help Center under the Start Menu for details about how to accomplish these tasks. 4) For purposes of this tutorial, Drupal was extracted to drupal-4.7.3 and drupal-cvs in order to illustrate their installation. Note that the installation procedure for Drupal 4.6.9 is identical to the one for Drupal 4.7.3. Note that in doing so, Drupal is being installed to a sub directory and follows installation procedure accordingly. If Drupal were to be installed at the "document root" level of the server, the files inside the drupal-x folder extracted themselves would be place in the htdocs folder inside the Apache2Triad installation. In this tutorial, the whole folder is placed in htdocs (for simpler organization) and this affects how Drupal will be configured in later steps.

Note that you may also use the folder name of your choice, such as the sub directory used on your web hosting server, "sandbox" or anything else that makes sense for your project.

Copy the folder you have created (or the files inside it to htdocs, if you want to install to the "document root") now.

5) Open your favorite web browser, select the text in the address bar and type: http://localhost/phpmyadmin/

This will load the PHPMyAdmin logon page, which will ask for a username and password; the username is "root" and the password is whatever you selected when Apache2Triad was installed. Enter these now. 6) This will load the PHPMyAdmin main page. At this stage of this tutorial, it is useful to provide a brief introduction to PHPMyAdmin, which is also discussed in the Drupal handbook

98 6 Jun 2007 Drupal Handbook

section How to install Drupal for newbies using FTP and phpMyAdmin. For intents and purposes, PHPMyAdmin is a tool used to create, backup and restore MySQL databases. Although it has considerably more sophisticated features, this tutorial focuses only on those needed to complete a given task. 7) Select a database name and type it into the text field labeled "create database", then click the button labeled "create". The next steps vary depending on whether 5.0 or 4.7.x or earlier is being installed. If you are installing 5.0 from scratch, you may skip the next step. For purposes of this tutorial, databases named drupal-4.7.3 and drupal-cvs were created (if creating multiple databases, click the ’home’ button to the left of the PHPMyAdmin page to return to the database creation page). Minimize your browser (we’ll come back to it, later) before moving on to the next step. 8) Open your htdocs folder and look for the folder labeled "sites" if you installed Drupal to your document root, or inside the Drupal folder you created earlier, if you are installing Drupal 4.7.x or earlier. Here it is necessary to open the settings.php file and specify the installation options described in the INSTALL.TXT file that came with Drupal. Note that if you require multiple Drupal installations to use the same copy of Drupal, you should modify the settings.php file according to your configuration requirements. For single-version Drupal sites, the settings.php file you’ll want to use is in the folder labeled "default". Right-click the settings.php file with your mouse, select "open with" from the context menu, and select "notepad" from the application list.

Depending on how you have Drupal configured, your settings.php file entries will vary, however the entry: $db_url = ’mysql://root:password@localhost/drupal-4.7.3’ will use "root" in place of the username and the password you selected when installing Apache2Triad. Don’t forget to set the entry for $base_url if you did not install Drupal to document root to the folder name you installed Drupal to. For example: $base_url = ’http://localhost/drupal-4.7.3’; // NO trailing slash!

IMPORTANT "localhost" must be substituted for "www.example.com" in order to work on your local machine.

For those working on copies of Drupal that will be hosted on production servers, it is handy to keep two copies of your settings.php entries, one for local use and one for remote use. This way, you can switch between configurations just by commenting or uncommenting the appropriate lines, for example:

# Remote setting: # $base_url = ’http://www.example.com/drupal-4.7.3’; // NO trailing slash! # Local setting: $base_url = ’http://localhost/drupal-4.7.3’; // NO trailing slash!

Once your settings.php file’s entries are correct, restore your browser window and locate the PHPMyAdmin page tab labeled "import" and click the button labeled "browse". For Drupal 4.7.x and earlier, the database that will be imported will be in the database folder, which will be in htdocs under the Apache2Triad installation you created earlier. Browse to that folder and select the appropriate sql file: database.mysql for Drupal 4.6.x, database.4.0.mysql for Drupal 4.7.x and

99 Drupal Handbook 6 Jun 2007

MySQL4 (Apache2Triad "stable" installation), and database.4.1.mysql for PHP5. Note that it is a good practice not to mix MySQL 4 and MySQL 5 databases in order to avoid potential compatibility conflicts. Click the "Go" button on the MySQL database to import the database you’ve selected. 9) The next step will depend on where you installed Drupal in your htdocs folder. Select the text of your address bar in your web browser and type: http://localhost/drupal-cvs/ substituting "drupal-cvs" for the folder name you used in htdocs or omitting it if you installed to document root.

If you are installing Drupal 5.x, this will open the Database configuration page for your new site, which will prompt you for a database name (the one you created with PHPMyAdmin earlier), a username (root) and a password (the one you created when you installed Apache2Triad). Enter these now: if your Drupal installation uses a database prefix, select the advanced option and enter the prefix at this time. Select the appropriate radio button, depending on if you are installing the MySQL or PGSQL version of the database (most likely MySQL). Click the "save configuration" button and your installation is complete. You will be taken to the welcome screen where you will create the first user logon for your new site.

Drupal 4.7.x users will be taken directly to the welcome page to create the first user logon directly.

Importing and exporting Drupal databases updated with PHPMyAdmin

There are certain circumstances when you may wish to work on a site that is a copy of one running on a production server, backup the database, and perform other tasks specific to making changes to your databases. This section of the tutorial focuses on using PHPMyAdmin to do so. If PHPMyAdmin is not available on your hosting provider’s server for you to use, you may be able to install it yourself if it is unavailable; check with your hosting service to find out what your options are if you are unsure.

Because any possible task is going to entail some permutation of exporting, copying and/or importing databases from one a remote server to your personal computer, this section of our tutorial focuses on two basic operations within PHPMyAdmin that have tabs labeled accordingly; "import" and "export".

To export a database with PHPMyAdmin

1) Using your web browser, browse to the PHPMyAdmin location of the server where the database you wish to export resides. For example: http://www.example.com/phpmyadmin/ for a remote database and http://localhost/phpmyadmin/ for a database hosted on your Apache2Triad installation. Select the name of the database you wish to export from the combo box on the left side of the page and you will be taken to that database’s main operations page. Next, click the tab labeled "Export" and you will be taken to the Export database page. 2) Fill out the sections of the form located on the Export database page as follows:

100 6 Jun 2007 Drupal Handbook

a) Click the link marked "select all" in the group labeled "Export" to select all of the tables in the database for export. The radio button selected below should be "SQL". b) Select the check box labeled "add DROP TABLE" in the group labeled "Structure". The check boxes labeled "Add AUTO_INCREMENT value" and "Enclose table and field names with backquotes" should be selected as well as the checkbox next to "Structure", leave them as they are if already selected or set if needed.

IMPORTANT Selecting "add DROP TABLE" means that if the copy of the database created is later imported to another Drupal installation, the tables in the imported copy will overwrite them if they exist in the target database. You should be careful to keep track of your databases, and make sure you only import and export the correct databases for your task. c) Under the group labeled "Data" select the check box marked "Complete inserts". The checkbox labeled "Use hexadecimal for binary fields" may be selected (select it if not) and the combo box labeled "Export type:" should be set to "INSERT" (select if needed). d) Put a check in the box in the "Save as file" group, then type a name for the database and click the button labeled "Go". Note if a radio button other than "None" is enabled in the group "compression". Uncompressed databases may be larger, but are sometimes easier to work with. e) Select a location to save your database to (preferably something easy to remember, like the database folder of your Drupal installation in htdocs, for example).

To import a database with PHPMyAdmin

1) Using your web browser, browse to the PHPMyAdmin location of the server where the database you wish to import resides. For example: http://www.example.com/phpmyadmin/ for a remote database and http://localhost/phpmyadmin/ for a database hosted on your Apache2Triad installation. Here you will either need to select an existing database name in the combo box on the left side of the PHPMyAdmin page, or create a new one. Note that if you are setting up a database on a remotely hosted site, your host may have prohibitions on the creation of MySQL databases that require they be created outside of PHPMyAdmin by means of a control panel or other mechanism; check with your web hosting service for specific details of their requirements. 2) One you have selected or created the appropriate database name, select the tab labeled "Import" on the PHPMyAdmin page to be taken to the import page. 3) Find the control group in the Import page form labeled "Location of the text file" and click the button labeled "Browse", following the resulting dialogs to select the database file of your choice.

IMPORTANT If you are importing a database that you exported using the instructions in this tutorial, remember, the tables of the imported database will overwrite any that exist in the database you are importing to, overwriting them. Therefore it is important to double-check that the database you are selecting and the target you are importing to are correct before proceeding. If uncertain, you should back up the target database before importing a new one into it.

101 Drupal Handbook 6 Jun 2007

4) Click the button labeled "Go" to import your new database.

Using bigdump.php to deal with large databases

While bigdump.php is not included with Apache2Triad, it is a useful tool that greatly simplified working with large databases and Drupal. Used correctly, it can greatly speed importing large databases under Apache2Triad, and will also assist in importing large databases hosted on remote servers where restrictions are placed on the size of databases that may be imported. This is done by breaking up one big import operation into several small ones, reducing load on the computer and avoiding import file size limitations.

1) Download a copy of bigdump.php, unzip the file, and open the file "bigdump.php" by right clicking it with your mouse, selecting "Open with" from the context menu and then "Notepad" from the list of applications. 2) Find the following section of the file:

// Database configuration

$db_server = ’localhost’; $db_name = ’drupal’; $db_username = ’root’; $db_password = ’password’;

The entries should be as shown above, substituting the correct values depending on where the database that is to be imported is located. Close this file and save a copy of it to your desktop or somewhere it will be easily remembered. 3) If you are using bigdump to import a database into your Apache2Triad installation, you should place a copy of the file you just edited in your htdocs folder along with a copy of the database you intend to support. If you are importing the database to a remotely hosted Drupal installation, you will need to transfer copies of the database and the bigdump.php file you edited to your server. 4) Open your web browser, select the text in the address bar, and type: http://localhost/path-to-my-drupal-folder/bigdump.php if you are importing to Apache2Triad and http://www.example.com/path-to-my-drupal-folder/bigdump.php 5) Bigdump.php should run unattended after it has run, and will inform you of it’s success when the database has been completely installed. 6) If you are importing to a remote database, you should delete the bigdump.php file for security purposes with your ftp program or other utility as suggested in the bigdump.php documentation, and you may wish to remove the old database at this time as well, to free up server space. Installing Apache (with PHP) on Windows

As of this writing, the current version of Apache is 2.2.4 and PHP is 5.2.2.

102 6 Jun 2007 Drupal Handbook

1. Download the Apache Windows MSI Installer from Apache.org 2. Download the PHP Windows Zip Package from PHP.net.

The first step to getting Drupal running on your Windows machine is to set up the Apache web server by running the Apache MSI installer. The following steps will walk you through the installation:

1. Select Next 2. Select "I accept the terms in the license agreement" 3. Select Next 4. Fill in your server information if it is known. A typical setup will use the "for All Users, on Port 80, as a Service" option. If this is being setup as a test machine, you may use localhost as the Network Domain and the Server Name. Select Next. 5. Select the Typical Setup 6. Choose a Destination Folder for the Installer to place the program files into. Note: the default Apache Installer location is C:\Program Files\Apache Software Foundation\Apache2.2. Because of the spaces in the directory name, using this folder may cause cgi and php scripts to not find the paths correctly. 7. Select Finish 8. If a Firewall is enabled, make sure that port 80 is unblocked and open. 9. To test if the Apache server is running, open up http:\\localhost in a browser. A plain black and white page should come up that reads "It Works!"

Configuring Apache:

1. Using a text editor such as Notepad, open the httpd.conf file. This file is found in the /conf sub-directory under the directory that was set up during installation. Alternatively, a shortcut may be found in the start menu under the Apache HTTP Server folder. 2. Note: Windows based systems uses backslashes \ and Unix based systems use slashes / for paths. In the Apache configuration files, slashes / should be used in path names. 3. Change the DocumentRoot to point to the location of the root document folder. In the default httpd.conf file, this is found on line 149 and if the defaults were used during the installation, it would point to "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs". Note: Wrapping the path name in quotes will escape out any spaces that are used. 4. Change the Directory path to match the one used in the previous step. This is found on line 177 of the default httpd.conf file. 5. Add to index.php to the DirectoryIndex. This is found on line 212 of the default httpd.conf file. 6. Append the following lines to the end of the httpd.conf file: LoadModule php5_module "c:/php/php5apache2_2.dll" AddType application/x-httpd-php .php PHPIniDir "C:/php" 7. Save and Close

103 Drupal Handbook 6 Jun 2007

Installing PHP:

1. Unzip the PHP files to C:\php 2. Copy c:\php\php-ini-recommended.ini and rename itc:\php\php.ini 3. Uncomment the Windows include_path on line 506 Note: In the PHP.ini file, semicolons are used to denote that something is commented out. To uncomment a line, simply remove the semicolon. 4. Update the doc_rootto match the one that was set up in the httpd.conf file on line 513. Note: The PHP INI files uses the Windows style backslash \ for path names. 5. Update the extension_diron line 520 to "C:\php\ext" 6. Uncomment php_gd2.dll extension on line 637. 7. Uncomment mysql.dll extension on line 651. 8. Update the sessions.save_pathto the Windows temporary files directory (i.e. C:\Temp). 9. The PHP directory needs to be added to the Path Environment Variables 1. Open the Control Panel 2. Open System > Advanced > Environment Variables 3. Append ;C:\php to the end of the Path System Variables list and Click OK. 10. Restart Apache 11. To test PHP on Apache, go to the root directory (i.e. C:\Program Files\Apache Software Foundation\Apache2.2#92;htdocs) and create a new php file in it. In this file, use PHP’s phpinfo() function to see the server’s configuration information. For example: Open this file in a browser (i.e. http:\\localhost\filename.htm).

Alternative Options: Bundled Packages

Apache2Triad Apache Friends - XAMPP Installing MySQL on Windows

1. After downloading the latest stable release version of MySQL, locate the setup.exe, and execute it. When prompted choose custom install. 2. Choose a path to install it. I recommend keeping to the default, which is c:\mysql. 3. Select all components, and continue until done. 4. Go to the MySQL folder, and start winmysqladmin.exe 5. Choose a username and password for yourself. 6. In the console, click on the my.ini tab, and choose "create shortcut in startmenu" option. 7. In the my.ini tab, also chck that all the configurable options are correct in accordance to your computer. 8. Close the admin console and restart it. If admin program runs with a green light, everything fine.

104 6 Jun 2007 Drupal Handbook

Installing PHP4 on Windows

After obtaining the latest stable release of PHP, extract the archive to c:\php or something similar. Copy php.ini-optimized to php.ini

Make the following modifications: Change include_path to ’’.’’ Change sendmail_from to ’’[email protected]’’ Change SMTP to ’your.smtp.mail.service’ If you don’t know your smtp server, use the same configuration as your email client uses. Change session.save_path to a temporary folder (’’drive:pathtotemp’’) and make sure the temporary folder exists. Change doc_root to your preferred work folder (’’drive:pathtofiles’’). Make sure it exists and is the same folder your specified in the Apache setup procedure. Set register_globals to equal "On" Save the changes, and copy the php.ini file to your Windows directory. Create a basic php file, for example test.php which contains the following:

and save it in your work folder.

Open your web browser, and type in: http://localhost/test.php. If you get the PHP information page, then everything is set up correctly. If not, just go over the settings again for PHP to make sure everything is ok.

Drupal 4.7 on Windows/IIS Requires PHP in ISAPI mode

When installing Drupal version 4.7 and later on Windows servers running IIS rather than Apache, PHP must be run in ISAPI rather than CGI mode.

A relatively obscure bug in IIS discards PHP session information when the PHP script that sets the session also redirects to another page. In Drupal 4.7 and later, the user login screen automatically redirects to the home page on a successful login. The IIS bug is triggered, preventing the new session data from being sent to the user’s browser, and making it impossible for users to log in.

As the bug only affects IIS when PHP is running in CGI mode, switching to ISAPI mode will solve the problem. Installing PostgreSQL on Windows

Postgres is easily installed and administered on Windows. See PostgreSQL on Windows for the options you have.

105 Drupal Handbook 6 Jun 2007

As of this writing, the apparently easiest choice for PostgreSQL on Windows is "UltraSQL by PeerDirect" mentioned at above link. It is available from here. See the README file enclosed in the download and Installing the PeerDirect PostgreSQL beta for Windows for more instructions. After completing installation, the username for your DB is your windows login name and there is no password. You might want to install phpPgSQL in order to admin your database. It will save you frustation at the command line. A more complete list of all known PostgreSQL GUI tools is available at PostgreSQL GUI’s Go ahead and create your database tables via phpPgSQL or via the command line as described here. Multiple Drupal Sites under Windows

One troublesome area in Drupal-on-Apache/Windows is multiple Drupal sites. Nowhere is this documented as being possible to do using a single code base. The weakness is in the fact Drupal uses symbolic links to point to the directory where Drupal’s code resides. In Linux, this is easy by creating a symbolic link to Drupal’s root directory:

\Drupal\Site1 -> \Drupal \Drupal\Site2 -> \Drupal In Windows, this isn’t that easy. Shortcuts in Windows are not usable except when browsing the file system. What not many people know, is that Windows DOES support symbolic links. What Windows doesn’t have is a built in capability to build symbolic links. That’s where a 3rd party utility is required. I use Junction by Sysinternals. Using the tool is similar to the ln command in Linux. c:\> junction.exe c:\drupal\Site c:\drupal Will make a link to c:\drupal from c:\drupal\site

Using this, AND the directions located elsewhere on this site regarding the strutcure of the drupal\sites directories, you can make an attempt at getting multiple drupal sites running under Windows. Running multiple sites on a local PC (localhost) from a single codebase, using Windows

Here’s how to get mutltiple sites working on localhost using Windows XP. This should work with Drupal 4.6.x and assumes that you have PHP, Apache, MySQL, phpMyAdmin and Drupal all installed and working.

There are four stages to go through, but it’s not difficult:

1. Set up your databases, one for each website 2. Set up each website in Drupal 3. Edit the virtual host settings in Apache 4. Update the Windows hosts file

106 6 Jun 2007 Drupal Handbook

In the following example we will add a local site"http://testsite1" in addition to the default site. We’ll assume Drupal is installed in c:/www (and that your web root is set to c:/www in the apache confic file).

Databases ======

Firstly we will set up a new database for ’testsite1’

1. Open your phpMyAdmin page

2. Type a name for your database in the ’create database’ textbox (’testsite1’ is as good as anything) then click the create button. You should get a message to say your database is created.

3. Next we need to add the necessary tables. Click the ’sql’ tab, then use the browse option to navigate to the ’includes’ folder of your Drupal installation, e.g. c:/www/drupal-4.6.3/includes. Select the file ’database.mysql.inc’ then ’go’.

4. phpMyAdmin will run the script and install the necessary tables.

Drupal ======

1. Make a copy of the folder /sites/default and call it /sites/testsite1. i.e. you should now have two folders in your sites folder, default and testsite1.

2. Open file sites/testsite1/settings.php using notepad. Edit the $db_url line to match the database defined in the previous steps:

$db_url = "mysql://username:password@localhost/database"; where ’username’, ’password’, ’localhost’ and ’database’ are the username, password, host and database name for your set up.

3. Set $base_url to match the address to your Drupal site:

$base_url = "http://testsite1";

4. Save the file.

Apache ======

1. Open the apache config file ’http.conf’ (it’s in the apache/conf folder in Apache 1. I think it has moved somewhere else in Apache2)

2. Scroll to the end of the file, where you will find the virtual hosting setup. Assuming your websites are all located in the folder c:/www then add the following lines (edit the paths as necessary)

107 Drupal Handbook 6 Jun 2007

NameVirtualHost 127.0.0.1:80 DocumentRoot "C:/www/" ServerName localhost DocumentRoot "C:/www/Drupal-4.6.3" ServerName testsite1

There are lots of other things you can add into your VHost settings - see the Apache documentation.

Windows ======

We now need to tell Windows that the domain ’testsite1’ is hosted locally, i.e. not to look on the Internet for it. Open the ’hosts’ file with notepad. It can usually be found in c:/windows/system32/drivers/etc

Edit the end of the file to read:

127.0.0.1 localhost 127.0.0.1 testsite1

Save the file.

Apache, again ======

OK, that’s (almost) it. All that is left is to restart the Apache webserver. You could reboot your computer but a better way is to open a command prompt window (a DOS window as we used to call it) and type ’net stop apache’. When the service has stopped, restart it using ’net start apache’

Now when you open your favourite browser and enter ’http://testsite1’ you should see your shiny new Drupal site, just waiting to be customised.

You can add as many sites as you need by following the process above. Untar

When you download Drupal packages you will need to decompress the files. Drupal packages are double compressed ’tar’ and ’gz’. To untar packages in Windows several programs are recommended.

108 6 Jun 2007 Drupal Handbook

7zip Winzip Winrar Winace Installing Drupal on Windows

[this page used to contain verbose windows installation guidelines. they got removed because they were a) just a copy of the general installation guidelines, b) misleading ("start by extracting the archive to the PHP working folder"), and c) we don’t want to maintain redundant documentation. this page should only contain windows specific guidelines that differ significantly from the general guidelines. preferably, latter would be put so generally that we don’t need anything here (eg. don’t rely on "wget" and "tar" etc.)]

PostgreSQL specific guidelines

1. Create a PostgreSQL database for your site. createdb -U username -W dbnamewhere username is the owner of the database (this user must have permission to create databases) and dbname is the name of your database. You will be prompted for that user’s password. On success, the following is displayed: CREATE DATABASE . The user must also have the correct PSQL Grant privileges to use the database correctly. 2. Once you have a proper database, dump the required tables into your database: psql -U username -W dbname < database/database.pgsqlYou will be prompted for your database password. You should see a progress report as the tables are created. All has gone well if there are no lines marked "Error:" printed to the screen. 3. Set the database options in includes/conf.php so Drupal can access the database you have created. Edit the following line in includes/conf.php: $db_url = "pgsql://username:password@hostname/dbname";

ERROR: DB connect failed

You may need to update pg_hba.conf file, to support access for loopback connections: host drupal drupal 127.0.0.1 255.255.255.255 password

When getting this type of error, it may help to look into apache error log. Postgresql 7.3.4 does not enable tcp/ip sockets per default, so you have to either enable it by uncommenting: tcpip_socket = true port = 5432

109 Drupal Handbook 6 Jun 2007

in postgresql.conf, which may not be a good solution for security concerned people, or enable unix domain sockets:

$db_url = "pgsql://admin:password@unix(/tmp)/drupal"

/tmp works on a slackware 9.0 Linux 2.4.21, no commas needed. ERROR: language "plpgsql" does not exist

If you get an error about plpgsql being an invalid language, you just need to install by running the following at the command line: createlang plpgsql drupal

(substitute your database name for "drupal")

Then go back and rerun the final part of the database.pgsql file - where the "greatest" function is created. ERROR: null value in column "uid" violates not-null constraint

Try the following to fix: psql -U drupalDbOwner -d drupalDbName -ec "alter table sessions alter uid set default 0;" PostgreSQL support in Drupal 4.7.x

The PostgreSQL support in Drupal 4.7.x has improved dramatically. This page lists remarks and points to remember when installing and using Drupal 4.7.x with PostgreSQL database.

The installation instructions, specific for PostgreSQL, are in INSTALL.pgsql.txt file PL/pgSQL is no longer required for Drupal working You should not use schema as a $db_prefix. For example, use foo_, but not foo.. If you use schema prefix, you will run into errors when upgrading to the next stable release (e.g. from 4.7.x to 4.8.x). The errors are easy to fix, but it’s impossibile to support both foo_ and foo. type prefixes Drupal 4.5 and PGSQL 8 configuration

The exact order of commands I used to get drupal working on PostgreSQL 8.0.0 beta[345].

Differences to the (excellent) supplied documentation:

Create the db user first createdb -O instead of -U. This sets the owner of the new database to the user, but that user need not have create database permissions. Remember the createlang command as pointed out (thank goodness!) by another user

110 6 Jun 2007 Drupal Handbook

psql expects -U instead of -u. Use -f to load the file.

1) Create a new database user (I used "drupal").

As the postgres user: postgres$ createuser --pwprompt Enter name of user to add: drupal Enter password for new user: Enter it again: Shall the new user be allowed to create databases? (y/n) n Shall the new user be allowed to create more new users? (y/n) n

2) Create the new drupal database owned by the user created in 1) above

As the postgres user: postgres$ createdb -O drupal drupal

3) Add the plpgsql language to the database

As the postgres user: postgres$ createlang plpgsql drupal

4) Finally, read in the supplied database.pgsql file.

As root postgres user: postgres$ psql -U drupal -d drupal -f database/database.pgsql

5) Set $db_url as mentioned in above documentation.

Installing contributed modules

Once you have the Drupal core files installed, you can begin adding third-party contributed modules to extend or alter Drupal’s behavior.

The basic instructions are as follows: Download the module, extract the files, upload the resulting folder, and enable the module in administer > site building > modules (version 5.x) or administer > modules (version 4.7 or under).

The detailed instructions are:

1. Download the module. Make sure the version of the module matches your version of Drupal. Note that modules labeled "CVS" are in a development stage. They may be written for a previous/current/future version of Drupal, and they are considered unstable and should be handled with care. 2. Extract the files. When you first get the module, it will appear in a compressed

111 Drupal Handbook 6 Jun 2007

such as ’tar.gz’. On Windows, use a program like WinZip to extract it. On the Mac, you can use Stuffit Expander. To extract the file using the Unix command line:

tar -zxvf modulename-drupalversionnumber.tar.gz

You should see a list of files extracted into a folder.

3. Upload the folder. FTP your files to the desired modules folder in your Drupal installation. Since the /modules/ folder is typically reserved for Drupal core modules, as of version 5.x you should create a sites/all/modules/ directory and put uploaded modules there. This will also make it easier to update your Drupal site later on. For version 4.7 and below, put contributed modules into /sites/example.com/modules/ (multi-site setup) or /sites/default/modules/ (single site setup) 4. Read the directions. If the module has an installation file (usually INSTALL.txt and/or README.txt), read it for specific instructions. There are modules that require special treatment, and even modules that depend on other downloaded files to function properly. Sometimes the readme filename has no .txt extension. When you try to double-click on it, your computer doesn’t know what program to use. In that case, open Notepad (or your favorite text editor) first, and then open the file using Notepad’s ’open’ command. 5. Enable the module. Version 5.x users go to administer > site building > modules while 4.7 or prior use administer > modules. Check the ’Enabled’ box next to the module and then click the ’Save Configuration’ button at the bottom. NOTE: If you’re upgrading an existing module you’ll need to browse to your update page at www.example.com/update.php and click on ’run the database upgrade script’. 4.6 USERS: As of 4.7, modules have an .install file so that any database tables which the module requires are created automatically when the module is enabled. If the new module doesn’t have one, look for modulename.mysql and/or modulename.pgsql. If you see those, the module isn’t using .install files yet, and you need to read step 6 of the 4.6 instructions. If there are none of those files, the module doesn’t affect the database. 6. Set file permissions. Some modules will require you change permissions or settings to get them working. Permissions and settings info may be in the instructions that came with the module. Usually, go to administer > users > access control. Scroll down to see if the module appears in the list and, if it does, give the appropriate permissions to roles. 7. Adjust settings. In 5.x, settings are with the module. In 4.7 and prior, go to administer > settings and see if the name of the module you just installed is in the list. If it is, click the module name and configure as appropriate. 8. If you run into problems, search the forums. If your problem hasn’t already been addressed, post a question and someonw will try to help you out.

Note: To keep up-to-date on any issues and fixes related to your newly installed module(s), you can create a user account (if you haven’t done so all ready) and then subscribe to each module you are using.

Note: You can have only one copy of a module with the same name in each Drupal site.

112 6 Jun 2007 Drupal Handbook

HOWTO: Install glossary module

I just finished installing the Glossary module in three Drupal 4.7x websites, so I thought I’d write out some basic steps here: Where is the Glossary?

One of the first things to try to understand is that, although we will install a "Glossary Module", all the glossary content is actually entered and created in "Administer>Categories*" as entries in a Vocabulary. Although Taxonomy Vocabularies are quite powerful, and contain many other uses (many of which I don’t yet understand or I’m not yet aware of), this article only explains Vocabularies as they relate to the Glossary Module. The Glossary Module takes the Vocabulary entries and turns them into one or more Glossaries. Each time you create a new "Vocabulary", you are creating (the potential for) a new Glossary. (The Vocabulary terms are only turned into Glossaries when chosen in the "Administer>Input Formats" section.) (More about this later below.) *Note: Although the Glossary content is entered through "Administer>Categories>Vocabularies" , don’t get this confused with the optional, but different, Category Module, which adds it’s own "Administer>Categories" menu listing.

What is the purpose of the Glossary Module, and what does it do?

Creates Glossary Page(s), the Glossary Module creates a glossary page of all your terms, with the definitions. You may create one or multiple glossaries.

Terms Identified:, on any page on your website, whenever you use any of the words in the glossary, those words will be identified on each page. You can choose whether the words will be identified by being underlined (with a broken line), or using a superscript letter (or word), such as the superscript letter "i", like thisi (You can actually type in any letter or word that you want), or by using a small icon by the word. (You can also chose whatever icon you like)(see instructions below)

Definitions Available on "Hover", whenever the visitor "hovers" the mouse pointer over any one of the identified terms, the definition will "pop up" in a small box for about 6 seconds. This way the definitions of all the words in your glossary will be readily available every time you use any of those words.

Instantly Go to Glossary. If you click on the underlined word, or one of the identifiers (the superscript "i" or the small icon), you will immediately be taken to the full glossary page.

Full Page Definitions, you can attach full page (or multiple pages) of descriptions to any, or all, of the glossary terms. (see instructions for this at the bottom). If you have attached any full pages to any glossary term, the pop up definition will still work, but when you click on the word, you will be taken to the full page descriptions instead of to the glossary page. If you have multiple pages attached to the glossary term, then you will be shown the teasers of all the definition pages. You can then choose to look at any of those pages.

113 Drupal Handbook 6 Jun 2007

Installing the Glossary Module

More detailed instructions (for some of the following steps) can be found in the Glossary Readme file.

1. First download the Glossary Module from http://drupal.org/project/glossary onto your computer.(Some website control panels allow you to upload an archived file; zip, tar, etc. and then unarchive it after the file is on your website in a folder. If this is the case, then just upload the Glossary Module tar or zip file to your website. Otherwise, unzip the file on your computer, then ftp the whole folder to you website folder.)

Using either a ftp program, such as FileZilla, or from your website control panel: file manager, upload the folder/files to (mywebsite.com/drupal/modules)

Configuring the Glossary 1. On your Drupal website, go to "Administer>Modules" and enable the glossary module and save the new configuration. Go to Administer>Categories: Add one or more Vocabularies. You might give the vocabularies names that will encompass all your terms. For example, since I do upholstery, I might name one of my Vocabularies "Upholstery Terms" , then add some terms. Go to Administer>Input Formats: Choose one of the input formats, for example chose âFiltered HTMLâ, At the right side, under "Operations", click on âconfigureâ. This will take you to the "’Full HTML’ input format" page. Under the âViewâ tab (which is the default), under âFilters,â enable the "Glossary filter", At the bottom of the page, click âSave Configurationâ. After it is saved, you will be on the same page. Now, at the top of the page, click on the âconfigureâ tab. Click on âGlossary Filterâ which will open up some choices. In the âSelect Vocabularyâ box, click on the vocabulary term(s) that you created in Administer>Categories. Next, do you want all the terms of your glossary to show on one page? (This would be suitable for small glossaries) If not, click in the box by "Show glossary across many smaller pages" The next choice is "Match Type". I haven’t figured that one out yet, so I leave it alone on "Word". Chose whether you want your glossary terms to be case sensitive or insensitive. I usually chose case insensitive, since I want all the tems to show up, whether capitalized or not. Next, do you want all the terms on any given webpage to be identified as being in the glossary, or do you only want the first term on any page identified? Chose Replace Matches: "Only The First Match" or "All Matches". Under "Indicator Settings", you now make choise about how you want your terms identified on the website pages. Under "Term Indicator" Choose "superscript", "icon", or "replace with acronym link": Superscript:If you want a superscript letter (or word) by each word, like thisi or thisterm Icon: A default icon is installed with Drupal. the icon will follow the term in place of the

114 6 Jun 2007 Drupal Handbook

superscript. If you want to choose a different icon, upload it somewhere on your website, such as your picture gallery, or a file, copy the URL to your chosen icon, and enter that URL into the Glossary Icon URL: text box. Underline: If you’d rather have all you terms underlined (only with a broken line), then choose "replace with acronym link" in the Term Indicator box. When you are finished with all of your choices, click on âsave configurationâ

Glossary Administration: Finally, Choose which type of user(s) that you want to be able to administer the glossary, such as all "authenticated users" or only members in a "specific user role", or just the "administrator(s)". To make this choice, go to "Administer>Access Control>Permissions. Scroll down to "glossary module" and enable your chosen user role(s).

Your Glossary Module should be working now. Go back to "Administer>Categories>Vocabularies" to enter your glossary/vocabulary terms. I would suggest that you keep your terms down to one brief paragraph. This paragraph will display all through the website whenever a user’s mouse pointer "hovers" over the indicated word; it will only display for about 6 seconds. Keep your paragraph down to about 6 seconds of comfortable reading. (Yes, a user can go back to the indicated word and get the definition to pop up again, but why should they have to? You can put more detailed definitions or explanations on other page(s), which can be connected to any glossary/vocabulary term(s).)

Adding Full Page Definitions

Do you want to allow any registered user to add full page definitions to the glossary, or do you want only specific persons to have this ability? This is controlled through the "Administration>Input Formats". If you want every authenticated user to be able to add full pages to the glossary, then you would enable the glossary with each of the input formats available to those users. However, if you only want specific users to have that abililty, Use or create an input format that only those users, or type of users, will be using...... >>> More to be added here later <<< ...... Adding Glossary To Menus

This part (below) needs to be written better, more later.

1. To create additional glossary entries, go to Administer>Categories (as you did above) and enter more. (when your create Vocabulary (in Administer>Categories above), menu items and blocks are created for them, but not enabled.) If you want your Vocabulary to be on the website menu, go to Administer>Menus and enable them. If you want your Vocabulary to have its own menu block, go to Administer>Blocks and enable them.

Stephen Winters Winters Sewing Winters Sewing: Upholstery Information Website

115 Drupal Handbook 6 Jun 2007

Kingwood Bible: Community Website

Leech - automating content addition

The Leech module is an amazing module that automagically adds content to your site. Once its set up it will read RSS feeds and "leech" the articles from the originating site and each article as a node on your drupal site.

This is how you set up leech (4.7.x-1.6 as of 3/3/2007).:

Enable the following 2 modules:

1. leech

node_template (which comes with leech)

next, according to modules/leech/README.txt you have to do the following:

1. create a story called "template story" and in the body of the story, put any place holder like "template node". Under publishing options disabled "Published" 2. After creating the story, you will find the node now has a new tab called "template". Click on that and then on the button named "create" 3. Next go to admin/settings/content-types and enable leech using the template created above. and save 4. The final and most important part of the leech puzzle is from http://drupal.org/node/116859. which says you have to create a PAGE for each RSS feed. When you create content/page you will now find there is a new option called leech. put in your rss feed’s url and wait for like 10 to 30 seconds. the advanced options will fill up with the data for your feed. Give your new leech feed a name and save. I don’t believe any body would want this new leech feed posted to their front page so uncheck that option from under publish. 5. once saved, there is still no data, depending on how often you set your leech module to check for updates (dependent on cron) you will either have to wait for the next cronjob or click on leech data now and VOILA! NEW STORIES!

NB. its supposedly possible to use other node types and even CCK but i havent tried and the above is exactly what i need

Relationships between modules

This is a start to explain how similar or related modules are related and why you would use one vs another.

Internationalization - Locale (core), i18n also known as Internationalization, and Translation

116 6 Jun 2007 Drupal Handbook

http://drupal.org/project/locale - provides multiple translations of strings generated by drupal - now part of the core code of drupal, critical if you want the site in something other than english http://drupal.org/project/i18n - provides a mechnanism to define multiple a single piece of content in multiple languages. - requires locale module - only use this if you want your site in English AND french http://drupal.org/node/12875 - translation module which allows for people to switch between node content in other languages - must require locale and i18n module - designed to make it easier to produce sites in both english AND french

Module Comparisons

- http://drupal.org/project/scheduler vs http://drupal.org/project/event (applied to nodes)

- http://drupal.org/node/19813 vs taxonomy

Installing new modules (Drupal 4.6 or older)

After installing Drupal, you have the option of installing extra modules to extend or alter Drupal’s behavior.

In brief. Download the module, extract, upload the folder into your Drupal modules folder, run the mysql file if necessary, and enable the module in administer » modules.

1. Download the new module. Make sure the version of the module is compatible with your version of Drupal. Also note that modules labeled CVS are considered unstable and should be handled with care. Often, CVS modules work only with the CVS version of Drupal. They may be in draft form, or be in the midst of active development. 2. Extract the module. When you first get the module, it will probably come in a compressed file format such as tar.gz. On Windows, use a program like WinZip to extract it. On the Mac, you can use Stuffit Expander. To extract the file using the Unix command line:

tar -zxvf modulename-4.5.tar.gz

You should see a list of files extracted in to a folder.

3. When you’ve extracted the file, upload the files via FTP to a folder inside the modules/ folder of your Drupal installation. 4. Read the installation file (usually INSTALL.txt and/or README.txt). Sometimes the installation file has no extension, so when you try to click on it, your computer doesn’t know what program to use. In that case, open Notepad (or your favorite text editor) first, and then open the file into it. 5. There are modules that modify the database. You can generally tell if there is a modulename.mysql and/or modulename.pgsql file included with the module. If you

117 Drupal Handbook 6 Jun 2007

do have to modify the database, see the next few steps. If you do not, please skip to step 7. 6. If you have to modify the database to get your module running, you will need to add tables to the database you made when you installed Drupal. Instructions given here are for MySQL. Using phpMyAdmin: If you have phpmyadmin, log in and go to your drupal database. If you have it, but do not know how to access it, please contact your host. Click on the tab that says ’SQL’ You should see a text area labeled ’Run SQL query/queries on database yourdrupaldatabase’. Underneath, it says ’Or Location of the textfile:’ Click browse, and find the modulename.mysql that came with the module. Click go. Unless your instructions for the module says anything else, that should be all you have to do to the database. Using the Unix command line: Run the following command. mysql -u username -ppassword database_name < modulename.mysql Replace ’username’ with your MySQL username, ’password’ (but keep the -p before it) with your MySQL password, ’database_name’ with the database Drupal uses, and ’modulename.mysql’ with the SQL file that the module comes with. You can generally find this out from settings.php in either the sites/default folder or the sites/sitedomain.com folder, replacing sitedomain.com for the domain that hosts Drupal.) 7. For most modules, all that is left is to activate it! To activate your module, you need to click administer » modules, check the box next to your new module name, and click on ’Save configuration’ at the end. 8. Some modules will require you change permissions or settings to get them working as you like them. Permissions and settings info may be in the instructions that came with the module. If not: 9. 1. Click administer » access control. Scroll down to see if the module appears in the list and, if it does, give the appropriate permissions to roles. 2. Click administer » settings and see if the name of the module you just installed is in the list. If it is, click the module name and configure as appropriate. 10. If you still run into the problems, search the forums. If your problem hasn’t already been addressed, post a new post.

Note: To keep up to date on any issues and fixes you can create a user account (if you haven’t done so all ready) and subscribe to each module you are using.

Note: You can have only one copy of a module with the same name in an Drupal installation.

Multi-site installation and set-up

Instructions on multi-site configuration (also known as "multisite" and "single code base" installations) can be found within the installation instructions.

118 6 Jun 2007 Drupal Handbook

Here are some useful links:

Search results 4.6 Multi-Site from single code base Multi-Site .htaccess configuration multi-site, single installation, shared db, single sign on. is this possible? Automatic Multi-site registration Using Multi-Site Multihosting Off Single Codebase Multisite and symlinks doesn’t work Sharing tables between installations

10 Minute Multisite Install & Configuration

Multisite 10 minute Install:

Server: LAMP SSH/Telenet Client: PuTTY Must have root access to your server.

If website in question is an addon domain, i.e., addon.mydomain.tld, then substitute "www" for "addon" in steps below.

For list of Linux commands visit: http://www.oreillynet.com/linux/cmd/ or http://www.ss64.com/bash/

Here we go:

[login via PuTTY]

Get to location where Drupal core will be located:

[/]# cd /var/www

Upload Drupal core:

"x.x" should be replaced with the version of Drupal you’re installing, e.g. "5.1"

[/var/www]# wget http://ftp.osuosl.org/pub/drupal/files/projects/drupal-x.x.tar.gz

Unpack Drupal core:

[/var/www]# tar -zxvf drupal-5.1.tar.gz

Move contents of Drupal core (including .htaccess) to html:

119 Drupal Handbook 6 Jun 2007

[/var/www]# mv drupal-x.x/* drupal-x.x/.htaccess /var/www/html

Clean-up:

[/var/www]# rm drupal-x.x.tar.gz [/var/www]# rm drupal-5.1

Create the files directory per Drupal instructions and change permissions (will change permission again after install):

[/var/www]# cd html [/var/www/html]# mkdir files [/var/www/html]# chmod 777 files

Make directories that will hold custom and contributes modules and themes:

[/var/www/html]# cd sites/all [/var/www/html/sites/all]# mkdir modules [/var/www/html/sites/all]# mkdir themes [/var/www/html/sites/all]# cd modules [/var/www/html/sites/all/modules]# mkdir custom [/var/www/html/sites/all/modules]# mkdir contrib [/var/www/html/sites/all/modules]# cd ../ [/var/www/html/sites/all]# cd themes [/var/www/html/sites/all/themes]# mkdir custom [/var/www/html/sites/all/themes]# mkdir contrib

Create directory "www.mydomain.tld":

[/var/www/html/sites/all/themes]# cd ../ [/var/www/html/sites/all]# cd ../ [/var/www/html/sites]# mkdir www.mydomain.com

Change permission of "settings.php" per Drupal instructions and copy "settings.php" in default to www.mydomain.tld:

[/var/www/html/sites]# cd default [/var/www/html/sites/default]# chmod 777 settings.php [/var/www/html/sites/default]# cd ../ [/var/www/html/sites]# cp -rp sites/default sites/www.mydomain.tld

Create database and user with permissions:

[/var/www/html/sites]# mysql mysql> CREATE DATABASE wwwmydomaintld_drupal; mysql> GRANT ALL PRIVILEGES ON wwwmydomaintld_drupal.* TO ’wwwmydomaintld_myusername’@’localhost’ IDENTIFIED BY ’mypassword’;

120 6 Jun 2007 Drupal Handbook

mysql> \q

Go back to PuTTY to chmod on settings.php in www.mydomain.tld:

[/var/www/html/sites]# cd www.mydomain.tld [/var/www/html/sites/www.mydomain.tld]# chmod 755 settings.php [/var/www/html/sites/www.mydomain.tld]# logout

What next?:

Make changes to "settings.php" in www.mydomain.tld? I’ve read that it’s not necessary to make changes to setting.php. Make changes to "httpd.conf" in /usr/local/apache/conf?

I’ve been using WHM to create accounts, putting Drupal in public_html and having no problems. But when it comes to parting from the WHM abstraction and getting multisite set-up correctly this is the end of the proverbial road for me.

Could use help...:

1. Help making improvements to steps articulated above 2. Help with next steps so that I/we can get on to grander things, like creating modules, custom themes, profiles, (and maybe - just maybe - spend some time working on business strategy :-)

Access all multisites with www. only [.htaccess]

The default .htaccess RewriteRule to redirect every multisite.com to www.multisite.com does not work properly.

If you have problems with that too, just leave the two lines uncommented, and ADD THE FOLLOWING 3 LINES FOR EVERY MULTISITE you set up:

RewriteCond %{HTTP_HOST} mysite\.com$ [NC] RewriteCond %{HTTP_HOST} !^www\. mysite\.com$ [NC] RewriteRule ^(.*)$ http://www.mysite.com/$1 [L,R=301]

(Thanks to Florian!)

Drupal as a library

Short introduction on how to share drupal with all users on a shared server (without having troubles with file-permissions).

Note: it is still possible to use the Multisite option of drupal.

121 Drupal Handbook 6 Jun 2007

example server’s file-structure:

/path/to/phplibraries/drupal (chmod 644) /home/ user1/ (example.com) lib (symbolic link => /path/to/phplibraries/) public_html/ main/ files/ includes (symbolic link => /home/user1/lib/drupal/includes) misc (symbolic link => /home/user1/lib/drupal/misc) modules (symbolic link => /home/user1/lib/drupal/modules) profiles (symbolic link => /home/user1/lib/drupal/profiles) sites/ all (symbolic link => /home/user1/lib/drupal/sites/all) default (symbolic link => /home/user1/lib/drupal/sites/default) example.com/ settings.php themes (symbolic link => /home/user1/lib/drupal/themes) .htaccess (copy from drupal/.htaccess) cron.php (copy from drupal/cron.php) index.php (copy from drupal/index.php) install.php (copy from drupal/install.php) robots.txt (copy from drupal/robots.txt) update.php (copy from drupal/update.php) xmlrpc.php (copy from drupal/xmlrpc.php) .htaccess (1) user2/ (example2.com) (same as user1) user3/ (example3.com) (same as user1) etc...

.htaccess (1) this isn’t neccessary but it keeps public_hml/ clean when several sites are maintained by one user. When only one site is maintained the contents of the main/ directory could be moved to public_html/ itself

Options +FollowSymLinks DirectoryIndex index.php RewriteEngine on

122 6 Jun 2007 Drupal Handbook

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{HTTP_HOST} ^example\.com$ [NC] RewriteRule ^(.*) main/$1 [L,QSA]

Multi-site setup in 5.x using CPanel

After some searching around, I found out how to do multi-site setup using CPanel.

1. Create your initial Drupal site at www.yourdomain.com. Drupal 5.x makes this very easy to do, as it will automatically install the database for you -- all you have to do is input the database information.

2. Create a folder in the sites/ folder that matches the subdomain you want to create (so for site1.yourdomain.com, the folder name would be site1.yourdomain.com).

3. Duplicate the settings.php file from the default folder and place it in your newly created folder from step 2.

4. Edit the settings.php file you just placed in the site1.yourdomain.com folder so that it points to the correct database.

5. In CPanel, set up the subdomain. For the above example of site1.yourdomain.com, a folder named site1 will be automatically created by CPanel.

6. Delete the folder that was created.

7. Use the following example to create and upload a php file onto your site. An easy way to do this is to use Notepad, pasting in the text below, editing as necessary, and then saving as multisite.php. Afterwards, upload via FTP or CPanel’s File Manager.

8. Go to the location of the php file in your browser (such as www.yourdomain.com/multisite.php)

This will create a symlink, allowing your subdomain to work properly.

9. Go to your subdomain. Drupal will install the tables necessary to run the new site.

10. You’re all set to use the new site.

If you run into any problems, or have questions, use the contact form attached to my user account here to contact me.

123 Drupal Handbook 6 Jun 2007

Multi-Site, Single Codebase, Shared Database, Shared Sgin-on 5.x

This document is written with assumptions that you have:

installed Drupal 5 before access to your server via ssh / telnet access to MySQL database / you can setup your own MySQL database

In this example, I will setup two sites using:

Drupal 5 One database on MySQL Linux-based server

Also:

Website’s url is: www.example.com Drupal is installed in: /var/www/drupal Names of sites are: âsite_1’ and âsite_2’

These sites will share session and user-related tables so once users login to one of the sites, they can view the other site without logging in. User roles and profiles are also shared among the two sites. 1. Prepare database and database user 1.1. create a database and user

In this example, I will use:

DB name: drupal_db DB username: druser Password: twosites Access right: SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES 2. create and modify site configuration 2.1. duplicate settings folder

Duplicate a folder contains site config information under drupal/sites/ dru@/var/www/drupal/sites: cp âR default/ www.example.com.site_1 dru@/var/www/drupal/sites: cp âR default/ www.example.com.site_2

124 6 Jun 2007 Drupal Handbook

2.2. Modify config files 2.2.1. provide DB connection detail

Open settings.php in a folder under www.example.com/site_1. Go to line 93 (or somewhere around there) and you should find a line that goes:

$db_url = ’mysql://username:password@localhost/databasename’; change this line with your DB name, DB user and password. It will look like: $db_url = ’mysql://druser:twosites@localhost/drupal_db’; 2.2.2. set prefixes for table names just below the line we just changed above, there is a line that goes like:

$db_prefix=’’; Since we want to share a database among two sites but not completely, we decide which tables to share / not to share. This can be done by adding prefixes to table names. An example given below is for sharing user-related tables, sequences (this table is a âcounter’ of users, nodes and other stuff) and session information. $db_prefix = array( ’default’ => ’site_1_’, ’users’ => ’shared_’, ’sessions’ => ’shared_’, ’role’ => ’shared_’, ’authmap’ => ’shared_’, ’sequences’ => ’shared_’, ’profile_fields’ => ’shared_’, ’profile_values’ => ’shared_’, ’users_roles’ => ’shared_’, ); the second line that goes:

’default’ => ’site_1_’, this means tables that are not shared with other sites will have a prefix âsite_1_’. So for example, table name ânode’ will be âsite_1_node’.

Now, when you finish editing this file, open and edit drupal/sites/www.example.com.site_2/settings.php. This time, you enter the exact same information for the database connection. So the line around 93 should look like:

$db_url = ’mysql://druser:twosites@localhost/drupal_db’; Then, you add an array of prefixes, which will look like: $db_prefix = array( ’default’ => ’site_2_’, ’users’ => ’shared_’,

125 Drupal Handbook 6 Jun 2007

’sessions’ => ’shared_’, ’role’ => ’shared_’, ’authmap’ => ’shared_’, ’sequences’ => ’shared_’, ’profile_fields’ => ’shared_’, ’profile_values’ => ’shared_’, ’users_roles’ => ’shared_’, ); notice a prefix in the second line is now âsite_2_’. At the installation, all tables will have this prefix except for the ones that are specifically given a prefix âshared_’. 3. create static links

In order to access site_1 and site_2 from web browser, you have to make static links to drupal directory. In the directory /var/www/drupal, enter the following commands: ln -s drupal site_1 ln -s drupal site_2 now access âwww.example.com/site_1’ (and âsite_2’). If you see a drupalicon and a message like âUnable to select database’, go back to 2.2.1 of this manual and check if you have all details correct, including a single-quotation and semicolon.

If you see hundreds of messages like âWarning: Table ’continuu_test.access’ doesn’t exist’, you are almost there. While this may look scary or makes you think you have done something wrong, it is just saying that it cannot find tables Drupal needs to have access to. This is simply because we have not yet finished installing Drupal. All the necessary tables will be created in the next step, which is described below. 4. install drupal

Since we have entered information for database connection, we can run the install script (install.php) straight away, instead of giving all the detail to installation wizard. From your web browser, just access: http://www.example.com/site_1/install.php http://www.example.com/site_2/install.php

Installation should complete within a second (or two). If you fail to install:

read the error message and find out what is wrong (wrong DB name, username or password, etc.) make sure $db_url (around line 93 in settings.php) ends with a quotation mark and semicolon. ( â; )

If you have two separate Drupal sites and are thinking about merging them with above method, I would recommend you not to do it. Yes, it is not impossible. You can rename tables and modify values in sequence table and so on, but i tried it and had a hell of a hard time... If you have sites already setup, using CAS or other authentication services is more appropriate than

126 6 Jun 2007 Drupal Handbook

merging.

Multi-Site, Single Codebase, Shared Database, Shared Sign-on 4.6

I used this option, having a network of interrelated sites. While each site has its own domain, offers its own theme and own primary (homepage) content, the sites are essentially related and needed to share user registration accounts and forums. With a shared database, they also share information, e.g. the site which offers reviews can also display news headlines in a sidebar; the site which offers classified ads can offer reviews in a sidebar; etc.

An unintended consequence of this approach is that savvy users can effectively navigate any and all content from any and all sites (once they understand breadcrumbs and drupal-specific navigation), so they get, essentially, whatever content they want in whatever theme they want. Apache (http) Configuration

All domains will point to one document root. That cannot be emphasized enough. When using virtual hosting, do not create a separate virtual domain for each site -- only for the first site. When using a control panel such as cPanel or Ensim, create only the first domain. In the first domain’s alias area, list all the additional domains and subdomains to be used. Your virtual hosting entries should end up like this:

ServerName www.firsthost.com ServerAlias firsthost.com ServerAlias secondhost.com www.secondhost.com ServerAlias thirdhost.com www.thirdhost.com forums.thirdhost.com etc...

DocumentRoot /home/virtual/whatever/var/www/html etc...

Any request for any of the domains will all run to /home/virtual/whatever/var/www/html for response. This is the desired result. Download and Placement

The code base should sit in the DocumentRoot defined above. Download the tar ball for the latest stable version (4.6 as of this writing) and open it in the doc root. Note: all remaining commands assume you are sitting in your doc root, so go there. wget http://drupal.org/files/projects/drupal-x.x.x.tar.gz tar -zxvf drupal-x.x.x.tar.gz mv drupal-x.x.x/* . mv drupal-x.x.x/.htaccess .

127 Drupal Handbook 6 Jun 2007

Check ownership and permissions - if you’ve downloaded directly, they’re likely to be very wrong. Security note of caution: I typically go through and change permissions to 444 (read-only) for all .php, .gif, .jpg and . files. In drupal, that’ll also mean .module files. You’ll have trouble editing these files, but that’s the point. It’s easier to change permissions temporarily on a file you want to hack than it is to fix a break-in. chown -R siteX:siteX . chmod -R 444 *.php *.gif *.jpg *.css *.tar *.module SQL Setup

There are two ways to do this: on the command line and via a control panel. Some control panels (Ensim, for example) require that you create new databases through their interface (so they can limit a site to a set number of databases).

If you can create new databases through the command line, do it like in the install file - mysqladmin -u user -p create Name mysql -u user -p GRANT ALL PRIVILEGES ON Name.* TO user@localhost IDENTIFIED BY ’password’; flush privileges;

I substituted Name for ’drupal’ in the instructions -- really, name your database something other than ’drupal.’ Helps to prevent hacking if the attacker isn’t intimately familiar with the site configuration. Even if you call it mysite_drupal, that’s something.

I also have no idea why the installation instructions suggest permissions for ’nobody,’ so I changed that to the database user. If you don’t have a database user setup for this site, setup an SQL user with its own unique password. phpMyAdmin makes it easy to do this.

If you have to create databases via your control panel, open it and go to the SQL page. Create a new, empty database associated with the correct host and call it what you will (see notes above about calling it ’drupal.’ Most systems create a database user for each site; if yours doesn’t, create that user and give it permissions for the database you just created.

Just because you have to create the database via the control panel doesn’t mean you have to fill it that way. You can now return to the command line and setup the database structure. mysql -u user -p Name < database/database.mysql chmod 000 database/database.*

Technically, you’re done after the first line, but I like to lock up all setup files once I’m finished with them. This prevents someone else from trying to reset my system to hack in and prevents me from erasing my database in a fat-fingered typing accident.

128 6 Jun 2007 Drupal Handbook

Individual Site Configuration & Theming

Now, to the individual site information. Drupal will parse the http request and provide the correct content based on the domain name and settings files. You’ll need one directory for each domain name and one settings file for each. You can link aliases together. In the example below, Drupal will load this settings.php file for calls to http://firsthost.com and http://www.firsthost.com. mkdir sites/firsthost.com cp sites/default/settings.php sites/firsthost.com ln -s sites/firsthost.com sites/www.firsthost.com

Now, edit sites/firsthost.com/settings.php and enter the following values (using the SQL values above for user, password and database Name). This allows the site to connect up to the database created above, and to create links to itself correctly.

$db_url = ’mysql://user:password@localhost/Name; $base_url = ’http://firsthost.com’; (or www.firsthost.com depending on preference)

And add the following lines (using site values). This overrides any theme or database settings to provide unique values for this site. Things you may want to override include the individual site’s name, slogan, and theme. Also, you can use site_frontpage to set a default module. In the case below, we’ve chosen ’node’ (generic stories) as the home page for this site.

$conf = array( ’site_name’ => ’Name of the First Site’, ’site_slogan’ => ’My Original Drupal Site’, ’site_frontpage’ => ’node’, ’theme_default’ => ’pushbutton’, ’anonymous’ => ’Visitor’ );

Now, repeat from the ’mkdir’ command for each new site. Some things will remain the same. The configuration variables will change. In the example below, we’ve changed the homepage to the book module and the theme to bluemarine. When Drupal parses a request for this second site, it will present those options.

$conf = array( ’site_name’ => ’Name of the Second Site’, ’site_slogan’ => ’The We Love Drupal Fan Site’, ’site_frontpage’ => ’book’, ’theme_default’ => ’bluemarine’, ’anonymous’ => ’Dude’ );

129 Drupal Handbook 6 Jun 2007

You have working multisites. Call up the first domain, setup your administrative user and run with it. Keep in mind that sites/default is the settings.php file which will be used if Drupal doesn’t recognize the http call, so you might want to set that one up to run with your default site ... or set it up to notify you if someone tries it. Some things which can be improved:

- I have yet to try to use the FOAF module ( http://drupal.org/project/foaf ) to automate logins from one domain to the other. At the present time, users must login separately to each site, even though they use the same account info.

- I don’t use the statistics module, so I can’t say what it does, but it can be difficult to get individual domain info out of the Apache logs. Unless you do some fancy configuration, you get one combined log.

- Note that to use different databases (completely different Drupal sites) with the same code files, you can still follow the above instructions, creating a separate database and user for each one. Then, point each settings.php file to the appropriate database instead of pointing them all to the same one.

Keywords: multisite multi-site multi site, multihost multi-host, host, sharing code, one codebase, site configuration, step by step

Multiple domains or vhosts using different databases

Apache supports both IP- and name-based virtual hosts (vhosts). While running more than one engine (by using vhosts) can be very useful for development and testing purpose, it might even be more interesting for hosting companies. Therefore, we tried to support vhosts in the best possible way in order to make the life of any administrator easier. We do so by making it possible to run an unlimited amount of vhosts on the same physical source tree, though by using different configuration files. Moreover, you can setup multiple configuration files in your includes-directory.

$ ls -l sites/*/*.php -rw-rw-r-- 1 drupal drupal sites/www.example1.com/settings.php -rw-rw-r-- 1 drupal drupal sites/www.example2.com/settings.php

The only thing left to be done is to setup the corresponding vhosts in your Apache configuration file. Note that the DocumentRoot points to the same source tree twice:

NameVirtualHost 127.0.0.1 DocumentRoot /home/www/drupal ServerName www.example1.com DocumentRoot /home/www/drupal ServerName www.example2.com

130 6 Jun 2007 Drupal Handbook

Remember that as of Drupal 4.6, you can have site specific modules and themes as well. Just create a directory under the sites/www.example1.com called ’modules’ and place the site specific modules. The same applies to themes as well.

Consult the INSTALL.txt that came with your Drupal installation for more details. Sharing Drupal tables between databases using MySQL5 Views

Note: The more Drupalish way to achieve this is through advanced table prefixing. The docs are in this handbook.

Problem: You’d like to share some data between two different drupal websites without changing any Drupal code or otherwise having to lift much of a finger. But you don’t want to share information unless it meets certain requirements (for example, only users labeled "foo" in somedatabase.sometable) For our example, we’ll use the users table.

Solution: Use MySQL5 Views (http://dev.mysql.com/doc/refman/5.0/en/views.html)

Our "master" users table resides in a database called "master". The database of the site that will have restricted access to our masters users table is called "banana". Assumming you’re starting with a fresh instance of the Drupal schema in your database "banana", do this: mysql> use banana; mysql> drop table users; mysql> CREATE VIEW users AS mysql> SELECT * mysql> FROM master.users mysql> WHERE uid IN ( mysql> SELECT uid mysql> FROM somedatabase.sometable mysql> WHERE uid = 0 mysql> OR label = ’foo’ mysql> )

Drupal will use banana.users just as it would a normal users table. No other modifications are necessary. Now only "foo" users will be included in the users table for your banana website.

Note: Drupal has a dependency that is not really documented. Every users table must have an entry that contains uid=0. It’s a "stub" entry that Drupal needs to function properly. A workaround for this dependency is to include "user 0" in the results set that defines your view.

See, wasn’t that easy?

131 Drupal Handbook 6 Jun 2007

Multiple domains using the same database

If you want to host multiple domains (or subdomains) on top of the same database (e.g. http://example.com/ and http://www.example.com/), simply use symbolic links to setup the required configuration files:

$ ln -s sites/example.com sites/www.example.com $ ls -l sites -rw-rw-r-- 1 drupal drupal sites/example.com lrwxrwxrrx 1 drupal drupal sites/www.example.com -> sites/example.com

If your installation isn’t in the root folder then you need to specify the path to the Drupal installation. For example if the URL to your installation is http://www.example.com/drupal/ you would use sites/www.example.com.drupal with a settings.php file in it.

If you want cookies to be shared between two sites, you will need to set the value of PHP’s session.cookie_domain correctly. In the case above, set it to ".example.com". You can do this through Drupal’s .htaccess file.

Same codebase, completely different content and users

This document assumes the following:

You want to create more than one Drupal site using the same codebase (the same basic set of Drupal files, uploaded into one location).

You know how to install mysql tables in your database. You know how to set up subdomains/folders/other domains that you want to use. You have already downloaded Drupal 4.7, and set up one MAIN site.

This document contains instructions on how to create completely separate Drupal site, with different configurations, users and content. Nothing is shared between the installations except the codebase.

Some definitions:

codebase: the basic set of Drupal files, included in the .tar.gz file. the stuff that makes Drupal work.

database: a collection of tables that stores data.

Affected files:

settings.php (sites/default/...)

132 6 Jun 2007 Drupal Handbook

database.mysql

For this example, we will assume the following:

www.example.com: the MAIN site, where the codebase has already been uploaded, and settings.php has been properly configured.

sub1.example.com; www.example.com/sub2; www.subexample.com : the other sites we will create.

1. Create the following folders in your sites directory:

sites/sub1.example.com/

sites/www.example.com.sub2/

sites/www.sub3example.com/

Copy the settings.php file from sites/default into each of the above folders.

2. There are different database files (inside the database folder). Select the one that is appropriate for your database version. Copy it to each of the folders you made in step 1. This is OPTIONAL, but it will help you keep things straight.

3. Decide on SEPARATE PREFIXES for each site. Below is what we will use for the example:

site database prefix

sub1.example.com sub1_

www.example.com,sub2 sub2_

www.sub3example.com sub3_

4. Configure your settings.php for each site.

This code MUST BE CHANGED FOR EACH SITE:

$db_url = ’mysql://username:password@localhost/databasename’;

Note; if you are using the same database as the MAIN site, the $db_url is the same.

133 Drupal Handbook 6 Jun 2007

OPTIONAL:

# $base_url = ’http://www.example.com’; // NO trailing slash!

# $conf = array( # ’site_name’ => ’My Drupal site’, # ’theme_default’ => ’pushbutton’, # ’anonymous’ => ’Visitor’ # );

For sub1.example.com, the settings would be:

$db_prefix = ’sub1_’; $base_url = ’http://sub1.example.com’; $conf = array( ’site_name’ => ’My SUB1 Drupal Site’, ’theme_default’ => ’pushbutton’, ’anonymous’ => ’Visitor’ );

For www.example.com/sub2, the settings would be:

$db_prefix = ’sub2_’; $base_url = ’http://www.example.com/sub2’; $conf = array( ’site_name’ => ’My SUB2 Drupal Site’, ’theme_default’ => ’fancy’, ’anonymous’ => ’Anonymous’ );

For www.sub3example.com, the settings would be:

$db_prefix = ’sub3_’; $base_url = ’http://www.sub3example.com’; $conf = array( ’site_name’ => ’My SUB3 Drupal Site’, ’theme_default’ => ’marvin’, ’anonymous’ => ’Guests’ );

6. Upload the modified settings.php files in their respective folders.

7. Open the database file you copied into each sites folder. Find the following (don’t forget the SPACE at the end!!!): CREATE TABLE INSERT INTO

134 6 Jun 2007 Drupal Handbook

Replace each ’create table’ and ’insert into’ with ’create table dbprefix_’ and ’insert into dbprefix_’

For sub1.example.com: CREATE TABLE >> CREATE TABLE sub1_ INSERT INTO >> INSERT INTO sub1_

8. Upload the modified mysql files into the database you specified in your settings.php.

9. Voila!

Setup of /sites directory for multi-site

Drupal’s multi-site hosting capability is built in with any installation. This is great news for users who run numerous web sites from a single hosting account. A single Drupal installation can be used to run multiple domains, which makes it much easier to manage and maintain the code base. Even if you are dealing with only one domain, the multi-site capability may be valuable by providing the ability to run a separate domain or sub-domain for a development version.

This page describes the set-up of the /sites directory for multi-sites. The single-site basics are discussed at Basic /sites directory setup.

With version 5.x, the intended location for all non-core elements of a Drupal installation is in a separate /sites directory inside the Drupal installation.

Directory Contents /drupal/sites/all /modules (used by all sites) /themes /drupal/sites/default /files (used when there is no /sites/example.com directory) settings.php /files /module /drupal/sites/example1.com /themes /tmp settings.php /files /module /drupal/sites/example2.com /themes /tmp settings.php

135 Drupal Handbook 6 Jun 2007

The intended best practice configuration is to create a /sites/example.com directory for each domain. It should contain a site-specific settings.php file and /files directory. Configure Drupal site settings to specify ’File System Directory’ of ’sites/example.com/files’ instead of the default ’files’. It’s possible to do this with an existing web site, but moving file uploads around can cause a lot of confusion if there are already URLs pointing to the old locations.

Domain specific modules and themes should also be placed in /sites/example.com/modules and /sites/example.com/themes respectively.

Contributed modules and additional themes which are for use by all domains in a multi-site installation should be placed in /sites/all/modules and /sites/all/themes. Note that there shouldn’t be a /sites/all/files or /sites/all/settings.php.

The /sites/default directory should contain /files and settings.php, for use if the /sites/example.com directory doesn’t exist for a domain.

In addition to multiple sites, such as www.example1.com and www.example2.com, sub domains are also easily set up. Adding sub3.example2.com and sub3.example2.com/site4, the directory structure for these four sites would be:

/drupal/sites/all/modules /drupal/sites/all/themes /drupal/sites/default/files /drupal/sites/default/settings.php /drupal/sites/example1.com/files /drupal/sites/example1.com/modules /drupal/sites/example1.com/settings.php /drupal/sites/example1.com/themes /drupal/sites/example1.com/tmp /drupal/sites/example2.com/files /drupal/sites/example2.com/modules /drupal/sites/example2.com/themes /drupal/sites/example2.com/tmp /drupal/sites/example2.com/settings.php /drupal/sites/sub3.example2.com/files /drupal/sites/sub3.example2.com/modules /drupal/sites/sub3.example2.com/settings.php /drupal/sites/sub3.example2.com/themes /drupal/sites/sub3.example2.com/tmp /drupal/sites/sub3.example2.com.site4/files /drupal/sites/sub3.example2.com.site4/modules /drupal/sites/sub3.example2.com.site4/settings.php /drupal/sites/sub3.example2.com.site4/themes /drupal/sites/sub3.example2.com.site4/tmp

136 6 Jun 2007 Drupal Handbook

Once you’ve done this, the file structure of your site will be cleanly organized:

The main Drupal directory will contain only the standard ’core’ files. All of your custom themes, add-ons, settings, and so on will be in /sites/example.com, /sites/all, or /sites/default. /sites/default/settings.php and /files will be used if there is no /sites/example.com directory. /sites/all/modules and /themes will be available to all sites. Backing up the /sites directory and your Drupal database will give you everything you need to restore the site in the event of a crash, or to move to a new server. Adding a domain is easy: just copy the /sites/default directory to /sites/example5.com

Symbolic links can be used for several purposes:

Even if using default settings, a good option is to use links from /sites/example.com directory to point to the /sites/default directory. That way, if the settings and /files are ever changed from the default and actually placed in /sites/example.com, their location does not ’move’ and no links are broken. Links could also be used to point the /sites/default directory to your primary site. A /files directory could easily be shared across two domains without being shared across the remaining domains. A non-domain-name path for /files can be setup. If it is possible that the domain name might change (say, from a development name), then you can set up a link from /drupal/sites/moniker to /drupal/sites/example.com, where ’moniker’ is a short version of the site name that will remain constant even if /example.com changes.

Although the /sites/default directory could contain a /modules and /themes directory, these elements should usually be placed in /sites/all or /sites/example.com. Similarly, although contributed modules could be placed in /drupal/modules as was the practice in version 4.7, this is not recommended.

Multi-site directory setup for sub-domains, including non-standard ports, is described in the installation instructions (INSTALL.txt).

See multidomain for a contributed module that allows spanning one site across multiple domains, so that specific content types appear on specific domains or sub-domains.

Version 4.6 and 4.7: Best practice for multi-site set-up under version 4.6 and 4.7 is similar to 5.x. The primary difference is that there is no /sites/all directory. Instead, /modules and /themes that are available for all domains are kept in /drupal/modules and /drupal/themes.

Installing new themes

Once you get Drupal installed and you start to come to terms with it you will probably want to customize the way it looks.

137 Drupal Handbook 6 Jun 2007

There are several themes which you can download from the Drupal web site which should get you started.

Installing a new theme is very straightforward:

1. Download a new theme package. Note that themes for different Drupal versions are not compatible, version 4.4 themes do not work with Drupal 4.5 and reverse. 2. Read any README or INSTALL files in the package to find out if there are any special steps needed for this theme. 3. Check to see if you have the required theme engine to be able to display your theme. Theme engine files go in a folder in themes/engines in your Drupal directory. 4. Upload the contents of the theme package to a new directory in the themes directory in your Drupal site. For example; in 4.7 you place your theme in themes/box_grey. in 5.0 you place your themes in /sites/all/themes/box_grey 5. Click administer » themes and enable the new theme (Drupal will auto-detect its presence). 6. Edit your user preferences and select the new theme. If you want it to be the default theme for all users, check the default box in the themes administration page.

Note: You can see a variety of themes on themes.drupal.org. Some of these themes shown there are available for download from Drupal.org and others are merely samples.

138 6 Jun 2007 Drupal Handbook

Basic site configuration

Drupal is an extremely flexible platform that provides you with many options for changing how your site looks, how users interact with it, and the kinds of information you wish to display. Although there are many configuration options, Drupal works well "out of the box" and there is very little initial configuration to perform. As your site evolves and your demands grow, Drupal makes it easy for you to dramatically alter its look and add to its functionality. Best of all, because it is released under the GNU General Public License, Drupal is infinitely customizable and lets you tailor it to your specific needs.

You will want to start your configuration with your drupal site’s basic settings can be found on the settings page, which you can reach by clicking administer » settings in the navigation block. You must be logged in and have permission to access this page. After you change the settings, don’t forget to click "Save configuration" at the bottom of the page.

The information you enter here is stored in Drupal’s database to help Drupal decide how to prepare and serve your pages. Keep in mind that the settings on this page are only basic configuration settings. There are many other places to configure Drupal. These are discussed in the appropriate sections of this handbook. Much of the configuration information can be found in the modules help file or in the modules section of the handbook. For more advanced configuration then an out of the box modules provide, see the Customization and theming handbook.

A lot of the information you are asked to supply on the settings page is self-explanatory and there are brief help messages below each setting to guide you. Note that the "Slogan," "Mission," and "Footer message" may or may not be immediately visible, depending on the theme you are using. If you are new to Drupal, we recommend supplying all the information for these boxes. If you decide that you don’t need or like how Drupal uses them, you can change it later (see the handbook section on configuring themes for more on this).

Settings

Below are links to provide you with explanations and tips for some of the more technical settings on the "settings" page. If you just want to get Drupal up and running, you can safely ignore these settings. You’ll always be able to come back and experiment with them later. The one possible exception to this is the "file system settings" which you may wish to set now. For more information on the "File system settings," click its link below. This link can also help you resolve issues with errors that often appear at the top of the "settings" page after Drupal is freshly installed.

You can

configure your sites basic settings at administer >> settings.

139 Drupal Handbook 6 Jun 2007

General settings

The General settings area is where you configure some basic information for your site.

Name: this is where you set the name displayed for your site.

E-mail address: A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc. You can set this to a real email address that people can reply to or to something generic [email protected] that is outbound only. The email server that your site uses is set in the php.ini file and not by Drupal.

Slogan: The slogan of this website. Some themes display a slogan when available. It will also by displayed in the title bar of your sites visitor web browser.

Mission: Your site’s mission statement or focus. Your mission statement is enabled in your theme settings and requires that the theme support it’s display.

Footer: This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.

HTML formating can be used in the mission and the footer areas.

Anonymous user: Users who interact with your site without being logged in are labeled as "Anonymous" by default. Drupal gives you the option to change this to something different (e.g. "Anonymous coward"). The name you give anonymous users is used by Drupal when creating bylines for posts which typically reads something like, "Posted by Anonymous on January 1, 2006".

Default front page

This setting gives you control over what Drupal-generated content a user sees when they visit your Drupal installation’s root directory. For example, you might have created a node with a large collection of links to act as a table of contents to the different sections of your site and you want this directory to be what users see first.

This setting tells Drupal which URL users should be redirected to. It’s important to note that the URL is relative to the directory your Drupal installation is in. So, instead of

"http://www.example.com/node/83" or

"http://www.example.com/drupal_installation_directory/node/83," you need only type "node/83". For those not using clean URLs, note that there is no need to type in "?q=" before typing the URL.

140 6 Jun 2007 Drupal Handbook

By default, the "Default front page" is set to "node," which simply displays articles that have been "Promoted to front page." Note that when you change the "Default front page" to something other than "node", nodes that are "Promoted to front page" will no longer appear on the front page. They can however, still be viewed by visiting the relative URL path "node".

If you enter a value in here that is not a valid Drupal path, the user will be confronted with a "Page not found" error. You cannot redirect users to any web documents (e.g. a static HTML page) not created by your Drupal site. Examples

Problem 1: You want a particular node to be the first page user’s see when they visit http://www.example.com (we are assuming Drupal is installed in the site’s root directory). Solution: Determine the id number of the node you wish to have Drupal redirect users to. One way to determine the node’s id number is to visit the node and look at the number after the last slash in your browser’s address bar. This is your node’s id number. Now set the "Default front page" to "node/id#". So, assuming your node’s id is "83," you would type "node/83". Problem 2: You want user blogs to be the front page. Solution: Set the "Default front page" to "blog". Problem 3: You want content from a single category to appear on the front page Solution: Determine the category’s id number. You can determine the id number by going to administer » categories. Roll the mouse on top of the "edit term" link next to the category to reveal the URL in your browser’s status bar (usually located at the bottom of your browser’s window). The number after the last slash in the URL is the category’s id number. Now set the "Default front page" to "taxonomy/term/id#". If your category’s id number is "5" for example, you’d write "taxonomy/term/5".

Clean URLs

By default, Drupal passes path arguments to itself via its internally generated URLs. This results in URLs that look like the following: "http://www.example.com/?q=node/83." This can make URLs hard to read and it also stops many search engines, like Google, from indexing the pages with these URLs.

You can tell Drupal to use "clean URLs", eliminating the "?q=" in internal URLs. Note that this works only for Apache servers which have the LoadModule rewrite_module configured and mod_rewrite enabled in httpd.conf configuration file.

141 Drupal Handbook 6 Jun 2007

There are two ways to enable URL rewrites in Apache. If there is complete control of the Apache webserver clean URLs should be enabled in the httpd.conf as this has better performance and security.

Warning. Enabling "Clean URLs" if your server is not properly configured can make it difficult to navigate back to administration pages to undo your mistake. If you find yourself in this situation, you can return to the administrative settings page by typing in the URL in the ’non-clean’ form: http://www.example.com/?q=admin/settings.

Enabling clean URLs involves three steps:

1. Enable mod_rewrite for Apache. Please talk to your web host or consult the Apache documentation for mod_rewrite to get more information on how to do this. At a minimum, this will involve making sure that mod_rewrite is enabled for your installation of Apache. It will have to be either compiled-in or made available as a loadable module. Generally speaking, you can tell Apache to load the module by including LoadModule rewrite_module modules/mod_rewrite.so AddModule mod_rewrite.c

in your Apache configuration file. Be sure to uncomment AddModule mod_rewrite.c. Note that this may not be the case for all distributions of *nix operating systems. Consult your distribution’s documentation that came packaged with your Apache software. We also recommend disabling multiviews in Apache as they conflict with clean URLs.

2. Edit your Apache configuration files for your site: the configuration information may be found in httpd.conf, a virtual-host-specific file, or in an .htaccess file in your Drupal installation directory. You can find this file usually in /etc/httpd/conf/httpd.conf. You may use find /etc -name httpd to find the file if it is located else where in your Unix system. The main configuration option which may need to be changed for your site is the RewriteBase. For example, if your Apache DocumentRoot is /var/www/ (i.e., /var/www/index.html is what is displayed when you point your browser at http://www.example.com/) and your Drupal installation is installed in the subdirectory /var/www/mysite/, then the RewriteBase should be set to /mysite. In some configurations setting RewriteBase / will allow mod rewrite to work.

If you don’t use the .htaccess that comes with Drupal you’ll need to add some rewrite rules into your apache directory directive. Consult the .htaccess file in Drupal for examples of rules.

142 6 Jun 2007 Drupal Handbook

RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

You will also need to set the Allow Override settings in httpd.conf so that local .htaccess commands will be run for you site. If you are changing the .htaccess file in the Drupal distribution you want to set it to

AllowOverride All to ensure rewrites are enabled. Read "Behind the scenes with Apache’s .htacces for a thorough review of .htaccess.Here are samples of Apache 2 directives. 3. You should ensure your Drupal site has the path module enabled and the correct permissions set in order to create custom URLs. You can enable the path module in administer >> modules. You can then set permissions to administer URL aliases and create URL aliases. Enable clean URLs on your administration >> settings page. First, see if you can go to the settings page on your site using clean URLs: type in the URL http://www.example.com/admin/settings (where www.example.com is replaced by your hostname). If you get no errors and get to the same page you would have gotten to by clicking on "administer" then "settings" , then you know that you have setup the ReWriteRule rules successfully and can then click the Yes checkbox for "Clean URLs:" . If you have problem you can read the instructions to unset clean URLs. If you If you still have problems with clean URLs you can set the Drupal Settings.php $conf[’clean_url’]=1;.

Note: The standard Drupal installation contains a sample .htaccess file which supports clean URLs. It is easy to miss copying this file, because of the leading "dot".

Note Regarding MultiViews: The Apache webserver supports a feature called "MultiViews" (more generally: "Content Negotiation"), which allows navigation to your pages without the need for file extensions. For instance, if you had a file called "evaluation.txt", a MultiViews-enabled site could access this file with the URL "example.com/evaluation". While MultiViews can be a handy feature when used knowingly, they can cause problems when Drupal’s Clean URLs are enabled. Unless you know what you’re doing, you should consider disabling MultiViews if you plan to use the clean URLs feature of Drupal. Be aware that there’s a good chance that MultiViews is already disabled, however; it’s not enabled in a default Apache installation. Consult the Apache documentation for further information about MultiViews. .htaccess for clean urls on specific shared hosts zorroposada posted this .htaccess file, the use of which then allowed clean urls to be enabled when using several hosts like 1and1.com, mediatemple.net, ehostpros.com, ehosting.ca

143 Drupal Handbook 6 Jun 2007

bobdonohue reported that this .htaccess file worked on dotster.

This code was taken from the boost.module and modified just a little bit.

There is no guarantee this will work for you though.

Instructions:

Create a text file, copy and paste the code below and save it as .htaccess

Upload the file and put it in the public_html directory of your site.

Modify "RewriteBase /" in line 68 to "RewriteBase /example" if your site is in subdirectory "example."

# # Apache/PHP/Drupal settings: # # Protect files and directories from prying eyes. Order deny,allow Deny from all # Set some options. Options -Indexes Options +FollowSymLinks # Customized error messages. ErrorDocument 404 /index.php # Set the default handler. DirectoryIndex index.php # Override PHP settings. More in sites/default/settings.php # but the following cannot be changed at runtime. # PHP 4, Apache 1 php_value magic_quotes_gpc 0 php_value register_globals 0 php_value session.auto_start 0 # PHP 4, Apache 2 php_value magic_quotes_gpc 0 php_value register_globals 0 php_value session.auto_start 0 # PHP 5, Apache 1 and 2 php_value magic_quotes_gpc 0

144 6 Jun 2007 Drupal Handbook

php_value register_globals 0 php_value session.auto_start 0 # Reduce the time dynamically generated pages are cache-able. ExpiresByType text/html A1 # Various rewrite rules. RewriteEngine on # If your site can be accessed both with and without the prefix www. # you can use one of the following settings to force user to use only one option: # # If you want the site to be accessed WITH the www. only, adapt and uncomment the following: # RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC] # RewriteRule .* http://www.example.com/ [L,R=301] # # If you want the site to be accessed only WITHOUT the www. , adapt and uncomment the following: # RewriteCond %{HTTP_HOST} !^example\.com$ [NC] # RewriteRule .* http://example.com/ [L,R=301] # Modify the RewriteBase if you are using Drupal in a subdirectory and # the rewrite rules are not working properly. RewriteBase / # Rewrite old-style URLs of the form ’node.php?id=x’. #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteCond %{QUERY_STRING} ^id=([^&]+)$ #RewriteRule node.php index.php?q=node/view/%1 [L] # Rewrite old-style URLs of the form ’module.php?mod=x’. #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$ #RewriteRule module.php index.php?q=%1 [L] # Rewrite rules for static page caching provided by the Boost module # BOOST START AddCharset utf-8 .html RewriteCond %{REQUEST_URI} !^/cache RewriteCond %{REQUEST_URI} !^/user/login RewriteCond %{REQUEST_URI} !^/admin RewriteCond %{HTTP_COOKIE} !DRUPAL_UID RewriteCond %{REQUEST_METHOD} ^GET$

145 Drupal Handbook 6 Jun 2007

RewriteCond %{QUERY_STRING} ^$ RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/%{REQUEST_URI} -d RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/%{REQUEST_URI}/index.html -f RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1/index.html [L] RewriteCond %{REQUEST_URI} !^/cache RewriteCond %{REQUEST_URI} !^/user/login RewriteCond %{REQUEST_URI} !^/admin RewriteCond %{HTTP_COOKIE} !DRUPAL_UID RewriteCond %{REQUEST_METHOD} ^GET$ RewriteCond %{QUERY_STRING} ^$ RewriteCond %{DOCUMENT_ROOT}/cache/%{SERVER_NAME}/0/%{REQUEST_URI}.html -f RewriteRule ^(.*)$ cache/%{SERVER_NAME}/0/$1.html [L] # BOOST END # Rewrite current-style URLs of the form ’index.php?q=x’. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] # $Id: boosted.txt,v 1.4 2006/12/05 10:39:19 arto Exp $ 403 Permission denied error

So you’ve tried every advice above but still get the 403, "You don’t have permission to access", error when testing for clean urls. This is how I solved it after many tedious hours of googling....

Apparently there’s an option called Multiview in apache which enables the server to look for files without an extension in the parent directory of the directory you specified, if it can’t find the directory. So if you type www.mysite.com/admin/settings and it can’t find the directory it looks for a file named settings.(some extension) in www.mysite.com/admin, however if you also have directory browsing turned of and it can’t find a file it will report it as you trying to find a file in www.mysite.com/admin which you don’t have a permission to view or doesn’t exist i.e. the 403 error. To solve this you either turn of diretory browsing in your .htaccess file by writing:

Options +Indexes instead of

Options -Indexes

However if you don’t feel like having directory browsing on, I guess most people do, you just turn of Multiviews like this under the other options in your .htaccess file:

146 6 Jun 2007 Drupal Handbook

Options -MultiViews

Apache 2 configuration of clean URLs on Debian

If you’re running Apache2 on Debian stable, in order to install the rewrite module you simply need to:

# a2enmod rewrite then restart the webserver:

# /etc/init.d/apache2 restart then edit either /etc/apache2/sites-enabled/drupal or to your .htaccess and ensure it looks something like this:

# # Apache/PHP/site settings: # # Protect files and directories from prying eyes: order deny,allow deny from all # Set some options Options -Indexes Options +FollowSymLinks # Customized server error messages: ErrorDocument 404 /index.php # Set the default handler to index.php: DirectoryIndex index.php # Overload PHP variables: # If you are using Apache 2, you have to use # instead of . php_value register_globals 0 php_value track_vars 1 php_value short_open_tag 1 php_value magic_quotes_gpc 0 php_value magic_quotes_runtime 0 php_value magic_quotes_sybase 0 php_value arg_separator.output "&" php_value session.cache_expire 200000 php_value session.gc_maxlifetime 200000 php_value session.cookie_lifetime 2000000 php_value session.auto_start 0

147 Drupal Handbook 6 Jun 2007

php_value session.save_handler user php_value session.cache_limiter none php_value allow_call_time_pass_reference On # Various rewrite rules RewriteEngine on Options All # Modify the RewriteBase if you are using Drupal in a subdirectory and the # rewrite rules are not working properly: RewriteBase /drupal # Rewrite old-style URLS of the form ’node.php?id=x’: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{QUERY_STRING} ^id=([^&]+)$ RewriteRule node.php index.php?q=node/view/%1 [L] # Rewrite old-style URLs of the form ’module.php?mod=x’: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{QUERY_STRING} ^mod=([^&]+)$ RewriteRule module.php index.php?q=%1 [L] # Rewrite URLs of the form ’index.php?q=x’: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] # $Id: .htaccess,v 1.58 2004/10/09 20:41:49 dries Exp $

This is because the debian package installs the drupal "sites-enabled" virtual host, result being that drupal is accessed from http://yourhost.com/drupal, hence the need to uncomment RewriteBase. Change it to the base that corresponds to your system. ref: http://www.debian-administration.org/articles/136 http://drupal.org/node/14322

-- Sean K. O’Brien CTO Colley Graphics, LLC http://www.colleygraphics.com

148 6 Jun 2007 Drupal Handbook

Apache 2 on Ubuntu

Two methods here:

Editing apache2.conf

First thing to do is make sure you have apache up and running: /etc/init.d/apache2 start

Then you have to enabled the rewrite module(mod_rewrite). You no longer have to do the: LoadModule rewrite_module modules/mod_rewrite.so AddModule mod_rewrite.c

It’s now as easy as: a2enmod rewrite

To disable this module it’s just: a2dismod rewrite with Apache version 2, the httpd.conf has been depreciated and the new file is located at: /etc/apache2/apache2.conf in this file you need to add your directory and the allow override to give access to your drupal site. so look for a section in your apache2.conf that has Directory tags and just add another section:

AllowOverride all

*keep in mind that my website is in a subdirectory (drupal_website_install) and so you may need to edit the above to reflect this. By this I mean if i go into my webbrowser I need to go to http://localhost/drupal_website_install/

After you edit you apache2.conf as listed above you need to restart the server by: /etc/init.d/apache2 restart

If you are having problems with getting your rewrite to work you can always use logging. To do that add this to the end of you apache2.conf:

RewriteLog "/var/log/apache2/rewrite.log" RewriteLogLevel 3

Level 0 is no logging Level 9 is log everything You can pick the level to determine the amount of output you need. ***Security Warning: Make sure to take the log code out, disable it, or put the log file in a directory that can’t be read by normal users (as shown above) otherwise it can result in a security breach.***

149 Drupal Handbook 6 Jun 2007

hopefulley this helps some people and saves them the time that I spent trying to get it working.

Editing apache2/sites-available

My configuration: drupal 5.x apache 2.2 mysql 5.0 debian/ubuntu server install drupal path: /www/drupal/sites/site1...site2

I have root access to my server.

First, from the linux command line, I enabled the rewrite module for apache like this: a2enmod rewrite

Next I restarted Apache: sudo /etc/init.d/apache2 restart

Then I reloaded Apache config files: sudo /etc/init.d/apache2 reload

Finally, I changed the file located at:

/etc/apache2/sites-available/default

(in the sites-available directory, you should see as many files as you have websites enabled. One is named default and the others should reflect the names of your additional sites if you are running virtual hosts. If you have only a single site, it will most likely be named default. You can open these files in an editor such as nano and make changes.) change this directive in the file(s) found in sites-available:

AllowOverride None to AllowOverride All

Save this file and then restart apache as we did above.

Now browse to your site with your browser, login, click administer, find "Clean URLs" and browse to that page, run the test for "Clean URLs" buried in the paragraph explaining "clean Urls".

If your setup is like mine, you should now have Clean URLs in drupal.

150 6 Jun 2007 Drupal Handbook

Clean URL Support in Abyss

This clean URL implementation has been tested on Abyss X1, one which has a properly set Custom Error Page 404 to any arbitrary file that, for this purpose, will be referenced as "/url_rewrite.php". Due to the generalized design of this solution, this method could theoretically work on virtually any webserver that can redirect missing URI location onto a php resource. The method described here works only on webservers with a singular host configuration.

One esoteric requirement is for the webserver to pass the server variable REQUEST_URI containing the value of the original resource requested. For more information on configuring Abyss X1 for this purpose, please visit this Aprelium forum resource.

This solution could be rendered academic if Aprelium finally decides to implement URL rewrite in Abyss internally. This method is useful for Abyss webservers version 2.3.2 and most other versions prior to this specific release. Another drawback is that the URL rewrite becomes only invisible to the machine but is always visible to the human.

The idea is to pass (or redirect) the missing URI location on the HTTP-404 handler "/url_rewrite.php". For illustrative examples, let’s look at the following scenarios:

1. http://www.example.com/node/add => "/node/add" not found, pass to 404 handler "/url_rewrite.php" => "/url_rewrite.php" determines "/index.php?q=node/add" exists and serves that instead. 2. http://www.example.com/admin/settings => "/admin/settings" not found, pass to 404 handler "/url_rewrite.php" => "/url_rewrite.php" determines "/index.php?q=admin/settings" exists and serves that instead. 3. http://www.example.com/no_exist/location => "/no_exist/location" not found, pass to 404 handler "/url_rewrite.php" => "/url_rewrite.php" determines "/index.php?q=no_exist/location" exists and serves that instead but lets Drupal display the proper "page not found" informational message.

Here are the steps in letting this method apply to your setup.

1. Create the following file and save it as "/url_rewrite.php". new path) pairs */ $redirection = array( ’^(.*)$’ => ’index.php?q=$1’ ); if (!file_exists($_SERVER["REQUEST_URI"])) /* Get the URI and trim leading slashes */ $uri = ltrim($_SERVER["REQUEST_URI"], "/"); { foreach ($redirection as $key => $value) { if (eregi($key, $uri))

151 Drupal Handbook 6 Jun 2007

{ /* Convert the replacement string syntax - $1 -> \1 */ /* and perform the substitution */ $uri = str_replace("index.php","",substr($uri,0)); $new_uri = str_replace("?","&",$uri); $new_uri = "/index.php?q=".$new_uri; $new_uri = str_replace("%26","&",$new_uri); break; } } } if (isset($new_uri)) { header("Status: 307"); header("Location: $new_uri"); exit; } ?> Not Found The object is not available. 2. In the Abyss web console, enter the Custom Error Pages, add a 404 Status Code entry with the Associated URL value "/url_rewrite.php". Click OK and restart the Abyss webserver. 3. Test for functionality by querying your website directly with URI’s such as: http://www.example.com/admin/settings http://www.example.com/node/add

If the redirection works properly, proceed to the next steps. If the redirection would not work, check if the steps above have been strictly followed. Modify only those things that you have absolute knowledge of.

4. Log on to your website and log on to your "/admin/settings" page. Under General Settings section, enable Clean URLs. If the Clean URLs option is grayed out, add the line "$conf[’clean_url’] = 1;" in your settings.php, then repeat this step. Don’t forget to click the "Save configuration" button. 5. If things do not work out, completely remove the line "$conf[’clean_url’] = 1;" from your settings.php. And browse to your http://www.example.com/index.php?q=admin/settings page to disable Clean URLs properly.

152 6 Jun 2007 Drupal Handbook

Clean URL support in XAMPP

Clean URLs do not work out of the box on XAMPP 1.5.x with PHP4 due to a problem in Apache’s module load order; mod_rewrite will not work properly. To remedy this edit the file [path_to_xampp]/apache/conf/httpd.conf.

Move the line

LoadModule rewrite_module modules/mod_rewrite.so to just above or below #LoadModule cache_module modules/mod_cache.so

You also have to set AllowOverride All for the directory Drupal is in. Do this in httpd.conf or extra/httpd-xampp.conf

Always restart Apache or changes to its configuration files won’t have an effect.

If Drupal is not installed in the document root, the next thing you’ll have to do is to modify the file .htaccess, that comes with Drupal. Remove the commentsign (#) in front of RewriteBase and, if necessary, modify the path:

RewriteBase /drupal

Finally, in Drupal go to administer » settings (admin/settings) and click the "Enabled" option for Clean URLs and save the settings. Clean URLs in Mac OS X Server

For Mac OS X Server 10.4 (Tiger Server) and most likely previous versions as well, do not make changes to /etc/httpd/httpd.conf expecting the AllowOverride All directive to work. The correct file to add the AllowOverride All directive is in the directory /etc/httpd/sites/. In that directory are the virtual host configuration files. Each virtual server has a configuration file in that directory so it is in those files that you must enable AllowOverride All. If you only have one web server on your server configured, then the file you want to modify is /etc/httpd/sites/0000_any_80_.conf. Clean URLs with different webservers Microsoft Internet Services Server

Windows ISS MySQL PHP(WIMP)-Tips for Configuring Drupal on WIMP

Lighttpd

For those who have stepped up a notch in performance and moved from Apache to Lighttpd, you can use the following configuration for Lighty’s mod_rewrite module:

153 Drupal Handbook 6 Jun 2007

url.rewrite-final = ( "^/system/test/(.*)$" => "/index.php?q=system/test/$1", "^/([^.?]*)\?(.*)$" => "/index.php?q=$1&$2", "^/([^.?]*)$" => "/index.php?q=$1" )

The first line ensures that Drupal’s clean URL check (when saving Settings) succeeds (Drupal makes an HTTP request for a path of the form /system/test/yLgnwqqUu5cWnvPi4Hrz.png). It’s a special case that must be handled separately (read on for the reason).

The two following lines let Drupal handle any URL that doesn’t contain a dot. This is significant because we can assume, fairly confidently, that addresses like /node/add are Drupal URLs, but addresses such as /themes/bluemarine/style.css are physical files. So the above configuration will work for all cases where this assumption holds true; if there are exceptions to the rule, they can be manually added to the rewrite configuration.

See also the related discussion at http://drupal.org/node/20766

I just successfully set up lighttpd 1.4.8 with php4 via fastcgi using those rules above. As per lighttpd documentation I also set up /etc/php4/cgi/php.ini to have that cgi fix. Then I added those rewrite rules for corresponding virtual_host.

Ubuntu breezy’s php4-cgi package bougyman’s lighttpd package (see http://www.lighttpd.net/download/ for details) Clean URLs with Easyphp.

To get that the clear URLs works in Easyphp 1.8 you have to join the httpd.conf file and change this two lines:

#LoadModule rewrite_module modules/mod_rewrite.so and

#AddModule mod_rewrite.c and leave like this in the same line.

LoadModule rewrite_module modules/mod_rewrite.so y

AddModule mod_rewrite.c and Re-start the server.

Easyphp have the mod_rewrite within.

154 6 Jun 2007 Drupal Handbook

If there is any problem tell me.

Oskar Calvo. Example Clean URL configuration of httpd.conf for performance

This was tested and applies to FC4/php5/Apache 2.0.54.

Enabling .htaccess in Apache requires more work on the part of the server. A full explanation can be found here: http://www.serverwatch.com/tutorials/article.php/3436911 Suffice it to say that it is in your interest to not use .htaccess files and even disable them if you are concerned about squeezing more performance out of apache.

I moved the rewrite rules (all of the sample .htaccess file really) to /etc/httpd/conf/drupal.conf. Then for each virtual host, one can add the line:

Include conf/drupal.conf The rewrite rules change slightly: # Rewrite current-style URLs of the form ’index.php?q=x’. RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

Note that I added %{DOCUMENT_ROOT} and a leading slash in front of index.php -- because I have index.php installed in my document root. If you install it in another directory, you will want to give the relative path to it from document root with the leading slash.

Important: If you forget the leading slash (more specifically, forget to give the relative path with leading slash), Apache will give you a "400 Bad Request" error.

This is better. But we still have a problem where every request will check for the existence of a file and a directory before we apply the rewrite rule. The OS may be able to cache some of that information, but it would still be better to avoid the two file-system checks in the first place.

There are some directories that we should not rewrite. And there are certain extensions that we should not rewrite. Using this information, we can update the rewrite rule to send everything to index.php that does not fall into this category. The first rule excludes the directories "files", "misc", and "uploads". The second rule excludes the extensions you see. Add more if you have other extensions in your directory that should not get passed to index.php.

RewriteCond %{REQUEST_FILENAME} !^/$ RewriteCond %{REQUEST_FILENAME} !^/(files|misc|uploads)(/.*)? RewriteCond %{REQUEST_FILENAME} !\.(php|ico|png|jpg|gif|css|js|html?)(\W.*)? RewriteRule ^(.*)$ /index.php?q=$1 [L,QSA]

155 Drupal Handbook 6 Jun 2007

Existing URLs for server overwrite Drupal paths

If your server has existing paths like /admin then you can either move your Drupal instance to a subdirectory like /home/admin or you can create a virtual link to ?=admin. IIS CleanURLs using some of the available ISAPI filters.

There is a free version called ISAPI_Rewrite Lite that should get clean URLs working for IIS. Install that and insert these rewrite rules.

# Accept a url with the following extensions and pass them through unchanged. RewriteRule (.*.gif|.*.png|.*.jpg|.*.pdf|.*.js|.*.css) $1 [I,L] # Make URLs sane RewriteRule /index.php.* $0 [I,L] RewriteRule /(.*)\?(.*) /index.php\?q=$1&$2 [I,L] RewriteRule /(.*) /index.php\?q=$1 [I,L]

Next, add the following line to the end of your settings.php file for your site:

$conf[’clean_url’] = 1;

Translating Apache’s rewrite rules

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d

In plain English: If the REQUEST_FILENAME variable does not exist (not an existing file and not an existing directory) then apply the rule: RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]"

After much research this exact functionalty does not appear to exist in any ISAPI module for IIS. I think the following solution will help solve this issue. It probably works with most "ISAPI rewrite" modules (they just need the "stop the rewriting process" option).

With this approach you basically revert the "Apache Rewrite" logic. First define rules for known files/folders (like /themes/ ..etc..). Have those "matching rules" exit, so rules processing stops before going to the next rule. With mod_rewrite.dll you can do that with the option [l].

Here is what my rules file looks (so far) like (using mod_rewrite.dll): RewriteRule ^/index.php\?q\=(.*)$ /index.php?q=$1 [l] RewriteRule ^/themes/(.*)$ /themes/$1 [l] RewriteRule ^/misc/(.*)$ /misc/$1 [l] RewriteRule ^/(.*)$ /index.php?q=$1 [l]

Remember, you have to add an "exiting" rule for all known folders/files before hitting the final rule. The first rule is to avoid recursion and exit immediatly if the URL already has index.php?q=.

156 6 Jun 2007 Drupal Handbook

To better understand the Apache rules here are the definitions of the main options: ’last|L’ (last rule) Stop the rewriting process here and don’t apply any more rewriting rules. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules.

’qsappend|QSA’ (query string append) This flag forces the rewriting engine to append a query string part in the substitution string to the existing one instead of replacing it. Use this when you want to add more data to the query string via a rewrite rule.

REQUEST_FILENAME The full local filesystem path to the file or script matching the request.

’-d’ (is directory) Treats the TestString as a pathname and tests if it exists and is a directory. ’-f’ (is regular file) Treats the TestString as a pathname and tests if it exists and is a regular file.

Note: Getting Apache running on MS Windows is not that bad (I had been delaying it for years). In reality it’s a matter of a few hours to get going. http://www.sitebuddy.com aims to save you time in that endeavor. Setting up clean URLs above web document root on virtual private servers

To set up clean URLs above web document root on virtual private servers, you need to change a setting in httpd.conf.

(default setting) Options FollowSymLinks AllowOverride None

Change it to Options FollowSymLinks AllowOverride All

None of the other changes discussed in this section of the handbook were necessary (and in fact had to be undone).

The hosting provide said this does not provide any security issues (no guarantees). reboot vps after making change

This is excellent advice. I installed a test site at /var/www/test. My live site is at /var/www/html. The live site worked fine. In the test site i went to set clean url’s and got an apache error.

157 Drupal Handbook 6 Jun 2007

This fixed it.

One minor note. I had to reset the vps before the changes took affect. With my hosting company this is simply a menu selection in their control panel, so if you have this setup and make the change and it does not work.

Ask your provider to reset your Virtual Private Server. This is simular to stopping and starting Apache on a Windows install. Using Clean URLs with IIS

Drupal can display brief, pretty URLs like those at drupal.org. For Apache sites, mod_rewrite powers this feature. For IIS, you will use a custom error handler for this. You probably want to disable logging in IIS, since every page view is considered an error using this technique.

make sure your Drupal is working well without clean urls enabled. open your Internet Services Manager or MMC and browse to the root directory of the web site where you installed Drupal. You cannot just browse to a subdirectory if you happenned to install to a subdirectory. right click and select properties -> custom errors tab set the HTTP Error 404 and 405 lines to MessageType=URL, URL=/index.php. If you are using Drupal in a subdirectory, prepend your subdir before /index.php paste the following code into the bottom of settings.php file, which is usually located under sites/default/. the first two lines should be edited. If you aren’t using a subdirectory, set $sub_directory to "". then set $active=1 and enjoy!

158 6 Jun 2007 Drupal Handbook

$_GET = array_merge($_GET, $arr); $_REQUEST = array_merge($_REQUEST, $arr); } } ?> at this point, you should be able to request clean url pages and receive a proper page in response. for example, request the page /node/1 and hopefully you will see your first node shown. you should not use the q= syntax; use the clean url syntax. if you get an IIS error, you have a problem. please fix redo the above and then retest. browse to index.php?q=admin/system, enable clean URLS, and press Submit. you may get a php error if your php error reporting in your php.ini file is set to high. Try this setting in your php.ini file

error_reporting = E_ALL & ~E_NOTICE

Note: This method seems to work for IIS5 but not IIS6. Check this thread for some approaches using ISAPI_Rewrite.

Alternate method

Alternatively, you can use ISAPI Rewrite by Helicon software to add mod_rewrite-like functionality to IIS: www.isapirewrite.com set your sites 403 and 404 Error pages

Drupal’s page error messages are meant to be direct and to the point. If you want page error messages that are a little more user-friendly, Drupal allows you to customize them. Just follow these steps:

1. Create two nodes, one for each kind of page error (403 and 404). 2. Determine the id number of the node you wish to have Drupal redirect users to. One way to determine the node’s id number is to visit the node and look at the number after the last slash in your browser’s address bar. This is your node’s id number. 3. Now enter the paths to your nodes into the appropriate boxes. For example, if the node id number for 403 error codes is "83," you would type "node/83" into the "Default 403 (access denied) page" setting.

Because you are creating nodes for this, they will show up in the tracker and popular content blocks and anywhere else real nodes would show up. If this isn’t acceptable, there is a contributed module called Custom Error that avoids this problem.

159 Drupal Handbook 6 Jun 2007

Configure your sites error reporting

Where Drupal, PHP and SQL errors are logged. On a production server it is recommended that errors are only written to the error log. On a test server it can be helpful to write logs to the screen. By default, errors are displayed to the screen. You should change this to ’Write errors only to log’ only for your production site.

You can tell Drupal to automatically discard error log entries older than the age you specify. This requires a crontab (yoursite.com/cron.php) to be set up. See step 6 of the install.txt for example of setup.

Cache support

Busy Drupal sites may want to consider caching their pages to lighten the load on their server and speed up page generation times.

Normally, every time you visit a Drupal page, Drupal makes dozens of queries to the database to pull out the data needed to generate the HTML that your web-browser renders. On a large site with many modules installed or with lots of content on a page, the number of queries per page could rise into the hundreds. Usually, you don’t notice all the work Drupal does because computers are very fast and Drupal is very efficient. However, on very busy sites with many hundreds or thousands of page views per minute, the amount of work required to serve each page may start to slowing the server to a crawl.

Busy sites can reduce the work required to generate pages by enabling Drupal’s page cache.

With the cache turned on, Drupal stores all the HTML code for any page visited by an anonymous user directly into the database. When another request for the same page comes along, Drupal knows to fetch this page out of the database rather than re-generating it from scratch. The result is that hundreds of queries are replaced with one single query, thereby significantly lightening the load on the web server.

Primary and secondary links General Information:

In versions 4.6 and below, primary and secondary links were handled in the theme administration.

As of 4.7, primary and secondary links have been incorporated into the menu system. To have primary and secondary links in your theme, you make them menu items. A fresh Drupal 4.7 install comes with an empty menu called "Primary Links" that is set to be used to display both the primary and secondary links.

160 6 Jun 2007 Drupal Handbook

Setting Up Your Primary and Secondary Links:

There are two configuration screens that deal with these links:

On admin >> settings >> menu you choose which menu is used for the primary links and which for the secondary links. If you have added items to the default "Primary Links" menu and they are not showing up, check to make sure the option on this page hasn’t been changed to "No Primary Links".

On admin >> menu you will find the default "Primary Links" menu and you should add your links to that. You can also create a menu to hold the secondary links or create a different menu for the primary links. Be sure to change the options on admin >> settings >> menu to use the correct menu(s). Theming Your Link Menus

You can display your links in two ways:

1) You can add the menu block to a region just like any other menu. 2) You can insert this code where you want the links to show up:

You can then use CSS to theme your DIVs however you like.

Set length of trimmed posts and # of posts on front page admin >> settings >> post

Here you can set the number of posts on main page and the length of trimmed posts. You also set whether previewing posts is optional or required.

URL Alias Optimization

Drupal 6.0 implements a new feature to enhance site-performance: a whitelist/blacklist for URL alias lookups. Database queries to find url aliases created by the path module are among the most frequent in many Drupal installations. The performance setting allows administrators to either define paths which will no be looked up (blacklist), or paths which will (whitelist).

Similar to the block visibility settings, you can use the * wildcard to define ranges of URLs.

The blacklist comes with a set of useful default urls. For many sites, enabling the blacklist will reduce the number of overall queries to the database without degrading any functionality. However, if you make extensive use of URL aliases, you should think about what settings work

161 Drupal Handbook 6 Jun 2007

best for you. If you have a small number of aliases, setting them up as a whitelist may be even better.

File system settings

Drupal provides configuration settings to control whether, and how, users and administrators can upload files for use by Drupal.

Note: Unconfigured or improperly configured Drupal installations may display one or more error message at the top of the "settings" page, indicating that either the "Temporary directory" or "File system path" directories do not exist and/or their permissions are not set properly. Simply create these directories and set their permissions so that Drupal can write and read from the directory.

If you are unsure about where or how to create these directories or how to change their permissions, contact your web hosting service or software documentation for further assistance. Download method

Download settings are configured in Administer >> Settings >> File system

There are two possible settings for download method: Public and Private.

Set to Public if you don’t care if any user, even anonymous users, can download the files uploaded by other users.

Set to Private if you wish to restrict the ability of some users to download files uploaded by other users.

Please note that if you set your download method as private, you should set your "files" directory to be outside the document root for your drupal installation (i.e. not in your_drupal_site/files or your_drupal/site/sites/all/files). The private download method also has performance implications which you may want to consider.

If you change your settings at a later date, all download urls will change, therefore it’s best to plan ahead when you set your drupal site up and think carefully about whether you’ll need to restrict file downloads. If that’s the case we strongly recommend setting the file download method to private when you first create your site to avoid broken links later on. If your download method is set as private, all users will still be able to download files until you set otherwise. Path settings

File system path By default, this is set to "files". We recommend leaving this setting alone.

162 6 Jun 2007 Drupal Handbook

Temporary directory By default this is set to "/tmp" which is the temporary directory common in GNU/Linux distributions. If you are using a Windows or other kind of server, we recommend setting it to "tmp" (no slash). Drupal will automatically create the temporary directory as a subdirectoy of the "File system path."

If it does not due to permissions or other configuration issue’s, you can create the file manually.

Date and time settings

Drupal allows you to configure how dates and times are formatted and displayed. When making the format settings, you should probably consider the culture of your target audience. Below are suggested configurations for the "Default time zone" and "Configurable time zones" options.

For sites where most users live in a small geographic region: Set the "Default time zone" to the time zone of the region and disable configurable time zones.

For sites where most users live a region that spans a few time zones: Set the "Default time zone" to the time zone usually considered to be the "standard" time zone and disable configurable time zones. For example, in the United States, you’d set your site’s time to the timezone that corresponds to Eastern Standard Time.

For sites where users are likely to be scattered across the globe: Set the "Default time zone" to the time zone to GMT (+0000) and enable configurable time zones.

Customizing the interface

When launching a new drupal site, here are some things you can do to personalize the design and architecture of your drupal site.

Choose a Theme.

The look and feel of Drupal is primarily controlled by the theme you have applied to your site. A site can even have multiple themes. A good first step is to go to administer > themes and set a new theme as your default. You can find more themes on the download page after the list of modules. Once you download a new theme you will need to install it on your system.

Create your own Theme.

Many Drupal sites will need a more unique look than these pre-built themes can offer. Therefore, many developers will want to write their own themes. Theme development requires a working knowledge of HTML/CSS and possibly some rudimentary PHP depending on the complexity of your theme.

163 Drupal Handbook 6 Jun 2007

Customize the Navigation.

The menus that are displayed on the top and bottom of the page are configured in administer > themes. Select the configure tab and scroll down to Menu Settings. The primary and secondary links can be defined here, using straight HTML. If the primary links are left blank your navigation will be created based on your installed modules.

Each theme has an individual configuration page (listed at the top of the global settings page) as well. Unfortunately, in Drupal 4.6 and previous using PHPTemplate your navigation must be defined in that theme’s individual theme area.

In 4.7 PHPTemplate engine is incorporated into the Drupal core and the Primary and Secondary links are now part of the menu system. Mention of this can be found here.

Customize Text Strings

You can also change the text strings throughout drupal using the locale feature, which was designed for running drupal in different languages, you can personalize almost all of the text in drupal.

In fact, you can replace a string like "create blog entry" with html markup such as references to graphics.

Customizing user login

In the default setup the Drupal login block is always displayed unless a user is logged in. This may not always be desirable. For example, if you are using Drupal to create a site that has a very small number of people actually logging into the system to create or edit content, then you probably don’t want a large portion of your screen real-estate taken up with a login block that doesn’t relate to them. This also confuses the majority of your users that will not have the option to login.

To disable the login block:

1. Goto the block configuration (administer » blocks) 2. Deselect the check box for User login in the Enabled column

Your regular content editors and administrators can still login to the site by directly accessing the login page, http://www.example.com/?q=user. If you are using clean URLs you may also use http://www.example.com/user, but remember that the ?q=user version will always work whether you have clean URLs enabled or not.

You can also create more customized login blocks.

You can create name and email filter rules in admin >> access control >> account rules.

164 6 Jun 2007 Drupal Handbook

Set up username and e-mail address access rules for new accounts. If a username or email address for a new account matches any deny rule, but not an allow rule, then the new account will not be allowed to be created.

Beginner’s guide for Cron on a shared hosting provider

This guide is excerpted from the original article on ThemeBot.com: Time to talk about Cron - a beginner’s guide

If you have downloaded and installed Drupal 5, you will notice that there is an error in the administrative log when you first sign in with your administrative account.

One or more problems were detected with your Drupal installation. Check the status report for more information.

When you look at the status report you can go ahead and click the link "run cron manually" and this will remove the error. However, you will eventually want to set up a Cron job to do this. Having the Cron maintenance run regularly on an automatic schedule is important for keeping your site indexed. If this is not done, new content that is added will not be included in search results. Cron can also perform other tasks in Drupal, such as cleaning up log files. Also, some of the contributed modules require that Cron maintenance is run regularly.

With the Drupal 5 installation package, there is a script included for Cron and it is called cron.php. This file is located in the root directory of your Drupal installation. You can actually run Cron maintenance by entering, for example, the URL "http://www.yourwebsite.com/cron.php" into a web browser. But we want to get this done automatically, so we need to call on the help of the Lynx browser. Lynx is a text browser that is often installed on servers. You will need to contact your hosting provider to make sure that they have Lynx installed (most probably do).

Once you know that Lynx is installed, you will need to find the configuration panel for setting up a Cron job in your hosting account.

The first thing to do is enter the command. The following example is the command I use to make Lynx run cron.php: lynx -source http://www.yourwebsite.com/cron.php

You may need to adjust this command depending on your hosting provider.

The next step is to decide on a schedule to have this Cron job run. Running Cron does use system resources, so you don’t want to have it running every minute if you don’t need to. It is up to you to decide on an appropriate schedule for having each Cron job run. Understanding the format for entering a schedule can take a little getting used to. Here is a quick rundown on scheduling options that can be entered:

165 Drupal Handbook 6 Jun 2007

Minute â any integer from 00 to 59 (specifies the minute the job will be run on) Hour â any integer from 0 to 23 (specifies the hour the job will be run on) Day â any integer from 1 to 31 (must be a valid day if a month is specified) Month â any integer from 1 to 12 Weekday â any integer from 0 to 7, where 0 or 7 represents Sunday

The asterik (*) specifies that the task should be run every time for any sub-constraint. This statement doesn’t even make sense to me so let’s just have a look at the examples to figure it out. You can also use the command */ to have jobs run every interval. Here the examples to help you get the hang of it.

Run cron.php task every 30 minutes:

*/30 * * * * lynx -source http://www.yourwebsite.com/cron.php

Run cron.php task once a week at 1:00 am every saturday (you can see that saturday is represented by 0):

00 1 * * 0 lynx -source http://www.yourwebsite.com/cron.php

Run cron.php task on the first day of every month at 12:00 am (midnight) :

00 0 01 * * lynx -source http://www.yourwebsite.com/cron.php

I hope this is helpful for beginners who have installed Drupal and are wondering how to setup Cron.

Check your filters

Drupal input filters are a little known but powerful feature. They can give a site administrator a lot of control over the input of their site. Some contributed modules add filters here to control content display and link behavior.

In the Navigation menu, select administer / input formats. (?q=admin/filters)

Configure user registration

Configure the user registration options for your site (?q=admin/user/configure). The three options for your Drupal based site are listed here.

Only site administrators can create new user accounts. Visitors can create accounts and no administrator approval is required. Visitors can create accounts but administrator approval is required.

166 6 Jun 2007 Drupal Handbook

If you allow user registration, take the time to customize the message to something appropriate to your site and community. User picture support is also enabled/disabled here and relies on the theme to have support for it.

These settings can be found in admin >> users >> configure in Drupal 4.6.

These settings can be found in admin >> settings >> users in Drupal 4.7.

Some sites may want to establish rules for user names, or block registration from certain email domains. This can be done through the Account Rules tab in admin >> access control(?q=admin/access/rules).

Set up username and e-mail address access rules for new accounts. If a username or email address for a new account matches any deny rule, but not an allow rule, then the new account will not be allowed to be created.

There is allowance for wildcards as well.

%: Matches any number of characters, even zero characters. _: Matches exactly one character.

For example a rule of

%- :would prevent any user names ending in a dash w_rd :would prevent any combination or w any 2nd character and rd

%: Matches any number of characters, even zero characters. _: Matches exactly one character.

There is also a checking tool to check the effect of your rules.

Creating a menu structure

Drupal comes with a menu module that allows you to create infinitely nested menu trees. You can activate this module at administer > modules if you can’t see the menu item labeled "menu" in the "administer" menu.

A screencast of building a basic site navigation system using menu module is also available for Drupal 4.7 users.

Creating a menu

1. To add a new menu, go to the menu module’s page at administer > menus. Click on "add menu" and supply a title for your new navigation. If it is the main navigation, simply call it "Main navigation" or "Default menu" or whatever you find appropriate.

167 Drupal Handbook 6 Jun 2007

2. Now that you have created your menu, enable it on the administer > blocks page checking the "Enabled" checkbox after the menu name that you entered in step one. You can also change the region and the weight of the menu. This affects where the menu is placed on the page. For a detailed description of what are blocks and how to use them, consult the block module’s handbook page. After having enabled the block, you should see an empty section on the side that has the title you supplied for the menu.

3. Create menu entries. This can be done by going back to the menu module’s page and clicking on "create menu item". Now you can enter a title for the new menu item, supply a short description, define its path (for a detailed description on paths or url aliases, consult the path.module’s handbook page). Select the parent for the menu item. That means, you can select under which navigation item your new menu item is filed. Selecting the item with the same title as your menu’s title means that the new item is a top level item. Select the weight. This defines at which position the menu item is. A lower weight means that the item "floats" above items with "heavier" weight.

You can also create multiple menu items for one node. This allows you to find the node on more than one place. But generally your visitors get only confused if they can find the same content on multiple places, so use this feature carefully and only when it’s appropriate.

Simplifying the workflow

In Drupal version 4.6.x, always having to go to the menu module page is sometimes annoying if you just want to quickly add a page to your site. For this purpose, the Menu-on-the-fly module has been created. It adds a section on every create content that allows you to create a new menu item along with the node quasi on the fly (as the module’s name indicates). This functionality is built into the core menu module in 4.7.x

Helping search engines and robots.txt

Drupal by itself is very search engine friendly. For example it is not uncommon for Drupal based sites to have have a Google ranking of 5 or higher (out of 10) where using the same content on another CMS would score much lower.

Still, you can make Drupal even more search engine friendly by changing some default parameters. There are several Drupal settings you can tweak to make Drupal even more search engine friendly.

1. First of all you might want to enable friendly URL’s 2. Then, make sure that you get rid of the session ID in the URL by changing the .htaccess if you are using version 4.5.x. On 4.6, session IDs in URLs are disabled by default. 3. Optionally, use URL aliasing for some or all nodes. You can use the pathauto module to automatically create aliases for new nodes.

168 6 Jun 2007 Drupal Handbook

Controlling what gets indexed -- the robots.txt file

The robots.txt file is the mechanism almost all search engines use to allow website administrators to tell the bots what they would like indexed.

A robots.txt is included with Drupal 5.x. Drupal 4.x does not come with a robots.txt file.

By adding this file to the root of your (virtual) webserver, you can quide the search engines’ "bots" through your site or forbid indexing parts of your site. See for an example the file for drupal.org itself at http://drupal.org/robots.txt.

If you want to have a robots.txt file, please follow the instructions below. For more details check http://www.robotstxt.org

Create a file with the content as shown below and call it "robots.txt"

# small robots.txt # more information about this file can be found at # http://www.robotstxt.org/wc/robots.html # lines beginning with the pund ("#") sign are comments and can be deleted. # if case your drupal site is in a directory # lower than your docroot (e.g. /drupal) # please add this before the /-es below # to stop a polite robot indexing an exampledir # add a line like (delte the #’s) # user-agent: polite-bot # Disallow: /exampledir/ # a list of know bots can be found at # http://www.robotstxt.org/wc/active/html/index.html # see http://www.sxw.org.uk/computing/robots/check.html # for syntax checking User-agent: * Crawl-Delay: 10 Disallow: /aggregator Disallow: /tracker Disallow: /comment/reply Disallow: /node/add Disallow: /user Disallow: /files Disallow: /search Disallow: /book/print

This file tells indexing robots that they should avoid pages that contain content for users only, for example the search page, or the ’Add a comment’ forms for nodes.

169 Drupal Handbook 6 Jun 2007

Many robots obey the "Crawl-delay:" parameter. Since Drupal sites seem to be popular with search engines and lots of people have more aggresive bots than visitors at their site, it might be wise to slow down the robots by adding a robots.txt line like this:

User-Agent: * Crawl-Delay: 10

Here 10 is the delay in seconds between page requests.

Both "Slurp" (The robot that is indexing for yahoo and altaVista) and the Microsoft robots for the MSN sites obey this parameter. Googlebot does not use the "crawl-delay" parameter yet but will likely do so in an upcoming version.

Change the file as you wish and save it. Now upload it to your webserver and make sure it is in the root of the (virtual) webserver. If you have installed Drupal in a subdirectory (for example /drupal), then change the URL’s in the robots.txt file but place the file in the root of the webserver, not in the root of your drupal instalation.

Now watch the robots visit your site and after some time, monitor your log files ("referrer log") to see how many visitors came from a search engine. Add ’Disallow: /node/’ if your setup has aliases for all nodes

If your Drupal setup has aliases for all nodes (mostly happens when you use path and pathauto both) then add Disallow: /node/ to your robots.txt. Nodes with aliases are accessible from 2 URIs: the default URI and the aliased URI. Search engine bots will discover both over a period of time and this might lead to penalisation for duplicate content as well as twice as much crawling as is really required.

I learnt this the hard way. It is best to do this when the site is new. Selective Bot Crawling here’s a copy of my robots.txt file:

# AllTheWeb User-agent: fast-webcrawler Crawl-Delay: 10 Disallow: /aggregator Disallow: /tracker Disallow: /comment/reply Disallow: /node/add Disallow: /user Disallow: /files Disallow: /search Disallow: /book/print Disallow: /admin Disallow: /cron.php

170 6 Jun 2007 Drupal Handbook

Disallow: /xmlrpc.php Disallow: /database/ Disallow: /images/ Disallow: /includes/ Disallow: /modules/ Disallow: /scripts/ Disallow: /themes/ Disallow: /email_disclaimer Disallow: /privacy_policy Disallow: */add/ # AltaVista User-agent: scooter Crawl-Delay: 10 Disallow: /aggregator Disallow: /tracker Disallow: /comment/reply Disallow: /node/add Disallow: /user Disallow: /files Disallow: /search Disallow: /book/print Disallow: /admin Disallow: /cron.php Disallow: /xmlrpc.php Disallow: /database/ Disallow: /images/ Disallow: /includes/ Disallow: /modules/ Disallow: /scripts/ Disallow: /themes/ Disallow: /email_disclaimer Disallow: /privacy_policy Disallow: */add/ # Googlebot User-agent: googlebot Crawl-Delay: 10 Disallow: /aggregator Disallow: /tracker Disallow: /comment/reply Disallow: /node/add Disallow: /user Disallow: /files Disallow: /search Disallow: /book/print Disallow: /admin Disallow: /cron.php Disallow: /xmlrpc.php

171 Drupal Handbook 6 Jun 2007

Disallow: /database/ Disallow: /images/ Disallow: /includes/ Disallow: /modules/ Disallow: /scripts/ Disallow: /themes/ Disallow: /email_disclaimer Disallow: /privacy_policy Disallow: */add/ # Looksmart User-agent: wisenutbot Crawl-Delay: 10 Disallow: /aggregator Disallow: /tracker Disallow: /comment/reply Disallow: /node/add Disallow: /user Disallow: /files Disallow: /search Disallow: /book/print Disallow: /admin Disallow: /cron.php Disallow: /xmlrpc.php Disallow: /database/ Disallow: /images/ Disallow: /includes/ Disallow: /modules/ Disallow: /scripts/ Disallow: /themes/ Disallow: /email_disclaimer Disallow: /privacy_policy Disallow: */add/ User-agent: zyborg Crawl-Delay: 10 Disallow: /aggregator Disallow: /tracker Disallow: /comment/reply Disallow: /node/add Disallow: /user Disallow: /files Disallow: /search Disallow: /book/print Disallow: /admin Disallow: /cron.php Disallow: /xmlrpc.php Disallow: /database/ Disallow: /images/

172 6 Jun 2007 Drupal Handbook

Disallow: /includes/ Disallow: /modules/ Disallow: /scripts/ Disallow: /themes/ Disallow: /email_disclaimer Disallow: /privacy_policy Disallow: */add/ # MSN User-agent: msnbot Crawl-Delay: 10 Disallow: /aggregator Disallow: /tracker Disallow: /comment/reply Disallow: /node/add Disallow: /user Disallow: /files Disallow: /search Disallow: /book/print Disallow: /admin Disallow: /cron.php Disallow: /xmlrpc.php Disallow: /database/ Disallow: /images/ Disallow: /includes/ Disallow: /modules/ Disallow: /scripts/ Disallow: /themes/ Disallow: /email_disclaimer Disallow: /privacy_policy Disallow: */add/ # Yahoo Vertical Crawler User-agent: yahoo-verticalcrawler Crawl-Delay: 10 Disallow: /aggregator Disallow: /tracker Disallow: /comment/reply Disallow: /node/add Disallow: /user Disallow: /files Disallow: /search Disallow: /book/print Disallow: /admin Disallow: /cron.php Disallow: /xmlrpc.php Disallow: /database/ Disallow: /images/ Disallow: /includes/

173 Drupal Handbook 6 Jun 2007

Disallow: /modules/ Disallow: /scripts/ Disallow: /themes/ Disallow: /email_disclaimer Disallow: /privacy_policy Disallow: */add/ # Exclude every other bot (hopefully) User-agent: * Disallow: /

... this way, it blocks every bot, except the ones i listed. a much more logical approach, methinks. also, a little off-topic, but don’t forget to Disable PHP’s session use_trans_sid for cleaner search engine listings.

Increase upload size in your php.ini

Drupal’s limits on upload file size are determined by your server’s PHP settings. The default values for PHP will restrict you to a maximum 2 MB upload file size.

Drupal 4.7.x and above calculates and displays the maximum file size that you can set in the settings page for the upload module based on two PHP settings, ’post_max_size’ and ’upload_max_filesize’. Since ’post_max_size’ is the limit for all the content of your post, potentially including multiple uploaded files, the upload module limits the size of a single attachment to be 50% of post_max_size, or 100% of upload_max_filesize, whichever is smaller. The default PHP values are 2 MB for upload_max_filesize, and 8 MB for post_max_size.

Depending on your host, changing these two PHP variables can be done in a number of places with the most likely being php.ini or .htaccess (depending on your hosting situation).

For example, to increase the limit on uploaded files to 10 MB:

Add the below to the relevant php.ini file (recommended, if you have access). Note that for some hosts this is a system-wide setting. However, for hosts running PHP as a CGI script with suexec (for example) you may be able to put these directives in a php.ini file in your Drupal root directory. upload_max_filesize = 10M ; post_max_size = 20M ; Add the below to your .htaccess file in the you Drupal root directory. php_value upload_max_filesize 10M php_value post_max_size 20M

The PHP documentation states that the memory_limit setting also affects file uploading. Generally speaking, memory_limit should be larger than post_max_size. If this is an issue, see the page on how to Increase memory in your php.ini

174 6 Jun 2007 Drupal Handbook

Need images etc? - check Filtered HTML

As you start creating content like a story or an article, it’s easy to overlook "input formats" - where there are options for filters like Full HTML or Filtered HTML. But these are very important; and the well-meaning Filtered HTML can trip up many a Drupal newbie: certainly caught me out, and had me searching for solution. The Filters remove HTML that isn’t listed as acceptable, as website code is processed for previews or actual views, to safeguard your site from potential harm. Can set the site’s default filter, plus decide which user groups have permission to use certain filters.

For me, as plenty of others, an apparently weird early problem was that I added an image to my text, but couldn’t see it in Preview or web pages.

The reason: I’d left "input format" in default mode, which uses Filtered HTML. And this, by default, is so enthusiastic in stripping out potentially dangerous HTML that it also removes tags. Result: no images!

One solution is to use Full HTML, so Drupal’s bodyguards stand down, and all HTML code entered is allowed on actual site. This, though, is unwise if you’ll have untrusted users contributing to the site.

It’s better, then, to permit and perhaps a few other HTML tags in Filtered HTML for untrusted users (if you’re site superuser, can use Full HTML as needed). Or, better still, create one or more new Filters: which, you’ll find, can include other filters.

Creating a Filter (site configuration - input formats - add filters), you’ll see that you have the option to include existing main filters, such as Filtered HTML and - depending on modules - things like a filter for menalto Gallery, and inline images filter from Image Assist.

But, in Drupal 5 at least, you can’t see the HTML tags in your custom filter. To see these, save your Custom Filter. Then, choose "configure" from the list of key filters, and then configure again.

Now, you can revise the list of tags. At least add . But since the default Filtered HTML seems like some latterday Ebeneezer Scrooge of the website world, can also add more. As I type this, Drupal site notes: Allowed HTML tags: