Installing Drupal on Windows

Table of Contents

I. Requirements

II. Installation

III. Connecting it All Together

IV. Drupal Adminstration

V. Setting Permissions

VI. Customizing Themes

VII. Scheduling Tasks

VIII. Optional Components

IX. Upgrading an Existing Drupal Site

X. More Information

Requirements

Drupal requires a web server, PHP4 (http://www .php.net/) and MySQL or a database server supported by the PHP PEAR API (http://pear.php.net/).

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 extend.

I strongly recommend a complete web server packaged installer if you are at all new to Apache, MySQL or PHP. There are many out there. My personal favorite (because it worked out of the box) is FoxServ (http://sourceforge.net/projects/foxserv/).

Server Configuration

Your PHP setup must have the following settings enabled. These can be set in the php.ini file:

session.save handler user

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

The php.ini file is usually found in the WinNT directory. These settings can be set in .htaccess file (in the drupal directory) overridding whatever is set in the php.ini file. There is a very helpful function in PHP that gives you all the information about how PHP is setup on your server. You can find this information out easily with PHP's phpinfo () function. This function also shows you where your php.ini file is located so you can make any changes there. To find out about your PHP settings simply create a file called phpinfo.php. Enter one line of text, 11 <?php echo phpinfo(); ?>

" and save the file to your server (where php is installed). For example, copy it to your "www.mydomain.com" or "localhost" directory and view it in a browser. Be sure to have apache running when you test it.

Installation

Step 1.

Downloading Drupal

You can obtain the latest Drupal release from http://drupal.org/. Click the downloads link. Download the most current tar.gz format and extract the files. You may need a tool to uncompress the files. I recommend picozip (http://www.picozip.com/) because it is easy and supports a huge number of compression formats. At the time of this writing it has a 30 day trial period.

This will create a new directory drupal-x.x.x/ containing all Drupal files and directories. This directory can be several directorys deeper than the unzipped directory. The directory we are concerned about has the index.php page and modules directory in it. Move the contents of that directory into a directory within your web server's document root or your public HTML directory. On my local machine I created a directory of the name of the domain name it is part of. For example, on my local machine I copy the files to, "C:\FoxServ\www\drupal". I would recommend copying it to a directory but if you are ready you can copy the files to root of the site which would be something like, "D:\FoxServ\www\" (locally) or "ftp://www.mydomain.com/www" or "ftp://www.mydomain.com/var/www/html".

NOTE: when copying files, ensure you also copy the hidden .htaccess file. You can see hidden files in Explorer by going to the menu item Tools > Folder Options > View > Hidden Files and Folders > Show Hidden Files.

Step 2.

Creating the Drupal Database

These instructions are geared toward a MySQL database. If you are using another database and you know a little bit about databases you should be able to follow along quite nicely. Be sure to check the database documentation for your specific database if you have any questions.

For this part of the tutorial I am going to use MySQL-Front to create and setup our Drupal database. At the time of this writing it is free. You can goto and download MySQLFront from http://www.mysqlfront.de/. Tell the guy thank you and donate. I received an error that prevented the program to launch when I tried to "Launch Program Now" from the installation program but on a second attempt the Start > Programs > menu it launched successfully. Alternatively you can use MySQL.exe from the command line to achieve the same thing. I will list the command line instructions after the MySQL-Front instructions.

To follow alongin the next steps you will need to login to your MySQL database with a user account that has the CREATE and GRANT privileges. You will need to use the appropriate user name for your system.

Creating the Database with MySQL-Front

If you are going to create a database from the command line skip to the next section, otherwise continue on here.

First, you must create a new database for your Drupal site. To do so:

- Opening MySQL Front

- Find and open MySQL-Front. An Open Session window will appear.

- Creating a New Connection Session

- Click the New button to create a new connection session for drupal. An Add Session window will appear.

- Under the Common tab enter the name for your connection. In this tutorial we will call it "Drupal Connection".

- Switch to the Connection tab and enter the name of the server that has mysql running on it. This would be "www.myserver.com" or an IP "127.0.0.1". Enter "localhost" if you are running it locally. The default port for mysql is "3306". Default Timeout is 30 seconds. Connection Saver is active by default. I dont know what Connection Saver is.

- Switch to the login tab and enter the username that you setup when you installed mysql. You have the option to choose the database to startup in. You will choose this at another time because we have not created our database yet. Click the Ok button to save your new mysql session connection and to take you back to the Open Session window. If you dont know your're userid and password you will need to contact your hosting company or whoever set it mysql on your server and get a userid or send them these instructions. If you installed mysql yourself the username is "admin" or "root" and the password is blank (on a fresh mysql installation).

- Login to MySQL

- Select the new session you just made and click the OK button. A window will prompt you for your password if a password was not supplied (when you were creating the session connection). If your password is blank you do not need to enter anything here. Otherwise enter your password now. Click OK to login to your mysql account.

If you get any errors the program will let you know about it and sometimes offers accurate advice on what to do to fix it. Try what it says and if it doesn't work use the Command line method listed below or contact the authors of MySQL-Front at http://www.mysqlfront.de/.

Assuming you login successfully you will be shown a list of databases attached to the mysql server.

- Creating a New Database

- To create our new drupal database, select Database > New > Database from the menu bar. There is also a toolbar icon that adds a new database. For this tutorial we will try to stay with menu commands.

- A New Database dialog appears.

- Enter the name of your new drupal database. If you are running it on your local machine I would name it, "drupal" or the same name as your domain, "mydomainname". I recommend using all lowercase in the names you specify to avoid case sensitive errors later on. MySQL will then create the initial database files.

- Creating a User with Access Rights

- Next you must set the access database rights. Right click on Users in the Host tree and select Database > New > User from the menu bar. An Add User window will appear.

- In the Common tab enter the name of the new user. In this tutorial we will use, "dba_user". In the password field enter a password. If you are smart you will write these down now. If you are not then skip it.

- Switch to the Hosts tab and enter "localhost" or the name of your session connection. You will get an error in german if you enter the wrong hostname. Interpreted it says, "I am german. No speeka englace." Ok, I dont seem to be doing something right here. Let's skip this method. Cancel out of that. We are going to run a script in MySQL-Front's SQL Query.

- Click on the SQL Editor and copy this code into it:

GRANT ALL PRIVILEGES ON myDatabaseName.* TO [email protected] IDENTIFIED BY 'myPassword';

- Substitute "myDatabaseName" with the name of your database. Substitute, "myUserId" with the name of the drupal account that will be responsible for administering your drupal database. Substitute "myDomainName" with the name of of your domain. If you are running drupal on a local machine enter, "localhost". Finally substitute, "myPassword" with the password for your "[email protected]" user ID. If you are smart you will write your username and password down now.

- Select Database > Run from the menu bar. If successful you will get "O rows affected" in the MySQL-Front status bar. This will add a new user with permissions necessary to administer your drupal database.

- Let's verify that we created a new user. Click on Users in the Host tree and select View > Refresh from the menu bar. If everything went hunky dory then we should see our new user listed. If not then check the error messages, go back and check for misspelling and incorrect syntax and try again.

- Importing the Drupal Database Scheme

Once you have created your new database, you must load the required drupal tables into it. To do this you must go to the "Importing the Drupal Database Scheme" section in the Command Line section or obtain an additional file called, "database.sql". This is a MySQL import compatible MySQL database. MySQL-Front cannot import "*.mysql" files which are the only kind included with drupal distribution. At the time of this writing the "database.sql" is not included with the drupal distribution. I made the file because I imported the database from the command line and once it was in MySQL-Front I exported it to "database.sql". It took 10 seconds to export it to ".sql" file. And ten seconds to import it to my test database. But whatever, you can write me or request it from the HEAD team at drupal.org. It would be better to have them manage it.

- Right click on your new drupal database in the Host tree and select Import > SQL File. Browse to the "[drupal install dir]/database/database.sql" directory and select the file, "database.sql". This is the SQL script that will create your drupal tables. An Import Options window will appear. Click Ok and your database will be created.

If you did not receive any errors then you have just created your drupal database! Yea!

Creating the Database from the Command Line

If you have already created a database using MySQL-Front skip to the next section. Otherwise you aren't going anywhere buddy. You gotta a lesson in "Running MySQL from the Command Line".

- Creating the Database

- You must create a new database for your Drupal site for it to work. The tool to do this is the mysql.exe file that can be run from the command line. To get to the command line goto Start > Run and enter "cmd". Click the OK button.

You will be presented with a scary black window with a square flashy thing. This is called the command line. (cue ghost sounds). This is what people used to work in before graphical user interfaces available.

- Browse to the directory where "mysql.exe" resides. The two commands you use to browse are, wait for it, "dir" and "cd". "Dir" lists the contents of the directory and "cd" changes the directory. Ok I was going to explain this but if you are installing a web site then you dont need to know this. (...ok fine.) Change directories to the mysql directory. Enter "cd\" to get to the root of your hard drive and then enter "cd FoxServ\mysql\bin". Well, on my machine the directory to the "mysql\bin" folder is "D:\FoxServ\mysql\bin". If you did everything right command prompt will look like this, "d:\FoxServ\mysql\bin>". If you see something like that then pat yourself on the back. You are a big boy now.

- Now enter the following where "dba_user" is the name of the user id that has database administration rights to create your drupal database and "drupal" is the name of the drupal database to create:

mysqladmin -u dba_user -p create drupal

- SQL will prompt you for the dba_user database password. Enter the password and hit enter. Note: if you just setup your mysql to run on your computer or server or whatever then you DO NOT HAVE A PASSWORD YET!!!! AAHHHHAHGGGG! That is ok. Calm down. You can set it later. For now just leave the password field blank and press the entertainme key. If you receive no messages and are back to the command prompt then you have just created the your drupal database. We still need to import the database tables and setup a user before we can go further.

- Setting Access Rights

- Next you must login into your new database and set the user's database access rights. To do that we need to log into the MySQL command prompt. This is a command prompt that mysql creates inside the bigger command prompt. What? You closed the command line window? No, no NO! This wont work at all! That's it I quit. (What drupal slave master? I am bound by the GPL to finish writing this on pain of death? Is it death by snoose snoose? No?

Hmmm. Ok. Fine. I'll keep going.) Ehem, excuse me, where was I? Oh right, let's get that command prompt back up.

- Make sure we are in the same directory as before and enter the following where "dba_user" is the name of the user id that has database adminstration rights:

mysql -u dba_user -p

- Again, you will be asked for the dba_user database password. Enter it (or dont if you dont have one) and press enter. You will now be at the mysql command line prompt which looks like "mysql> ". pretty isn't it?

- Creating a new user with permissions

- Now we need to create a new user that drupal can use to have access rights to the database.

- At the MySQL prompt, enter following command where 'myDrupalDatabase' is the name of your new drupal database, "[email protected]" is the new Drupal UserId, "localhost" is the server where MySQL is installed and running and "myDrupalUsersPassword" is the new password for "[email protected]" required to log in as the MySQL user. You must include the semicolon at the end of the line for MySQL to evaluate your statement. Enter the following and press Enter:

GRANT ALL PRIVILEGES ON myDrupalDatabase.* TO [email protected] IDENTIFIED BY 'myDrupalUsersPassword';

- If this attempt is successful, MySQL will reply with "Query OK, 0 rows affected < 0.08 sec >". Note: You must remember to include the semicolon at the end of every statement you enter at the mysql prompt, otherwise it just sits there, waiting, waiting, waiting...

- Activating Permissions

- You must activate the new permissions for MySQL to apply the last step to the current running databases. To activate the new permissions you must enter the the following from the mysql command prompt:

flush privileges;

- and press enter. This refreshes and applies the permission to the new user we just made.

- Exit MySQL Command Prompt

- We must now exit the mysql command prompt to finish creating our database. To exit mysql command prompt type 'exit' and press enter. You will be returned back to the command prompt.

- Importing the Drupal Database Scheme

- Once you have created your new database, you must load the required drupal tables into it. To do so enter the following from the command prompt:

mysql -u myDrupalUserID -p myDrupalDatabase < database/database.mysql

- where "myDrupalDatabase" is the name of your new drupal database, "myDrupalUserID" is the new MySQL userid you just created(without the "@locahost") for use with your new drupal database and "database/database.mysql" is the path to the mysql database stored in the "[drupal install dir]/database/" directory. Now would be a good time to copy the database (using windows explorer) to the same directory where "mysql.exe" resides (that is the directory you are in right now). On my machine it is "D:\FoxServ\mysql\bin". When entering the userid remember to leave off the "@domainname" we specified in previous steps. It's was only necessary when we created a user but not used after that.

- You will be prompted to enter a password. Enter the password you created for your "myDrupalUserID" account. If you receive absolutely no messages whatsoever then the drupal database was successfully imported. That is called living by faith. Believing it worked even when you see no sign. If you do receive an error then I suggest checking the specified the path to the database and spelling errors.

- Close the Command Prompt window

- Type "exit" and press enter to exit the command window.

If you've got this far then you can conclude that your drupal database was installed and setup successfully.

Connecting it All Together

We are almost done. Before Drupal will work we need to setup a few more settings. Drupal server options are specified in includes/conf.php file. Before you can run Drupal, you must set the database URL and the base URL to the web site. The database URL creates a connection string to connect to your database. Remember how I said you can have multiple drupal sites running? Here is where you can configure that.

Setting the Path to the Drupal Database

- Browse to the "includes" directory in your drupal server install directory and open the "conf.php" file in a text editor. On my machine the "conf.php" file is located in "D:\FoxServ\www\includes\conf.php". On my second drupal install, my test site, the "conf.php" file is located in "D:\FoxServ\www\mytestsite\includes\conf.php". I have two duplicate sites on my server. I've copied the orginal files to both the root "D:\FoxServ\www" and the test directory, "D:\FoxServ\www\test". Open the "conf.php" configuration file (in whatever drupal install you are in) and edit the $db_url line to match the values we defined in the previous steps:

"mysql://myDrupalUserID:[email protected]/myDrup alDatabase";

- This step is essential. This is the login script to get into your specific MySQL drupal database.

Setting the Path to the Drupal Directory on your Server

- This step is also essential. If you dont get this you will only see the home page. But nothing else. The base URL is the location, the directory where your index.php file exists on your server. So if you put your drupal files into a directory say, "http://www.mysite.com/drupal" then you would put the same thing here.

- Set $base_url to match the address and directory of drupal on your web site:

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

Here are some more examples. Use only one that matches your specific configuration:

"http://www.mysite.com/directoryWhereDrupalIs"; $base_url = "http://localhost";

$base_url = "http://localhost/anotherDrupalSite";

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

Setting up more than one dupal site on one machine using Virtual Hosts

Besides the method I've mentioned above Drupal also allows for multiple virtual host installations. To configure a virtual server host, make a copy of the conf.php file we worked with earlier and rename it to "www.yourdomainname.com.php". place this in your includes directory. NOTE: This part of the instructions (setting up virtual hosts) is not not tested. If someone validates this and would include any steps I have forgot then i will add it here for the benefit of others.

Drupal Adminstration

You can now launch your browser and test your site! Browse to the root directory where Drupal is installed. Make sure Apache and MySQL services are running. If everything is setup correctly you will be at the home page of your new Drupal site. 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/.

Setting Permissions

Out of the box you will not have permission to do or view anything but the home page. Neither will anyone who visits the site. You have to give them (an anonymous visitor) privileges to view your site. The first thing you need to do is create a master user account. Follow the on screen instructions to create an account and login. The first account will automatically become the main administrator account for the site. You can add additional adminstrator accounts at any time. I recommend creating another account with administrative permissions for security reasons and using that from now on. Write your user name and password to both down in a secure location.

Creating the Administrator Role

By default Drupal only has two roles, anonymous visitor and authenticated user. Except in certain cases you will want to create additional roles for the different users that use your site. For now go to Administer > Accounts > Roles and add "Adminstrator". Enter "adminstrator" and press the Add button.

Giving Permissions to a Role

By default all the roles have very limited capabilities. New roles have no permissions set. If we are going to create a new adminstrator user account for ourselves we will need to change this. We can change this in the Permissions page. Goto Administer > Accounts > Permissions. Here is a table filled with options for all your different roles. Set your administrator account to have all permissions for now and click save permissions. You can go back and change this after you get familiar with Drupal (think a few months from now). Please note. This is the page to give users the permission to see the content on your site. To enable anonymous users to see your site content find a row called, "access content" check the checkbox.

Creating a New User

Finally, we are one step away from creating our secondary adminstor account. Goto Administer > Accounts > New User. On this page enter the new account information and click Create Account. You can now log out of the adminstrator account (write down the password) and login with your secondary adminstrator account.

Customizing Themes

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.

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.

Scheduling Tasks

Many Drupal modules have periodic tasks that must be triggered at specific interviews. This is called a cron job and they are setup in the cron.php page. 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. I dont know the Windows equivalent of this section. Please email me if you know.

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.)

Upgrading an Existing Drupal Site

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. Overwrite all the old Drupal files with the new Drupal files.

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.

Was this article helpful?

0 0

Post a comment