Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Configuring your settings.php file

From: Drupal 7 Advanced Training

Video: Configuring your settings.php file

The Drupal software comprises over a thousand files and directories, but for the most part you only have to concern yourself with a handful inside of the sites folder and the most important file inside there is the settings.php file. It primarily tells Drupal where to find the site's database, but it also has the potential to do much more. The file itself is over 500 lines long, but only about 60 of them are functional code and of those 60 lines only about 35 are actually active, while the rest are commented out, so don't fret even though it looks intimidating.

Configuring your settings.php file

The Drupal software comprises over a thousand files and directories, but for the most part you only have to concern yourself with a handful inside of the sites folder and the most important file inside there is the settings.php file. It primarily tells Drupal where to find the site's database, but it also has the potential to do much more. The file itself is over 500 lines long, but only about 60 of them are functional code and of those 60 lines only about 35 are actually active, while the rest are commented out, so don't fret even though it looks intimidating.

We'll look through the whole file with special emphasis on the most important parts, and we'll start by looking at the settings.php file as appears in a traditional installation; that is where it's on the web host, as opposed to using Acquia Dev Desktop on your development computer. I'm already logged in here. Take a look at where we are. Here's our lynda site in the site's folder and in default. If I list it, and there is my settings.php file. I'll edit it by going nano settings.php, and again, you to learn more about this in the videos about using the UNIX command line.

So let's start up here at the top. All of the lines that you see that start with stars like these are just comments; they don't actually affect your site, so let's start scrolling through lots and lots of comments. The first part has to do with a multi- site installation, and we talk more about that later on in this course. But again, this is just documentation; it talks about how to set them up with the different options that are possible and so forth. The second group of comments is the database settings; this is the most important part. We'll scroll down, and again, you can read these at your leisure, but when we get way down at the end, we see the actual settings for our site; here, where it stops being commented.

The most important parts are the database name here, which in my case it's tgeller_lynda, the username, the password, and then some of the other ones, which you usually don't need to change. Let's continue on. Then we have quite a few more comments. This part is actually also important if you don't have user ID Number 1. User ID Number 1 you might remember, is the one that gets installed when you first create your Drupal site, so if somebody else installs the site and you don't get that password, you're going to have to change this line here, update_free_access, so that it says TRUE.

Otherwise, you won't be able to run update PHP on your site, and you won't be able to bring it up to the latest version of Drupal, for example. This can be very touchy though, because if you change this value to TRUE, like so, and then forget to change it back, it means that other people may be able to make changes to your site, and that's actually a big security hole. So if you do change this, go right back in and change it back to FALSE. Now we come to a section of settings that very few people ever find a reason to change, so I'm going to go through them really, really quickly. As you'll see though, there is a fair amount of explanation in the settings.php file itself, in the form of documentation.

The first thing here has to do with how Drupal comes up with random numbers this drupal_hash_salt. You generally again will never have to change this. However, do note up here that you can store this in an external file, if your security setup demands that. The next two settings are for troubleshooting. They'll generally only change them if your site isn't working properly when you first install it. We first come to the base URL, and you notice that this is also commented out; by the way, both the hash mark here and the star are used for commenting in files of this type.

Continuing down we have a section of PHP settings, and a lot of these are ini_set values. Basically if you don't know what these are, don't change them, and if you do need to change them, take a good look at the documentation that comes with them. The cookie_domain variable, you only change if you're doing cross-site tracking and that will happen if you have a complicated setup for your domains. If for example, you're hosting your site on one domain, but it's being called up on another domain, and so forth, and you wanted all to be tracked in the same cookie, that would allow somebody who logs on to one site, to also get into the other site without having to re-login.

Then we come to a section called Variable overrides. Quite honestly I've never heard of anybody using this, because pretty much anything that you do here can also be done in the Drupal interface. The only reason I could imagine changing these is if you're setting up a Drupal distribution where you're handing off a specially configured copy of Drupal and you want to make sure that these values get in. As we continue down we have quite a few settings that are really geeky. There is this reverse proxy configuration, a whole bunch about page caching, file compression, and so forth.

Basically, if you don't know what they are, then don't touch them. Next, we come up to String overrides. This is something you actually might find yourself using if you just want to change one or two little things in the site, the way that it states things. For example, if instead of saying forum, you wanted to say Discussion board, you would uncomment this line here; these two are just given as examples. Now I wouldn't use this if you're doing some large amount of changes. If for example you're translating a site from English into French. To do that, see the video "Internationalizing sites" in my Drupal Gardens Essential Training course.

Continuing down, we have a way to block certain IP addresses for security reasons. It's possible to change how 404 pages are displayed; that is, when people can't reach a certain page in your site, you can make them go a lot faster by changing these configurations, but generally speaking, you only have to do that for extremely busy sites, where you want to make sure that calling up those pages isn't taking up a lot of resources. The last section is this Authorized file system operations. You can change this if you want to prohibit Drupal from using the update function for example.

This is what allows Drupal to update modules and do other things on the file system. Again, generally speaking, you won't ever touch it, and that's the end of the settings.php file. The last thing I want to point out is how Acquia Dev Desktop puts the most crucial part of this file, that is, the database address, at the very end. So to show that I'm going to switch over to my Desktop. Close out this window. Open up my desktop installation. Go to sites, and lynda, and there's my settings.php file. I'm going to open that in a text editor, which in this case is Text Wrangler.

Scroll down to where the database settings normally would be; and you'll notice it's actually just an empty line in this case. That gets overridden by what Acquia Dev Desktop puts at the end of the file here, and you'll notice it puts up this big warning: don't edit anything below this line. Well, the fact is, you may have to edit what's below that line in order to make it work on your web host when you move your development environment. So there you go. Once we broke it all down, it wasn't so bad, was it? As you saw, there are very few parts that you really have to change, and in fact, the only part I've ever personally touched was the database settings and the update free access setting.

Earlier I stated the rule I follow for the rest of the settings. Simply, if you don't completely understand it and you have a specific reason to change them, just leave them be, or find someone experienced in making such changes. In any case, be sure to back up your settings.php file before making any changes, so that you can roll it back if anything goes wrong.

Show transcript

This video is part of

Image for Drupal 7 Advanced Training
Drupal 7 Advanced Training

72 video lessons · 10925 viewers

Tom Geller
Author

 
Expand all | Collapse all
  1. 4m 51s
    1. Welcome
      1m 7s
    2. Planning your Drupal career
      3m 44s
  2. 25m 46s
    1. Comparing development and production environments
      6m 22s
    2. Configuring your settings.php file
      7m 10s
    3. Running multiple sites from one Drupal installation
      7m 32s
    4. Troubleshooting common issues
      4m 42s
  3. 51m 20s
    1. Understanding your Drupal site's place on the web
      2m 44s
    2. Selecting a web host
      7m 20s
    3. Using Unix's command-line interface
      8m 23s
    4. Working with your web host's access restrictions
      4m 51s
    5. Using cPanel and other graphical web host interfaces
      3m 40s
    6. Transferring files to and from your web host
      5m 49s
    7. Moving databases using phpMyAdmin
      6m 34s
    8. Moving databases using Unix commands
      6m 8s
    9. Modifying server configuration files
      5m 51s
  4. 27m 10s
    1. Learning from case studies
      3m 13s
    2. Planning your site
      4m 18s
    3. Populating your site with Devel Generate
      3m 42s
    4. Managing URL paths
      3m 20s
    5. Restricting access to downloadable files
      5m 55s
    6. Reusing site components with the Features module
      6m 42s
  5. 21m 53s
    1. Understanding and installing Drush
      5m 23s
    2. Installing Drupal using Drush
      7m 24s
    3. Building a site using Drush
      9m 6s
  6. 31m 59s
    1. Backing up with the Backup and Migrate module
      8m 17s
    2. Moderating comment spam
      6m 47s
    3. Migrating from Drupal 6
      4m 28s
    4. Migrating to Drupal 7
      12m 27s
  7. 22m 24s
    1. Letting users log in through OpenID
      5m 10s
    2. Letting users log in through Facebook, Twitter, and other services
      9m 43s
    3. Republishing posts on Facebook and Twitter
      7m 31s
  8. 1h 5m
    1. Understanding Drupal's base themes
      5m 55s
    2. Introducing base themes: Zen and subtheming
      11m 35s
    3. Introducing base themes: Fusion and extensibility
      10m 44s
    4. Introducing base themes: AdaptiveTheme and responsive design
      7m 25s
    5. Introducing base themes: Omega and mobile devices
      7m 9s
    6. Using Firebug and other theming tools
      7m 20s
    7. Modifying themes with Sweaver
      6m 59s
    8. Modifying themes with Livethemer
      8m 45s
  9. 49m 35s
    1. Understanding the Rules module
      6m 48s
    2. Demonstrating how Rules works in Drupal Commerce
      3m 53s
    3. Creating practical rules
      6m 37s
    4. Improving rules
      9m 10s
    5. Defining conditions with the Context module
      7m 51s
    6. Varying layout with the Context and Delta modules
      5m 0s
    7. Varying layout with the Panels module
      10m 16s
  10. 52m 46s
    1. Enabling social features
      9m 46s
    2. Implementing a voting system
      9m 15s
    3. Rewarding good behavior with the Userpoints module
      5m 57s
    4. Setting up Organic Groups
      6m 28s
    5. Adding content to groups
      2m 21s
    6. Seeing group activity better with views and panels
      10m 13s
    7. Making groups private
      4m 54s
    8. Letting each group have its own permissions
      3m 52s
  11. 25m 32s
    1. Understanding packaged Drupal distributions
      2m 8s
    2. Getting a head start with Acquia Drupal
      7m 28s
    3. Creating online storefronts with Drupal Commerce
      6m 53s
    4. Creating government web sites with OpenPublic
      9m 3s
  12. 1h 30m
    1. Taking the assignment
      3m 26s
    2. Planning the project
      3m 43s
    3. Preparing the infrastructure
      8m 42s
    4. Starting the design
      7m 35s
    5. Filling in the content
      7m 29s
    6. Developing the layout
      10m 27s
    7. Finishing the layout
      7m 8s
    8. Refining the CSS
      6m 32s
    9. Setting up sections for regional offices
      4m 53s
    10. Configuring regional offices
      7m 18s
    11. Connecting to social media
      5m 9s
    12. Cleaning up
      12m 32s
    13. Securing the site
      5m 56s
  13. 37s
    1. Next steps
      37s

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Drupal 7 Advanced Training.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.