Welcome to the companion CD for Core Web Application Programming with PHP and MySQL
by Marc Wandschneider. Copyright (c) 2005 Prentice-Hall Inc.
-----------------------------------------
SIMPLEBLOG ENGINE SAMPLE
SETUP INSTRUCTIONS
-----------------------------------------
You will need to do three things to complete the setup of
this sample:
1. Set up the database for the application
(run setup/simpleblog.mysql).
2. copy the include files to your PHP include_path
(put them in a subdirectory called simpleblog/).
3. copy the web application files to your document root
(run index.php to test).
We assume you have copied the source for this book into:
Unix: /home/marcw/phpwebapps
Windows: c:\Download\PHPWebApps
OS X: /Users/marcw/Download/PHPWebApps
Replace the directory with whatever is appropriate for
your setup.
More detailed instructions are as follows:
1. DATABASE SETUP
=================
1.1 MySQL
In the setup/ subdirectory of this sample is a file called
simpleblog.mysql which you can execute. You need to know
where your mysql client program is and you need to have
the username and password of an account with permissions to
create a database.
We will demonstrate with the root account:
Unix:
cd /home/marcw/phpwebapps/simpleblog/setup
/usr/local/mysql/bin/mysql -u root -p
Enter password: ********
Windows:
pushd c:\Download\PHPWebApps\simpleblog\setup
c:\usr\mysql\bin\mysql.exe -u root -p
Enter password: ********
OS X:
(Start Terminal Application in Applications/Utilities)
cd /Users/marcw/Documents/PHPWebApps/simpleblog/setup
/usr/local/mysql/bin/mysql -u root -p
Password: ******
From here, we execute the same on either platform:
mysql> \. simpleblog.mysql
Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Database changed
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.06 sec)
Query OK, 0 rows affected (0.05 sec)
Query OK, 1 row affected (0.03 sec)
2. INCLUDES/LIBRARIES SETUP
===========================
The exact paths for this section will depend exactly
on how you want your web server's document root
directory to be organised. We have set up the following:
Windows:
D:\WebAppliactions
D:\WebApplications\Includes (PHP includes)
D:\WebApplications\WWW (Web Server DocumentRoot)
Unix:
/home/httpd/webapps
/home/httpd/webapps/includes (PHP includes)
/home/httpd/webapps/www (Web Server DocumentRoot)
OS X:
/Library/WebServer/
/Library/WebServer/Includes (PHP includes)
/Library/WebServer/Documents (DocumentRoot)
2.1 include_path in php.ini
We will thus need to make sure that the include_path
in our php.ini file looks as follows:
Windows:
include_path=".;c:\php\includes;c:\php\pear;d:\webapplications\includes"
Unix:
include_path=".:/usr/local/lib/php:/home/httpd/webapps/includes"
OS X:
include_path=".:/usr/local/php5/lib/php:/Library/WebServers/Includes"
2.2 Copy over files from libs/
We will then make a subdirectory of this new includes
directory called simpleblog/ and copy the files from the
libs/ directory of the sample into it, as follows:
Windows (cmd.exe prompt):
pushd d:\webapplications\includes
mkdir simpleblog
chdir simpleblog
xcopy c:\download\phpwebapps\simpleblog\libs
Unix:
cd /home/httpd/webapps/includes
mkdir simpleblog
ch simpleblog
cp /home/marcw/phpwebapps/simpleblog/libs/* .
OS X:
cd /Library/WebServer/Includes
mkdir simpleblog
cd simpleblog
cp /Users/marcw/Documents/PHPWebApps/simpleblog/libs/* .
2.3 Important: Check File Permissions
You will need to make sure that the web server has
permissions to access this directory. On Unix, you
will want to make sure that the group that the web
server operates as has at least read permissions while
on Windows you will want to give the user that the web
server uses as an anonymous user can at least read
all of the directories.
Unix:
cd /home/httpd/webapps/includes
chgrp -R nobody . # or httpd, depending on setup
chmod -R g+r .
Windows:
- Right click on d:\webapplications\includes in the Windows
Explorer and select the Security tab. (**)
- click "Add" and enter IUSR_HOSTNAME (where HOSTNAME is
the name of the server computer).
- Select this name in the "Group or User Names" box and
give them at least "Read & Execute" permissions.
(**) If you do not see the Security Tab, then click on
Tools/Folder Options, and in the "View" tab, make sure that
"Use Simple File Sharing" is UNCHECKED.
OS X:
cd /Library/WebServer/Includes
chgrp -R admin . # or httpd, depending on setup
chmod -R g+r .
3. CONTENT FILES SETUP
======================
3.1 Copying Content:
In this last step, we just need to copy the actual web
application files to our DocumentRoot directory.
Unix:
cd /home/httpd/webapps/www
cp /home/marcw/phpwebapps/simpleblog/webapp/* .
Windows (cmd.exe):
pushd d:\webapplications\www
xcopy c:\download\phpwebapps\simpleblog\webapp
OS X:
cd /Library/WebServer/Documents
cp /Users/marcw/Documents/PHPWebApps/simpleblog/webapp/* .
3.2 Important: Check File Permissions
You will need to make sure that the web server has
permissions to access this directory. on Unix, you
will want to make sure that the group that the web
server operates as has at least read permissions while
on Windows you will want to give the user that the web
server uses as an anonymous user can at least read
all of the directories.
Unix:
cd /home/httpd/webapps/www
chgrp -R nobody . # or httpd, depending on setup
chmod -R g+r .
Windows:
- Right click on d:\webapplications\www in the Windows
Explorer and select the Security tab. (**)
- click "Add" and enter IUSR_HOSTNAME (where HOSTNAME is
the name of the server computer).
- Select this name in the "Group or User Names" box and
give them at least "Read & Execute" permissions.
(**) If you do not see the Security Tab, then click on
Tools/Folder Options, and in the "View" tab, make sure that
"Use Simple File Sharing" is UNCHECKED.
OS X:
cd /Library/WebServer/Documents
chgrp -R admin . # or httpd, depending on setup
chmod -R g+r .
4. RUNNING THE WEB APPLICATION
======================
To run the web application, you will need to launch a
web browser on your computer, and then type in something
similar to the following:
http://[hostname]
For example, if the web server is running on the same
machine you are using to browse the web:
http://localhost
If your web server is not configured to automatically
detect and run files with the name index.php, you can type
in:
http://localhost/index.php
Please see Appendix I in the book for more instructions
on how to configure your web server to run PHP scripts.
PHP做的一个小博客
5星 · 超过95%的资源 需积分: 10 77 浏览量
2008-10-26
16:48:35
上传
评论 1
收藏 39KB RAR 举报
nabice
- 粉丝: 8
- 资源: 4
评论2