MY SQLPart 1 - GETTING STARTED - Page 2 CONFIGURE APACHE Locate the file C:\Apache\conf\httpd.conf and open it with Notepad or WordPad. Find the line AddModule mod_setenvif.c Add the following 3 lines: LoadModule php5_module c:/php/php5apache.dll AddModule mod_php5.c AddType application/x-httpd-php .php .phtml Save the file. CONFIGURING PHP.INI Open C:\Windows\php.ini with Notepad Locate [mail function] My outgoing mail is smtp.ntlworld.com and my email is jim@mp3science.com so my php.ini file reads: [mail function] ; For Win32 only. SMTP = smtp.ntlworld.com Smtp_port = 25
; For Win32 only. sendmail_from = jim@mp3science.com
Locate doc_root and change the line to read:
doc_root = "C:\Apache\htdocs"
Locate extension_dir and change it to read:
extension_dir = "C:\php\ext"
Locate the list of extensions and change the appropriate one to read:
extension= "php_mysql.dll"
Notice that the semicolon has been removed from the beginning of these lines! RUNNING MySql This is very important to get right. After installing MySql, restart the computer and wait for the following program to run: C:\mysql\bin\WinMySqlAdmin.exe This program will be the 2nd window to open, the 1st window is mysqld-opt.exe. Eventually a 3rd window will appear, asking you for a user name and password. The data that you enter is stored in a file: C:\WINDOWS\my.ini If everything has gone correctly, you should see a 'Traffic Light' icon in the right hand start menu. A green light means MySql has started, red means it hasn't. The next time you run the computer, MySql should automatically start, and you should get the green light. MY.INI After downloading a virus, I had to reinstall MySql. However, I couldn't get the program to work again! Eventually, I decided to delete the my.ini file. This did the trick, because MySql uses my.ini during start up. So I can only assume that it was configured incorrectly. I entered the user name and password again, and it seems to be working correctly.
HTDOCS This folder already exists, and is located at: C:\Apache\htdocs, where the server looks for your PHP files. This was set when you configured php.ini You could change that but please make sure you know what you're doing. Otherwise, just put all the PHP files in the htdocs folder. For example, the file below is: C:\Apache\htdocs\phpinfo.php but to run it, you type: http://localhost/phpinfo.php You don't have to tell it to look in 'htdocs' because php.ini tells the server where to look.
TESTING MySql Type the following code into notepad, and save as C:\Apache\htdocs\mysqltest.php <html> <head> <title>MySQL Connection</title> </head> <body> <h2>
<?php $connection = mysql_connect( "localhost", "root", "" ) or die( "Unable to connect to MySQL" ); echo( "Connected to MySQL ok" ); ?> </h2> </body> </html> Now type http://localhost/mysqltest.php and you should see, "Connected to MySQL ok". |