Transcript

1.
Installing Stuﬀ
Alex S.∗
1 Introduction
This document will help/guide you to install Apache, MySQL, PHP, and Perl. The assump-
tion is that you’re running Windows2000 (or WindowsXP). If you’re on Linux, you likely
have all these things already installed (they’re pretty easy to install anyway; just read the
documentation)
I tried to use the latest version at the time of writing this document. Later versions
shouldn’t be that much diﬀerent to install. You are encouraged to repeat this installation
several times (and possibly on diﬀerent systems—try setting up a Linux machine with all
these things) to get a good hang of how things work.
2 Apache
Apache is a Web Server, which you can download from:
http://www.apache.org/
For this tutorial, we will use Apache2, but the procedures are the similar (or exactly the
same) as previous versions.
2.1 Installation
Installation of Apache under Windows involves double clicking on the:
apache_2.0.54-win32-x86-no_ssl.msi
The version you have may be diﬀerent, but the process is the same. Follow the screens and
accept all defaults until the dialog that asks you for location where to install Apache. The
default is:
C:Program FilesApache Group
∗
alex@theparticle.com
1

2.
2.2 Testing 3 MYSQL
You don’t want this. You want to set it to:
C:
This will create directory C:Apache2, which is nice and short, compared to the alternative.
After the installation, the “Installation Completed” dialog box should come up with a
“Finish” button; congratulations, you have just installed Apache Web Server.
2.2 Testing
You can test your install of Apache by going to:
http://localhost/
Or
http://127.0.0.1/
You should see a “Test Page for Apache Installation.”
2.3 Troubleshooting
The installation or instantiation might fail if you have other web-server running on the
computer—like a previous version of Apache, or more likely, MicrosoftTM Internet Informa-
tion Server (IIS). You should disable or remove that before installing Apache. A way to
disable these things should be somewhere in the Control Panel.
2.4 Starting & Stopping
You can start/stop the server from command prompt (a.k.a. The DOS Box) by typing:
net start apache2
Or
net stop apache2
3 MySQL
MySQL is a Database Server, which you can download from:
http://www.mysql.com/
For this tutorial, we will use MySQL 5. This latest version makes installing much simpler
compared to previous versions.
2

3.
3.1 Installation 3 MYSQL
3.1 Installation
Installation of MySQL5 under Windows involves double clicking on the:
mysql-5.0.6-beta-win32.exe
The version you have may be diﬀerent, but the process is the same. Follow the screens and
accept all defaults. You can skip the sign-up process.
After the installation, you are asked to conﬁgure the server. Select that option, and
proceed to the conﬁguration wizard.
3.1.1 Conﬁguration
In the conﬁguration wizard, select “Standard Conﬁguration.” In the following screen, you
should “Install as Windows Service,” and “Include Bin Directory to Windows PATH,”—this
will make it much easier to work with MySQL.
You will also be asked to provide the “root” (the MySQL administrator) password. Spec-
ify something easy to remember. While you’re getting started, I recommend using “12345”;
that way you won’t get locked out of your own server1 .
At the end of the conﬁguration wizard, you are asked to “Execute” all the conﬁgurations
that you’ve speciﬁed. Do that now.
Congratulations, your server is now installed and conﬁgured (and hopefully running).
3.2 Testing
You can test the MySQL server by logging in. Start a Command Prompt (DOS Box), and
type:
C:>mysql -uroot -p mysql
This will ask you to enter the password (do that), at which point it should display a screen
that looks something like this:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id is 5 to server version: 5.0.6-beta-nt
Type ’help;’ or ’h’ for help. Type ’c’ to clear the buffer.
mysql>
This is the MySQL prompt, where you can type in any commands, including SQL statements.
A simple list of commands to create a test database, and try it out is:
1
Note that for a production server, you should use a more creative password.
3

5.
3.3 Troubleshooting 4 PHP
3.3 Troubleshooting
The ﬁrst thing to check is whether your MySQL server is running. Check out Section 3.4
for information on starting/stopping the service.
Another thing that could be wrong is that MySQL didn’t setup the PATH environment
variable. In Command Prompt, try going to:
C:Program FilesMySQLMySQL Server 5.0bin
and running all the commands from there.
3.4 Starting & Stopping
You can start/stop the server from command prompt (a.k.a. The DOS Box) by typing:
net start mysql
Or
net stop mysql
4 PHP
PHP is PHP Hypertext Processor, which you can download from:
http://www.php.net/
For this tutorial, we will use PHP 5. Installing previous versions is very similar.
4.1 Basic Installation
Installation of PHP 5 under Windows involves unzipping:
php-5.0.4-Win32.zip
Into some nice convenient place, like:
C:php
Inside the c:php directory, you will ﬁnd install.txt ﬁle, that describes exactly, step by
step, what you need to do to properly install and conﬁgure PHP with any number of servers.
For this tutorial, we are using Apache2 (installed in Section 2), and MySQL5 (installed in
Section 3).
5

6.
4.2 Basic Testing 4 PHP
4.1.1 php.ini
In the C:php directory, make a copy of php.ini-dist, and name the copy php.ini. Open
php.ini in your favorite text editor2 .
You need to set doc_root to Apache’s htdocs directory. In other words:
doc_root = "C:Apache2htdocs"
You need to set extension_dir to:
extension_dir = "C:phpext"
You’ll also need to setup session support. You need to create directory:
C:Tempphp_session
And then you need to look for session.save_path line, and set it to:
session.save_path = "C:Tempphp_session"
4.1.2 httpd.conf
We also need to conﬁgure Apache2 to work with PHP. This involves editing:
C:Apache2confhttpd.conf
At the end of the “Loading Modules” section, you need to add:
# For PHP 5 do something like this:
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"
4.2 Basic Testing
PHP and Apache should now be conﬁgured. You should restart Apache, at Command
Prompt run:
net stop apache2
net start apache2
If everything goes ok, open your web browser to:
http://localhost/asdf
2
If you don’t have a favorite editor, just open it in Notepad.
6

7.
4.3 Conﬁguration 4 PHP
This should give you an Apache error message, but it should also give you the server signa-
ture, which should include PHP. Ie:
Apache/2.0.54 (Win32) PHP/5.0.4 Server at localhost Port 80
A more involved test requires you to write a simple PHP script. Take the following and
place it in:
C:Apache2htdocsphpinfo.php
The contents of the script is just one line:
<?php phpinfo(); ?>
Now, going to:
http://localhost/phpinfo.php
should provide a much better view of what you just installed.
4.3 Conﬁguration
Yes, we’re not done with conﬁguration just yet. We need to ensure MySQL module (and
library) are properly setup and running. For this, we need to update the php.ini ﬁle again.
You’ll need to ﬁnd the line:
;extension=php_mysql.dll
and change it to:
extension=php_mysql.dll
In other words, remove the ; character that comments out that line.
Also, now that we installed MySQL 5, we don’t need the MySQL client library that PHP
ships with (which I think is “Client API version: 4.1.7”—we have MySQL5, might as well
use the proper client libraries).
Stop Apache2, and erase ﬁle:
C:phplibmysql.dll
And start Apache2 once again.
Once done, if you go to that phpinfo.php page, under MySQL, it should display:
Client API version: 5.0.6-beta
(or the version of MySQL that you installed.
The reason the above works is because when we installed MySQL, we put its bin
directory into the PATH. Without that, those MySQL libraries would not be found. If having
problems getting this to work, you can try moving the:
C:Program FilesMySQLMySQL Server 5.0binlibmySQL.dll
To some place like:
C:WindowsSystem32
Do not do this unless you’re having problems starting Apache.
7

8.
5 PERL
5 Perl
Perl is a Scripting Language, which you can download from:
http://www.activeperl.com/
For this tutorial, we will use ActivePerl 5.8.7.813, but the procedures are the similar (or
exactly the same) as previous versions.
ActivePerl is a pretty good Windows version of Perl. Since Perl is open source, there
are many distributions. ActivePerl is a Microsoft sponsored port of the generally UNIX Perl
version to Windows.
5.1 Installation
Installation of Perl under Windows involves double clicking on the:
ActivePerl-5.8.7.813-MSWin32-x86-148120.msi
The version you have may be diﬀerent, but the process is the same. Follow the screens and
accept all defaults.
5.2 Testing
You can test Perl by opening the Command Prompt, and typing:
C:>echo print qq{Hello World $_n} for(1..5) |perl
Which should display something like:
C:>echo print qq{Hello World $_n} for(1..5) |perl
Hello World 1
Hello World 2
Hello World 3
Hello World 4
Hello World 5
Or you could just type:
C:>perl --version
But that’s not as fun :-)
8

10.
7 CONCLUSION
http://localhost/glah.php
The page displays:
Connected successfully
1 meh
2 beh
This is exactly what’s in those tables :-)
7 Conclusion
If everything in these pages worked, then you’re ready to move onto the next round. Other-
wise, I suggest re-installing things until things start to work.
Everything in these pages was tested as I write this (on a fresh install); so things should
work if you follow the exact steps. Good luck.
If things still don’t work, you can try installing:
http://sourceforge.net/projects/quickeasyphp/
This is an all-in-one installer for Apache/PHP/MySQL. This may seems like a quick time-
saver, but I still highly recommend that you install things separately.
10