So I haven't posted on this little hole-in-the wall for a long time. I'm lazy I know. But I had one of the greatest epiphanies of all time today. I NEED to write a blog about this. I'm sure there are webmasters scouring the internet for how to put their website on their localhost so that way they'll be able to test things out when they upload modules or write custom PHP. They need to know that what they are doing will not negatively affect their site in any way. I believe that one of the hardest things about Drupal is installing it. So I'm going to take you step by step into everything you need to do.
1). First things first, do NOT use a bundle. I've tried many bundles, and none of them have been successful for me. Plus, Downloading each one gives you better security. You probably don't need to worry toooo much about security if nobody else uses your computer except for you, and if you don't use public wi-fi all the time.
2) Install MySQL from their
website. I'm using Windows, so I used the MSI. If you are using a different OS, follow your OS-based install instructions for MySQL.
3) Make sure that the thing about "remote connections" is unticked, unless you have an awesome reason to leave it ticked. This is for security purposes. Speaking of security, set a root password and remember it! You will save yourself a lot of headaches if you don't forget this. Don't make it too difficult, and don't make it "password" or "12345". Right after you install it, you'll want to find the config file. It will take you through more setup options, like being able to run MySQL through the command prompt in the PATH directory, which is definitely awesome, and great for debugging purposes. So go ahead, fool around with the commandline and have some fun. Create some databases, and delete them, just to prove to yourself that you can. Log in using "mysql -u root -p" (without the quotes) Now, let's make some awesomeness! For instance: CREATE DATABASE AWESOMENESS;
then
SHOW DATABASES;
You'll see test, information_schema and awesomeness. Nice! You don't have to type in all caps, but it's sort of an SQL tradition. If you are mad at the errors that you sometimes get in MySQL, typing in all caps is potentially a great way to blow off some steam. If you want to delete the database you just made, just do
DROP DATABASE AWESOMENESS;
4) Install PHP: Go to their
website and download the latest release. By now, you should be using PHP 5. As of this blog posting, the latest release is 5.3.10. I suggest getting the most recent version. My website that I webmaster states that the version of PHP that it is running is like 5.3.3gentoo, kinda weird but the latest version of PHP works fine with that. Always opt for the latest version unless you find a good reason not to. Better to stay fresh, so to speak. I went for a standard install. I didn't add Pear or any of the non-standard things that PHP has to offer. Do what suits you best. Now here's where you do some fanangling that will come in handy later. This is mostly for importing large databases that you've got from FTPing, or downloading from your server. You edit the php.ini file with these lines:
post_max_size = 750M
upload_max_filesize = 750M
max_execution_time = 5000
max_input_time = 5000
memory_limit = 1000M
Use your text editor's "find" feature to find these values. These are NOT the default values. These are what I changed them to.
5) Install Apache from their
website. A default installation should work fine. When you are finished, you have to edit the mod_rewrite file so that it says "true."
6). Install PHPMyAdmin from their
website. I installed the last one on the list, the zip file. You are going to need to configure a few things. You will need to login as the root user you specified earlier when you installed MySQL. Your username will be "root" and the password will be whatever you set when you installed MySQL. There's a file called "config.inc.sample.php." Copy it and save the other as "config.inc.php." You'll need to edit this file in a few ways:
$cfg['Servers'][$i]['auth_type'] = 'cookie'; //You want this as cookie, also change the blowfish secret at the top to something like
$cfg['blowfish_secret'] = 'liukjnrguingngjnifflsklsksdoskdsdkskdskmiu';
If you are importing large databases, add this:
$cfg['ExecTimeLimit'] = 1300; //This will make it so you can import large files and not have it
timeout. We needed to do this in conjunction with the editing the php
So now you're in PHPMyAdmin, and in order to import large databases, you'll need to add that line.
So now create a user and call it "drupaluser" or whatever you want to call it. Import your database and then grant all privileges to it. Just a word of caution, you might want to grant all privleges besides the grant. privilege. On my computer, I granted all including the grant to my drupaluser. Now it seems that I can't log in as root. That doesn't really matter though, because I can still create databases just fine. But that is a little necessary tidbit in case you run into the same thing. I can do everything root can do, so it doesn't bother me. So we've got this out of the way, now it's time to put everything together.
Honestly, I don't know how to backup a website or a database. (Somebody did that for me) But you will need the most recent version of your site and the database. Use an FTP client like Filezilla to connect to your server, and then download your backups from there. Put your web folder in the "Htdocs" folder in Apache. Now you only need to do just a
little bit more tweaking before going forward. Look for the sites/default directory. There are either 1 or 2 files. If you have only the defaultsettings.php, copy it and rename it to "settings.php." (If you already have a settings.php file then delete it and copy the defaultsettings.php and rename it to settings.php) Then put it in a new folder called "files". Make it a writable folder by right-clicking and going to properties and "permissions".
Now type in localhost/(what folder(s) your site is in)/install.php. The Drupal installation screen should come up. Put in your database name and password. Use "drupaluser" (or whatever name you chose) and that password or you could use "root" and your root password. One of the screens has an "Advanced" tab. click it. In my case, the database HAD TO BE PREFXED! If your configuration is the same, you need to prefix your database! If you don't, you'll have a clean install of Drupal. That's not what you want! You want the stuff that is on your site to appear as it is on your localhost! Everything should go well from there. Enjoy Drupaling it up! If you have any questions, or if you were unclear about something, leave a comment.
Keyboard Cat approves!