|
发表于 2002-5-12 13:33:07
|
显示全部楼层
Installing Apache, PHP, and MySQL
This is a beginner's guide to installing and configuring the Apache web server, PHP, and MySQL on a Windows platform.
Installing Apache
The latest version of the Apache web server can be downloaded from http://httpd.apache.org/.
Install Apache by double-clicking on the Apache msi file (e.g. apache_1.3.22-win32-x86.msi).
Edit the file httpd.conf in the folder "C:\Program Files\Apache Group\Apache\conf". Change the directive DocumentRoot to point to "C:/WebRoot". This folder (i.e., WebRoot) contains your web documents (e.g., HTML files).
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "C:/WebRoot"
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "C:/WebRoot">
Restart the Apache server (Start:Programs:Apache HTTP Server:Control Apache Server:Restart).
You should now see the index.html file you place in C:\WebRoot when you point your browser to http://localhost/.
Installing PHP
The latest version of PHP can be downloaded from http://www.php.net/.
Install PHP4 by simply unzipping it into a new folder named "C:\Php4Win".
Configuring PHP4 consists of changing a few lines in a text file, renaming it and copying it and another file into the Windows directory.
Copy the file C:\Php4Win\php.ini-recommended to php.ini. Open this php.ini file with a text editor and change the doc_root and extension_dir lines so that they read as follows:
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
include_path = ".;C:\WebRoot"
extension_dir = "C:\Php4Win"
Then move the two files php.ini and php4ts.dll to C:\Windows or C:\WinNT, depending on your Windows flavour. Voila, PHP is now configured.
Although PHP is itself configured, we still will not be able to access it through the Apache server, as Apache has only so far been configured to read static HTML pages. We still need to tell Apache Server what to do when it encounters embedded PHP script in web pages.
Where the httpd.conf file talks about PHP and AddType, add the following lines:
ScriptAlias /php/ "C:/Php4Win/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php.exe"
Restart the Apache server (Start:Programs:Apache HTTP Server:Control Apache Server:Restart).
Now create a one-line test PHP file called "c:\WebRoot\phpinfo.php" with the following contents:
<? phpinfo() ?>
Then open your browser and go to: http://localhost/phpinfo.php You will see a whole bag full of info on your PHP installation.
To use additional *.dlls, put them in C:\Php4Win\ and uncomment their entry in this block of your php.ini file:
;Windows Extensions
;extension=php_mysql.dll
;extension=php_nsmail.dll
;extension=php_calendar.dll
;extension=php_dbase.dll
;extension=php_filepro.dll
;extension=php_gd.dll
...
Installing MySQL
The latest version of the MySQL can be downloaded from http://www.mysql.com/.
Unzip the MySQL distribution, and run Setup.exe. Choose default options through the installation process.
Run winmysqladmin.exe in folder C:\mysql\bin. This starts up the MySQL server. (You will now see mysqld running if you check in the Task Manager)
Create the file c:\WebRoot\testmysql.php with the following content:
<h3>Click on refresh to add entry to database</h3>
<?
mysql_connect("localhost");
mysql_create_db("MyFirstDB");
mysql_select_db("MyFirstDB");
// make a table
mysql_query("create table MyFirstTable(firstName VARCHAR(25), lastName VARCHAR(25))");
mysql_query ("insert into MyFirstTable(firstName, lastName) VALUES ('Tee', 'Tester')");
// show what is in the table
$result = mysql_query ("select * from MyFirstTable");
while($row = mysql_fetch_array($result)) {
print ("Added record: " . $row["firstName"]." ".$row["lastName"]."<br/>\n");
}
mysql_close();
?>
Then open your browser and go to: http://localhost/testmysql.php. Each time you refresh the page, you will see that another record has been added to the database.
Installing MySQLFront
MySQLFront provides a simple interface to access MySQL databases. The latest version of MySQLFront can be downloaded from http://anse.de/mysqlfront/download.php. Install by running the EXE file.
You might want to verify the database entries created in the test phase of MySQL installation using MySQLFront.
Enjoy.
--------------------------------------------------------------------------------
[email protected]
Sat Feb 23 21:44:14 NZDT 2002 |
|