Here’s the first part of my “Setting Up” tutorials. It will teach you how to set up to learn PHP, and for web development. It is my own personally journey as well because I’m getting ready to make new WordPress themes. I’m using Windows XP, soon will be upgrading to Windows 7 (when it comes out) so most of my tutorials will be Windows-oriented.

Installing the Server Software

The best way to learn PHP and scripting is at home and without buying a domain nor paying for hosting. So let’s set up your computer as a server using XAMPP. XAMPP stands for X (as in a variable instead of an OS name) Apache, MySQL, PHP, and PERL. You can use any other alternative depending on your operating system. There’s also WAMP for Windows (I use this one) and MAMP for Mac. All are basically the same with small differences. I’ll show you how to use XAMPP because it’s the most cross-platform package. I’ll do an article on how to set up your Linux with XAMPP later.

So what are these packages? They install the Apache Server, MySQL database system, and PHP all in one. The packages are all set-up to interact and will save you a ton of time. You won’t have to install each program separately and try to intertwine them. It will all be done for you. Go to the XAMPP website, select Windows and download the newest package available. Don’t get distracted by the add-ons.

picture1 Depending on the package that you downloaded, you’ll either have an executable file or an archive (zip). I downloaded the .exe for my windows because it was forty megs lighter and easier to set-up. Let’s move on. If you downloaded the .exe file, open it and install it in a folder. When choosing a destination folder, I recommend using your main drive (usually C:\) and a subfolder. I’m installing my XAMPP package into C:\server\, click install, follow the directions and you’re done. If you used the .zip download, extract all of the contents into a folder (C:\server\ for me) and follow the read me which tells you to use a couple .bat files to set-up everything. Once you’re done, start up the XAMPP Control Panel (it will be under start>programs>Xampp for Windows> Xampp Control Panel). If you’re having problems with the Control Panel, start the MySQL and Apache services by double-clicking on apache_start.bat and mysql_start.bat in the main folder.

Here’s what the control panel looks like, it will list a different Windows version etc. but that’s alright:

picture2You can start up all the services shown by just clicking on start. I had some problem with it so I used the .bat files instead. Now point your web browser to http://127.0.0.1/ and you’ll see a XAMPP splash page, pick the language and let’s get going. I’ll cover all the features of XAMPP later tutorials, so for now, be happy that it works :)

Keep your browser there and read on. Put all your PHP files and other files in …/xampp/htdocs/yourfoldername/ I set mine up /xampp/htdocs/learningPHP and I put an index.php file in there that will link me to all my scripts and tutorials that I absolved (ie. <a href=”tutorial1.php”>tutorial one</a>). This will keep your folders organized and it’ll be easier to find these files. Type in http://127.0.0.1/learningPHP and you’ll get to your index.php file there. Unlike WAMP, XAMPP doesn’t seem to have a listing directory on its server but don’t worry too much about that. We’re set-up and ready to go. If you didn’t get any of this, don’t worry about it. Just remember to make a new folder in /htdocs/ where you can store your php scripts and other stuff. Also, remember that unless you set up your apache and mysql as services (the process is in the readme file and included in the .exe installation), you’ll have to start them every time you start up your computer.
To get rid of XAMPP, simply delete the folder or use the provided “uninstall_xampp.bat” file

Setting up the Database

While in your browser is at http://127.0.0.1/xampp/ Click on PHPmyadmin and follow these directions.

  1. click on the “privileges” tab
  2. add a new user
  3. type in your user name, I’ll use the user name “Alexander”
  4. under the host tab, click “local” and it’ll fill out localhost in the field next to it
  5. type in a password, I’ll use “davepcguy”
  6. Database for user: none
  7. check all privileges (it’s the easiest and as long as you don’t put your server online, it’ll be safe)
  8. click “Go”
  9. go back to “Databases”
  10. under Create New Database, create one, I created “WP” for my WordPress

Now I have a database named “WP” under the username “Alexander” with the password “davepcguy”

Your database list should look like this:

databasesThe first five databases are preset, and my “wp” database is the one I made.

Setting up WordPress:

First, go download WordPress.

then:

  1. extract the zip file into htdocs
  2. change “wp-config-sample.php” to “wp-config.php”
  3. open the file with your PHP editor. You can also use your text editor if you don’t have a PHP editor yet. I’ll post a short tutorial on setting up your PHP editor later.
  4. find this section:
     // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'putyourdbnamehere');
    
    /** MySQL database username */
    define('DB_USER', 'usernamehere');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'yourpasswordhere');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
    
    /** Database Charset to use in creating database tables. */
    define('DB_CHARSET', 'utf8');
  5. Change “putyourdbnamehere” to the database name you created, in my case it would be “wp”
  6. Change “usernamehere” to the username we set up earlier, in my case that would be “Alexander”
  7. Change “yourpasswordhere” to your password we set earlier, in my case it would be “davepcguy”
  8. save the file and your result should look like this:
    // ** MySQL settings - You can get this info from your web host ** //
    /** The name of the database for WordPress */
    define('DB_NAME', 'wp');
    
    /** MySQL database username */
    define('DB_USER', 'Alexander');
    
    /** MySQL database password */
    define('DB_PASSWORD', 'davepcguy');
    
    /** MySQL hostname */
    define('DB_HOST', 'localhost');
  9. go to: http://127.0.0.1/wordpress

Now let’s install WordPress. Type in the blog title and your e-mail. Press “install”. It will give you a randomly generated password. Copy that password and click “Log in”. Type “Admin” as user name and paste the password. Viola, you got your own home WordPress blog set up!

A couple of tips:

  • go change your password immediately, there should be a link on top of the page to do that
  • your wordpress password and your MySQL password are NOT the same
  • you can always change your e-mail and password under Users>your profile
  • before you start posting blog-posts, change your nickname from “admin” to something else
  • to log in next time, go back to “http://127.0.0.1/wordpress” and find the login button at the bottom of the right sidebar

That’s all you need to start messing around with PHP and WordPress for now. Have fun figuring out WordPress, I’ll have a tutorial ready later to explain how to use its functions fully but you probably won’t need that. Also, note that this set-up is for home use only. I’d suggest a better username and password if you were to host your blog online. Setting up a WordPress blog online is a bit different, there is no “phpmyadmin” and you’ll have to create a database differently, and probably using software your host provides. Enjoy! :)

http://127.0.0.1/wordpressgo
Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Reddit
  • Tumblr
  • Twitter
  • email
  • Slashdot
  • StumbleUpon