Hướng dẫn cài đặt Drupal 7 Multisite

Hướng dẫn cài đặt Drupal 7 Multisite

Do you have more than a few installations of Drupal 7 on a server? Tired of doggedly updating the core files when they're released? Add to the mix updating the installs of modules on numerous sites. After you've gone down that road a several times you start to wonder if there is a better way to handle updates/upgrades of modules and Drupal's core files.

THE ANSWER IS A DRUPAL MULTISITE

A Drupal multisite allows multiple domains to share the same Drupal core files. That's right, one install of Drupal and as many domains as you want use the same core files. Even better is that all of those other domains can do the same thing with the modules. Imagine updating a module once and your done (of course it is always a good idea to run update.php for each domain, but you'd be doing that anyway.)

Is Your Current Hosting Company Drupal Friendly?

Before you start it's a good idea to make certain that your current hosting company is Drupal friendly. The best way is to read Drupal's requirements for the CMS. If you are looking for a hosting company consider Green Geeks (yeah, I get a commission if you use the link and sign up for an account).

Currently few web hosting companies are offering PHP 5.3, which is the version most ideal for Drupal 7. Check your CPanel to see which version of PHP is installed. If it is below PHP 5, then you need to seriously considering moving to a new service.

[In some cases the reason hosting companies are slow (read that as reluctant) to upgrade to a newer version is because they feel too many customers will rise and revolt when they discover their old PHP code no longer works. Running a version of PHP below 5 not only prevents you from enjoying a better operating program, it also increases security issues.]

If you sign up for a new account with GreenGeeks and you get a plan with a 'free domain' don't use one that you plan to develop. Instead sign up for one that you won't mind losing. Here's why. The free domain is in complete control of Green Geeks. Lots of luck transferring it to another hosting service--not saying it isn't possible--just you're better off choosing a domain you can scrap.

There's another reason for selecting a useless domain name. The domain you select will become the primary name for the account. It will also be the domain where the core Drupal 7 files will be installed. The final reason for a junk name is that I'd hate to see anyone poor years of hard work into a site, then decide to sell the domain. Don't complicate your already hectic life.

Setting Up Your Primary Drupal 7 Site

On some servers I've used services like Fantastico to install WordPress and Drupal without a problem. For whatever reason When I used Fantastico on GreenGreeks the results were not as expected. Sure for a single install of Drupal the site works, but when building the multisites things got wonky. For example on a multisite the URI would look something like this, "http://www.example.com/example."

Not willing to spend a massive amount of time on diagnosing the problem I found a system that works and isn't difficult...if you follow the steps in order.

Installing the Primary Drupal Account

You'll need to download the latest version of Drupal 7. Don't be tempted to get the DEV(eloper) version. It's not the official release and most likely has a chance of doing unexpected things. In other words never-ever use a development version for a production site.

If you were expecting a ZIP file you're probably surprised to find it wrapped in a tar-ball. No need to stress, you're not going to open it on your machine.

  1. Download Drupal 7 install files.
  2. Upload the tar-ball file to the root directory (public_html) of your account.
  3. Log on to your CPanel.
  4. In the 'Databases' section click on 'MySQL Database Wizard'.
  5. Enter a name for the database. Use alpha (lowercase) & numeric characters only. Name it 'drup1' or an abbreviation of the junk domain. Click 'Next Step'.
  6. Enter a name for the user. It's okay to have the user name and database name the same--in fact it easier to remember one name instead of two separate ones. Whatever you choose to do write it down.
  7. Click the 'Password Generator' button. Make sure you make a copy of it. You'll only need to use it once, but if you loose the info between now and when you go to install Drupal not to worry. Just return here, delete both the user and database using the 'MySQL Databases' program just left of the Wizard program. When ready click the 'Create User' button.
  8. Tick the 'All Privileges' box, then click the 'Next Step' button.
  9. Return to the CPanel by clicking the little 'Home' icon in the top left of the window.
  10. Under the 'Files' section open 'File Manager'.
  11. Look in 'public_html' folder for the Drupal 7 install files, the right click on the file and select 'Expand'.
  12. Close the CPanel; you won't be needing it for now.
  13. In your browser go to your junk domain and follow the prompts.
  14. At one point you'll be asked for the database and user name, along with the password. Be sure to use you account name (usually the junk domain name without the dot com. It'll look something like: junkdomain_drup1.
  15. A few more details like your site name, email address, etc. You'll need to also provide a user name and password. How you handle your site security is up to you. If you like to play it safe, but have trouble coming up with mind twisting passwords, then visit the Gibson Research Corp's Password Generator where you'll not only be treated to a vast array of passwords, but also learn a little (okay, more than you'll ever want to know) about password security.
  16. Congrats. You're done with the primary site.

Get Your Drupal Multisite Domain Name Ready for Action

Assuming that you already have a domain registry you'll need to log in and change the DNS for the Drupal multisite domain. The specific DNS settings should have been emailed to you when you registered for Green Geeks hosting. If you aren't certain how to change the DNS settings do a quick search on Google using the name of the registry service (like GoDaddy) plus 'change DNS'. If all else fails contact technical support. Be forewarned. It can take up to 48 hours before the DNS change takes place. In other words it take minutes or days before your domain name will point to the new hosting company.

You won't have to wait though to perform the following steps. You will however have to wait for the Internet to recognize your new hosting company before installing a multisite.

  1. Open the CPanel.
  2. Under the 'Domains' section click on 'Addon Domains'.
  3. Enter your domain name, i.e. example.com.
  4. Click in the text box labeled 'Document Root'. Magically a couple of the boxes are populated with data.
  5. Use the 'Password Generator' to generate a password. Don't know what that is all about, but from experience don't bother storing the password.
  6. Finally, click 'Add Domain'.
  7. Return to CPanel

Creating the Drupal Multisites

You'll be repeating much of what you did in the previous section, but the scenery will be slightly different. Namely, you'll be doing a few extra steps using your computer.

Before getting started you'll need to expand the Drupal tar-ball. If the file type looks unfamiliar to you may need to download Z-Zip to free up that little tar-ball. If this is your first time you'll be surprised that you don't 'unzip' it once, but twice. After the second 'unzip' you'll a folder named Drupal 7.x.

  1. Rename the newly unfurled tar-ball the name of the domain you're going to install. Be sure to include the dot com, or net, or whatever. As in: example.com
  2. Now ZIP that renamed file. On a PC right click on the file, select 'Send to', then 'Compress (zipped) folder.
  3. Use your FTP program to access your hosted account.
  4. Upload the zipped file to the root directory.
  5. Follow the steps 3 through 15 from the above section using the zipped file you just uploaded.
  6. Congrats. You are halfway to completing your first multisite.

Semi-Final Steps for a Happier Drupal Multisite Life

You're on your final leg of the journey. In a few moments you'll officially be running a Drupal multisite.

If you're going to be installing only one multisite, then you can delete the ZIP file you created earlier. If you plan to create any additional multisite in the immediate future, then delete the zipped you created and rename the folder you zipped previously to that of the next domain you'll be installing. Might as well ZIP it too.

A word of caution about adding multisites in the future. You'll want to be certain that the version of Drupal installed on the primary account is the same version that you are adding as a multisite. Otherwise you'll run into problems in regards to the database.

  1. On your desktop create an empty folder of the new domain. For example, 'mydomain.com'.
  2. Open the newly created folder and add four more empty files; files, themes, tmp, and modules.
  3. Using your FTP program download from the site (you just created) the settings.php file [mydomain.com/sites/default/settings.php. Copy it into the folder of the name of the new domain. So, you'll have in it four empty folders and settings.php.
  4. Upload that folder to 'public_html/sites/mydomain.com

Final Steps to Complete Installation of Drupal Multisite

This final part is mainly housekeeping and tossing the files no longer needed.

  1. Open CPanel (if not already open), then 'Addon Domains'.
  2. Delete the domain that you added earlier. Return to the CPanel.
  3. Next to 'Addon Domains' is the 'Parked Domains' icon. Open it.
  4. Add the domain you just deleted as a parked domain. Return to the CPanel.
  5. Open 'File Manager' and look for the domain you just installed Drupal 7 on. Don't confuse it with the one of the identical name in the sites folder. You're going to delete all of its files--except they aren't all going to disappear. Select the folder and either right click, then choose delete, or click the big red 'X' on the toolbar.
  6. To remove the remaining files you need to open the folder and make certain the permission level for folders is set to 755 and for files the permission level needs to be 644. You see the current permission level to the far right of the 'File Manager' window. When done close the CPanel.
  7. Seriously, you're done!

The Finishing Touches On Your Drupal Multisite

To keep your Drupal 7 site healthy it is an excellent idea to run what is called a cron job. In the past this is something that sent people an early digital grave. Relatively few web site owners bother with it because it seems so arcane.

The good news is that Drupal 7 comes to the rescue, but because this is a multisite you need to perform one little tweak, which won't be technical...I promise.

Remember back when you created an empty folder with the name of your domain? Recall the empty folder you added called 'tmp'? You're about to find out why you added it. Before we get started log into your new multisite.

  1. Logged in as administrator you should see a black band across the top with several links. Click on 'Configuration'.
  2. Under the 'Media' section click on 'File system'.
  3. Copy the content in the box lableled 'Public file system path'.
  4. Paste what you just copied in the text box for 'Temporary directory'. Now change the last word from 'files' to 'tmp'. It should look something like; 'sites/mydomain.com/tmp'. Be sure to click the 'Save configuration' button.
  5. Click on the 'Configuration' link again. Select the frequency you want cron to run. When you are starting a new site there isn't much point in frequent cron updates, so for now select the maximum time of 1 week. You can always change it later if the need arises. Again, click the 'Save configuration' button.
  6. Click the 'Run cron' button.
  7. Click the 'Reports' link on the menu bar, then recent log messages. There should be a message reporting that the "Cron run completed". If you see a bunch of warnings it is because you either didn't create the 'tmp' folder or you didn't set the permission to 755.
  8. This last step caches the content, CSS, and javascript for anonymous users. Click on 'Configuration', then under 'Development' click on 'Performance'.
  9. Under 'Caching' tick 'Cache pages for anonymous users' and tick all of the boxes in the 'Bandwidth Optimization' section. If your sites looks screwy after clicking the 'Save configuration' button, then you don't have the correct tmp folder settings mentioned earlier.
  10. Now you're done. Seriously!

By the way this site is hosted on Green Geeks.

Bạn thấy bài viết này như thế nào?: 
No votes yet
Ảnh của Khanh Hoang

Khanh Hoang - Kenn

Kenn is a user experience designer and front end developer who enjoys creating beautiful and usable web and mobile experiences.

Tìm kiếm bất động sản

 

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Sức mạnh của Contextual Filters trong Drupal Views của Drupal 8

Sức mạnh của Contextual Filters trong Drupal Views của Drupal 8

The small endpoint I built returns an array of cars in sale, with relative information about each car

Cách chèn Captions vào Drupal Images with jCaption

Cách chèn Captions vào Drupal Images with jCaption

jCaption allows you to add captions to your Drupal images, no matter what editor you're using.

CEO Mark Zuckerberg sẽ gặp gỡ ai tại Việt Nam?

CEO Mark Zuckerberg sẽ gặp gỡ ai tại Việt Nam?

Chuyến đi bất ngờ của Mark Zuckerberg đến VN chỉ vì mục đích cá nhân, không phải vì công việc.

Công ty diệt chuột T&C

 

Diet con trung