Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Topic started by: ɔɔɔɔɔɔuɥoɾ on July 18, 2010, 12:36:10 AM

Title: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on July 18, 2010, 12:36:10 AM
SMF tutorials:

How to setup a localhost for testing

In this Tutorial you will be learning how to set up a localhost so you can test and practice your PHP without dooming your forum.
Using a locally hosted forum makes editing really easy and fast with no uploading. I will be using Xampp (http://www.apachefriends.org/en/xampp.html) in this tutorial, their are other software's that do the same thing, choose which every is your preference.


1st of all, install the Xampp, this is relatively easy, just follow the on screen instructions and then, if default settings were used you localhost files will be located C:\Xampp\htdocs, we erase (or move to another folder) the current files that are in their. This is where we extract the SMF installer zip file to.

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi32.tinypic.com%2F20jl6vc.png&hash=610c463e359fcf39c0a8b600d415419a4d6798bc)

If you don't have Winrar, zips can be extracted without any additional software in Windows (XP or above), whichever method you use, just make sure index.php extracts to the htdocs folder along with the rest of the root files and folders. I recommend leaving the smf installer zip inside htdocs, simply because when your done testing, you can simply extract here again and start a fresh installation easily.

Now, We have the installer files ready its time to setup our database for smf to use, this is simple too. We simply go to phpmyadmin and add an account.

http://localhost/phpmyadmin/ (http://localhost/phpmyadmin/) is the default address

Click on Privileges, Click on Add New User. Fill in the Login Information form.

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi25.tinypic.com%2F2i6jrq8.png&hash=ecd062d04fdace6beb31e39377468142319b0139)

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi27.tinypic.com%2Fsd1c8h.png&hash=24e9d2f88984735f9c6e90802bd3225644f407fc)

On the Host part, use the drop down menu to select Local.

On the password drop down menu, select Use text field.

Now before creating the account, check the Global privileges area, Click the Check All then click Go in the right bottom corner

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fi26.tinypic.com%2F2h7j32d.png&hash=5960c174246091965e8486def3ef680e85d0b9eb)

Tip: Since were using localhost for testing only, I set my database name the same as the password and user I will use for smf, ordinarily this is a no-no, but since its only local and were testing we can use this, because then we can have Firefox remember the password so every time we use the installer it will remember our database info as well as our smf login information.

Now we got that done, we use the usual method to install smf (http://docs.simplemachines.org/index.php?board=2.0), We just type localhost in our web browser to start the smf installation process
When we get to the create admin account, providing we saved the login information (using Browser) from logging into database, it should be pretty much filled, all to fill is the confirmation password for the new admin account and the database password. Once we do that were done, we have our forum set up and ready to do all our testing.
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: cicka on July 18, 2010, 09:08:53 AM
Nice tutorial. Thanks for posting it :)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on July 18, 2010, 12:20:41 PM
Your Welcome,

Not quiet sure where this belongs, maybe their is/should be a tutorial board somewhere in the forum, I think little tutorials to explain little things in small dose's will help out smf users a lot, especially newcomers that overlook the smf online manual

(I made this tutorial myself)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: cicka on July 18, 2010, 12:21:57 PM
Quote from: ♪ JohnCcCcCc ♫ on July 18, 2010, 12:20:41 PM
Your Welcome,

Not quiet sure where this belongs, maybe their is/should be a tutorial board somewhere in the forum, I think little tutorials to explain little things in small dose's will help out smf users a lot, especially newcomers that overlook the smf online manual

(I made this tutorial myself)

Yes, I am sure it will help the new admins a lot.
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ~DS~ on July 18, 2010, 02:11:55 PM
I am trying to figure how to make them secure...

Thank you for sharing.

Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: sAce on July 18, 2010, 02:58:49 PM
Why are you creating another user ? you can simply use the root user with no password
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on July 18, 2010, 03:07:23 PM
Well, for speed, Since we will be erasing and re using the smf installer several times, I had the idea to have the browser remember the password, thus less typing for us, to complete the speedy idea, I though to use the same name in smf, I don't think SMF allows blank passwords, thus we create a password for both.

Using this method it takes me mere seconds to create a complete new forum with new database too

1. Extract Zip over other files
While that's getting done

2. Drop all the tables from the database.

3. Run the SMF installer, almost all the forms are already filled, thanks to Firefox remembering our settings.
Since the SMF admin account and database password are the same, it remembers for both (localhost URL)



Quote from: Delita Heiral on July 18, 2010, 02:11:55 PM
I am trying to figure how to make them secure...

Thank you for sharing.
Im not a mac user,thus unsre about 2 of those errors.
You can make the MySQL secure by adding the admin account with a password, you can also add a password to the root account, just to make sure its not throwing that "un-secure" error
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: sAce on July 18, 2010, 03:20:01 PM
Well do one installation every 2nd day, and the only thing i change is the user to root, and it that much of work now, is it ?

But your method is fine, but speed , nah!!

And blank passwords are not allowed for users, but Db settings does take blank passwords
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on July 18, 2010, 03:26:41 PM
Quote from: S-Ace on July 18, 2010, 03:20:01 PM
Well do one installation every 2nd day, and the only thing i change is the user to root, and it that much of work now, is it ?

But your method is fine, but speed , nah!!

And blank passwords are not allowed for users, Db settings does take blank passwords
Exactly why I create a db account with a password ;)

I make, well try to make mods, and when I do I have to be checking for errors in the log, a lot, since I'm not that good yet, I'm still  a beginner, (take a look at my mods, link in sig) So every time I make a revision to the mod I'm creating, I need to start with a completely clean forum, so every time I fix something, which is usually several times per day, this seems quiet needed.
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: sAce on July 18, 2010, 03:31:31 PM
anyway, at the end of the day getting it done matters, right ?
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on July 18, 2010, 03:39:21 PM
Quote from: S-Ace on July 18, 2010, 03:31:31 PM
anyway, at the end of the day getting it done matters, right ?

I would assume newcomers like me will face the same difficulties, so I may as well help them out.

And yes, its getting done :)

Any better place for this tutorial?
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: sAce on July 18, 2010, 03:50:13 PM
Two boards can accept this, Install & upgrade or Tips and tricks
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on August 01, 2010, 01:11:54 PM
Quote from: S-Ace on July 18, 2010, 03:50:13 PM
Two boards can accept this, Install & upgrade or Tips and tricks

Request to move to Tips and Tricks then? ...
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: epidemdown on September 01, 2010, 07:17:32 AM
how i go to phpmyadmin
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: yakyakyak on September 01, 2010, 07:21:19 AM
Please read the tutorial step-by-step

Every stage is so well documented

Quote
Now, We have the installer files ready its time to setup our database for smf to use, this is simple too. We simply go to phpmyadmin and add an account.

http://localhost/phpmyadmin/ is the default address

Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Reefie on September 01, 2010, 03:15:23 PM
simple and effective thanks for sharing
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on September 02, 2010, 12:49:27 AM
Quote from: Reefie on September 01, 2010, 03:15:23 PM
simple and effective thanks for sharing

Thank you, I'm glad this could help you :)


Feedback is welcomed, I'm sure I have documented everything well, if you don't think so, please reply and tell me :)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: KensonPlays on September 06, 2010, 03:10:44 AM
JohnCcCcCc, did you know in xampp settings you can create a password for the root? Look around, you can find it :)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on September 06, 2010, 11:43:48 AM
Yes, I know that, but I used this way so I can show members how to create additional accounts also, this way people reading the tutorial can learn more from it ;)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: lucas-ruroken on September 08, 2010, 09:52:42 PM
Good tip, I prefer Easy php 2.0 Beta :P
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: KensonPlays on September 09, 2010, 12:26:38 PM
Ok, I kept "root" and changed password, because it is faster to type "root" rather than "kcmartz" or "administrator".
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on September 09, 2010, 12:30:26 PM
The add user was intended for learning purposes, also, for testing, you can set your smf pass and username the same and have your browser remember it, Read a few posts up, I already explained this, the quickest way to set up a forum from scratch.

I have managed to do it in less than 10 seconds ;)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: KensonPlays on September 09, 2010, 12:37:18 PM
Install a whole SMF? wow. It takes me around 2-3 minutes!
Both localhost, and a live site!
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on September 09, 2010, 12:38:48 PM
See, I don't post this information for nothing, it all has a purpose, you just need to read "all" the details, in 1st post and replies.
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: KensonPlays on September 09, 2010, 01:12:33 PM
... i read them. i was just stating that.

lets GET BACK on TOPIC now ok?
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on September 09, 2010, 01:20:52 PM
Quote from: Kcmartz on September 09, 2010, 01:12:33 PM
... i read them. i was just stating that.

lets GET BACK on TOPIC now ok?

Actually we're still on topic for the most part, but if it was off it would be you needing to get back on topic :P
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 08, 2010, 11:34:27 PM
I'm using XAMPP and I have gotten fresh installs to work. But I really need an exact copy of the one I'm currently using.

I tried to just copy all files and put it in the directory I'm supposed to. But I can't do that because #1 all the database data is different and #2 there is no install file. There might be more issues too but I'm not sure.

So, how do I exactly go about doing this?
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on October 09, 2010, 03:33:09 PM
Well, you will need to transfer your database to your local host also you can make a backup from your online forum using phpmyadmin, then simply import that into your localhost also using phpmyadmin.
Everything should go well if you download your forum files and place them into the directory where you want your forum.
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 09, 2010, 04:15:22 PM
Quote from: ɔɔɔɔɔɔuɥoɾ on October 09, 2010, 03:33:09 PM
Well, you will need to transfer your database to your local host also you can make a backup from your online forum using phpmyadmin, then simply import that into your localhost also using phpmyadmin.
Everything should go well if you download your forum files and place them into the directory where you want your forum.

Thats what I was thinking. Am I going to have issues with the database name and username/password in the SMF files vs the local database?
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: xenovanis on October 09, 2010, 04:17:52 PM
You can import the database in phpMyAdmin. Just setup a new database, you can use the same name if you want.

After restoring the database, run repair_settings to set up a connection to it and to restore the paths and urls.

What is repair_settings.php? (http://www.simplemachines.org/community/index.php?topic=18096.0)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 09, 2010, 08:12:53 PM
Ok, when I go into the phpMyAdmin of my localhost, I click on the database I want, and choose to import. I upload my real database...but it never actually uploads? All it says in the bar at the bottom is "sending request to localhost" and nothing ever happens....
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 12:53:10 PM
Ok, turns out the database I guess was too big at 40mb, so I zipped it and was able to import it this time.

I named my database the same name as my live forum, added all my backed up files, and ran repair_settings.php I still get a Connection error:

Connection Problems
Sorry, SMF was unable to connect to the database. This may be caused by the server being busy. Please try again later.

The paths and URLs are set & the username is root and no password database name is the same as the old one and same as the one I just set up...

I do notice if I go into the local phpmyadmin there are only 61 tables instead of 70 something on my live site.

Any suggestions on something I could be doing wrong?
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: xenovanis on October 10, 2010, 02:25:54 PM
Are you sure your database name is the same? On hosting packages, databases usually have a prefix which they don't specifically have on your localhost.

If your database is too large to import through phpmyadmin, you can use the source command to import the database:
Copy the database sql file to the /xampp/mysql/bin directory
Windows -> Start -> Execute -> cmd
Go to the mysql bin directory using cd commands (like cd xampp -> cd mysql -> cd bin)
Enter commend: mysql -u root -p
Enter command: connect {database}  (database name here)
Enter command: source (databasebackup.sql} (filename of the backup here)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 02:34:37 PM
Yup, my database is NAME_NAME and so when I made the new one I just copy and pasted it into the local phpmyadmin (and double checked it was right on my live forum) and when I did the repair settings I made sure it was the same as well, it auto filled out my old password and username, and I'm guessing since its all local I would just input the "root" as user and no password, When I leave it auto filled out it gives me an error that the SQL info isn't correct.

Could it have something to do with the fact that Flashchat & coppermine are integrated but I haven't put up databases for those? I'm not interested in having those in the test area anyhow

I notice that the following tables are missing as well:
smf_message_icons
smf_moderators
smf_ob_googlebot_stats
smf_package_servers
smf_permissions
smf_personal_messages
smf_pm_recipients
smf_polls
smf_poll_choices
smf_sessions
smf_settings
smf_smileys
smf_themes
smf_topics
smf_xlinks
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: xenovanis on October 10, 2010, 02:38:29 PM
Well, that should work then. No idea why it's not working. Unless the most essential tables from your database are missing.

After saving repair_settings the first time, where you corrected the mysql settings, at the bottom of the page, were there more links to correct? If SMF can't find the database, repair_settings will only show the fields for the mySQL info and the path and url to your forum. If the MySQL information is entered correct, after saving, additional fields for avatars, attachments and themes paths and url's will should appear.
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 02:45:34 PM
Whoops, updated my above post with more info.

There are three links to correct, the forum url, forum directory and sources directory, thats all that shows at the bottom. But there are no errors showing on the page
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: xenovanis on October 10, 2010, 02:48:44 PM
Weel, before trying to connect, you should import the database properly. The settings table is a keytable, without that your forum won't function anyway.
See my previous post on using the source command:
http://www.simplemachines.org/community/index.php?topic=391328.msg2814098#msg2814098
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 02:52:16 PM
I went in, selected the missing tables, and exported them then imported them. When I saw that was one of the missing tables I figured that was my issue. Repair settings does work.

However, now I have a new problem LOL. As soon as I get into the forum it tells me I'm banned. I'm guessing I need to edit a table to fix this issue, but I'm not quite sure what I'm doing. I'm gonna attempt to just delete the ban table, and hope that works. I guess I can always import it again if not lol

Thank you for your help. I'm learning a lot though :)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: xenovanis on October 10, 2010, 02:57:44 PM
Using source is cool though. You get all these lines running in your screen, like in DOS :)

Since it's your local host, you could truncate the smf_ban_items table. This should clear all bans.
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 03:04:21 PM
Quote from: xenovanis on October 10, 2010, 02:57:44 PM
Using source is cool though. You get all these lines running in your screen, like in DOS :)

Since it's your local host, you could truncate the smf_ban_items table. This should clear all bans.

Hum, Not sure what you mean. I emptied both ban tables, then tried again...couldn't get in. Then I dropped both tables, and couldn't get in...
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: xenovanis on October 10, 2010, 03:09:15 PM
Well, dropping tables that are part of the installation wouldn't be a good idea now, would it?

Did you try clearing your cache after truncating the ban tables?
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 03:19:10 PM
I just figured I'd give it a test to see if it would work LOL. But nothing.

I did clear everything with ATFcleaner and nope, still says "sorry guest you are banned" if I try to login with my info says the same thing...
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: xenovanis on October 10, 2010, 03:22:49 PM
Odd.. Can you see what's logged in the smf_log_bans table? Just sort by id from high to low.
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 03:31:16 PM
This is what I see in that table

(https://www.simplemachines.org/community/proxy.php?request=http%3A%2F%2Fwww.shiversofhorror.com%2Fdatabase.jpg&hash=8539ac987c26e685e41f1aa5ea067440ed898713)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: xenovanis on October 10, 2010, 03:32:57 PM
Click browse to see the content. This is the structure ;)
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 03:35:12 PM
Hahaha, oopsy. Nope, if I try to click on that I get an X and can't see it
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: xenovanis on October 10, 2010, 03:40:09 PM
So, you see a message you're banned, yet no trigger is logged?

Can you see the latest errors added to the smf_log_errors board?
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 03:48:11 PM
Yup, I can see the latest. Just says the same thing, that "Sorry Guest, you are banned from using this forum!" and the localhost IP 127.0.0.1 and the session number
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: xenovanis on October 10, 2010, 03:52:52 PM
Hey, what's the table fc_bans doing? Anything in there perhaps?
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 04:10:33 PM
Can't browse that one so I'm not sure. But that should just be flashchat
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: Kat9119 on October 10, 2010, 06:07:13 PM
Ok, so, I went into my live site. Browsed the ban triggers. Someone had banned the IP of the localhost and it was a migrated ban from yrs ago when we used phpBB. So I unbanned it. Exported the database again, and imported it and reran repair_settings.php

Most of it seems to be fine, except some small template issues which I have no idea why they'd look different...for example, I have the random quote mod installed, and the background color for it is wrong. Also, the whole forum should be in a table, and its not...these are the #1 reasons I wanted to have a local forum so I could test how mods would look being that its in a table and some mods don't work well with it.

So, I need to figure these things out. I figured maybe it had something to do with the theme settings. So I went into the admin panel for that, and switched everything to the localhost (thought repair settings should have done that) but it still didn't fix it. 

I was going to attach two pics, but now there are no options to do that...so maybe its not allowed now...weird

EDIT: Ok, all fixed! I had to go into Themes & Settings and click on "attempt to reset" thank you SO much for sticking with me and helping me out! Much much appreciated
Title: Re: SMF tutorials: How to setup a localhost for testing
Post by: ɔɔɔɔɔɔuɥoɾ on October 11, 2010, 01:23:33 PM
I get here all late, but welldone :)
Now you can do all your testing :)