Install - Just Us Two Photography

advertisement
ECA 236
Open Source Server Side Scripting
Installation and Testing
Open Source Server Side Scripting
PHP / MySQL / Server
Response
.html
Local
Browser
Remote
Server
.php
PHP
engine
SQL
results
Request
MySQL
DB
ECA 236
Open Source Server Side Scripting
2
MySQL
 database
of choice for majority of PHP users
 efficiency
and ease of use
 free
 runs
on multiple platforms
 documentation
 software
consists of 3 pieces
 MySQL server
 MySQL monitor
 numerous
ECA 236
utilities
Open Source Server Side Scripting
3
Installing MySQL
 MySQL version
5.0, distributed by MySQL AB
 www.mysql.com
 dev.mysql.com/downloads
 Current Release
 Windows Downloads
 Windows Essentials: contains essential elements to run MySQL on
Windows
 Extract files, double click setup.exe
 Install MySQL, noting any relevant information
 To start MySQL navigate to C:\mysqlbin or C:\Program Files\MYSQL\
 Double click WinMySQLadmin to start MySQL server with GUI interface
ECA 236
Open Source Server Side Scripting
4
PATH
Start
R
click My Computer L click Properties
Advanced
Environment Variables
Path
Edit
Add C:\mysql\bin or proper path
ECA 236
Open Source Server Side Scripting
5
 Using
Testing MySQL
the command line
Open Command Prompt
Change Directory to c:\mysql\bin unless PATH has been
changed
if mysql was installed as a service, it is already running in
the background
otherwise, type mysqld to start the server
 Create a test Database
mysql monitor: type mysql
at this point, all commands must end with a ;
ECA 236
Open Source Server Side Scripting
6
Testing MySQL
testDB
test_id
ECA 236
cont …
test_table
test_note
1
This is note 1
99
And another note
13
And yet another
Open Source Server Side Scripting
7
Testing MySQL
cont …
Type
use testDB;
Create a test table:
CREATE table test_table (test_id INT, test_note TEXT);
Verify creation of table:
SHOW tables;
Verify field names and types:
EXPLAIN test_table;
ECA 236
Open Source Server Side Scripting
8
Testing MySQL
cont …
 Insert
a row:
INSERT INTO test_table VALUES (‘1’, ‘This is note 1’);
 Insert another row:
INSERT INTO test_table VALUES (‘99’, ‘And another note’);
 Insert one more row:
INSERT INTO test_table VALUES (‘13’, ‘And yet another’);
 Select data from test_table:
SELECT * FROM test_table;
 Order by ID:
SELECT * FROM test_table ORDER BY test_id DESC;
ECA 236
Open Source Server Side Scripting
9
Installing Xitami
 download
and install Xitami from my web site
www.justustwo.com/mbarath.htm
 if another web server (such as IIS) is already running, we must
change the port from the default of 80 to 88
open xitami.cfg in the C:\Xitami directory
open defaults.cfg
add the following lines to default.cfg:
[Server]
portbase=8
ECA 236
Open Source Server Side Scripting
10
Installing Xitami
cont …
Start Xitami
(green icon in taskbar)
Point your browser to http://localhost:88/
Bookmark this page in Favorites  Links
All web pages must be stored in the webpages folder
of Xitami, or its subfolders
ECA 236
Open Source Server Side Scripting
11
Installing PHP 5 . x . x



Current version is PHP version 5.x.x
www.php.net/downloads.php
Download Windows Binaries
 PHP 5.x.x zip package
 Create a directory named C:\php
 Extract files to this directory
 resave a copy of php.ini-recommended to php.ini
 open php.ini
uncomment extension=php_mysql.dll (app. line 657)
 Set PATH
 C:\php\bin
C:\php\ext
 Restart computer
ECA 236
Open Source Server Side Scripting
12
Installing PHP 4 . 4 . 4
 If
you want to install an earlier version of PHP
 www.php.net/downloads.php
 Download Windows Binaries
PHP 4.4.4 installer
Extract files
follow directions
set PATH
ECA 236
Open Source Server Side Scripting
13
 Xitami
Testing PHP
make config changes
to defaults.cfg or defaults.aut if
necessary
In defaults.cfg add:
[Filter]
.php=c:\php\ php.exe
All php files must be run from C:\Xitami\webpages
directory
Access server through localhost:88 or 127.0.0.1:88
When typing in URL, do not add “webpages” to URL
ECA 236
Open Source Server Side Scripting
14
Testing PHP cont …
In
php.ini, set cgi.force_redirect to 0
make sure it is not commented out with a semicolon
In a text editor create an HTML document with the
following code in the <body>
<?php
phpinfo( );
?>
Name it phpinfo.php, save in C:\Xitami\webpages
Run it: http://localhost:82/phpinfo.php
ECA 236
Open Source Server Side Scripting
15
Download