« Home « Kết quả tìm kiếm

Web Database_ Step-by-Step Guide


Tóm tắt Xem thử

- Configuring PHP...10.
- Testing PHP ...11.
- Building the Database ...12.
- Creating the database...12.
- index.php3...15.
- add.php3 ...16.
- covers Apache 1.3.6, PHP 3.0.7 and MySQL 3.22.21.
- The Apache Group (http://www.apache.org/contributors).
- The PHP Development team (http://www.php.net/credits.php3).
- T.c.X DataKonsult AB (http://www.mysql.com/info.html).
- setup the PHP 3.0 Hypertext Preprocessor for server-side-scripting.
- On a brighter note, if you have any questions, comments, or suggestions, please feel free to send me email at [email protected].
- 2 data from the database.
- his web browser sends a request for http://www.foo.com/foofoo.php3..
- Apache gets the request for foofoo.php3.
- It knows that .php3 files are handled by the PHP preprocessor, so it tells PHP to deal with it..
- foofoo.php3 is a PHP script that contains commands.
- The data comes back from the database, and foofoo.php3 does something to format the data.
- First let's grab MySQL, you will find it at http://www.mysql.com.
- The latest version as of this writing is 3.22.21.
- Binary RPM containing the server for i386 machines MySQL-3.22.21-1.i386.rpm.
- Binary RPM containing client programs for i386 machines MySQL-client-3.22.21-1.i386.rpm.
- If you're not using RedHat, download the precompiled binaries (mysql-3.22.21-pc-linux- gnu-i686.tar.gz).
- You will find it at their homepage http://www.apache.org, the latest version as of this writing is 1.3.6..
- If you want to use the Apache RPM, you will have to make appropriate changes to my examples to suite your configuration..
- Finally, get the PHP source distribution from their homepage http://www.php.net.
- You can also get the GD library if you want to be able to create and manipulate GIF files on the fly.
- If you have the GD library, PHP can be compiled to take advantage of it..
- Their homepage is at http://www.boutell.com/gd, download it from there or grab the RPM if you're using RedHat.
- You can also find it on http://www.rpmfind.net/RPM..
- If you downloaded the RPM's, the installation is really easy..
- If you downloaded the binary tarball (because you don't have RedHat), it's a wee bit more involved..
- The RPM installation is the recommended way to go if you are running RedHat, since everything is done for you..
- If you downloaded the binary distribution, it has a name like mysql-3.22.21-pc-linux-gnu- i686.tar.gz.
- cd /usr/local.
- tar -zxvf /tmp/mysql-3.22.21-pc-linux-gnu-i686.tar.gz.
- After it extracts everything, a directory called mysql-3.22.21-pc-linux-gnu-i686 will be created.
- ln -s mysql-3.22.21-pc-linux-gnu-i686 mysql.
- chown -R mysql:root mysql-3.22.21-pc-linux-gnu-i686 mysql.
- There is a startup script in the binary distribution of MySQL called mysql.server.
- cp /usr/local/mysql/support-files/mysql.server mysql Next, make it executable:.
- /etc/rc.d/init.d/mysql start.
- If that worked, you should be able to something like:.
- If you installed the binary distribution, the programs are located in /usr/local/mysql/bin, you may want to this to your path.
- You should see the following:.
- Welcome to the MySQL monitor.
- Your MySQL connection id is 2 to server version: 3.22.21 Type 'help' for help..
- You should see:.
- If you did, then it's working!! Exit MySQL by typing exit:.
- tar -zvxf apache_1.3.6.tar.gz.
- This is really handy, read all about it at the Apache DSO page (http://www.apache.org/docs/dso.html), if you're interested..
- If all goes well, you should see a bunch of messages tell you some information about Apache and how it was installed on your computer.
- If you're using RedHat, make a symlink from /usr/local/apache/bin/apachectl to /etc/rc.d/init.d/httpd:.
- ln -s /usr/local/apache/bin/apachectl /etc/rc.d/init.d/httpd.
- Starting from Apache 1.3.4, the three configuration files: srm.conf, httpd.conf, and.
- DirectoryIndex index.html index.shtml index.cgi index.phtml index.php3.
- AddType application/x-httpd-php3 .php3 .phtml.
- If you're using RedHat, run this:.
- /usr/local/bin/apachectl start.
- If it said that Apache was started, you should be able to use any web browser to connect to your box.
- You should see a bunch of processes like:.
- 14362 ? S 0:00 /usr/local/apache/bin/httpd 14364 ? S 0:00 /usr/local/apache/bin/httpd 14365 ? S 0:00 /usr/local/apache/bin/httpd 14366 ? S 0:00 /usr/local/apache/bin/httpd 14367 ? S 0:00 /usr/local/apache/bin/httpd 14368 ? S 0:00 /usr/local/apache/bin/httpd.
- /usr/local/bin/apachectl stop.
- tar -zxvf php-3.0.7.tar.gz.
- ./configure --with-apxs=/usr/local/apache/bin/apxs \ --with-config-file-path=/etc/httpd \ --with-mysql.
- The above configuration command should work fine if you've been following this howto exactly.
- If you have things installed in different locations:.
- Change --with-apxs=/usr/local/apache/bin/apxs to point to whatever path the apxs script is in.
- If you installed Apache from RPM, it will probably be in /usr/sbin/apxs.
- If you installed MySQL from the binary distribution, you should change --with-mysql to --with-mysql=/usr/local/mysql.
- If you don't have the GD library, take out the line that says --with-gd.
- cp php3.ini-dist /etc/httpd/php3.ini.
- /usr/local/apache/bin/apachectl start.
- Create a file in /home/httpd/htdocs (or /home/httpd/html if you installed Apache from the RedHat RPM) called test.php3:.
- lynx http://localhost/test.php3.
- You should see a page come up with the words Hello World.
- Building the Database.
- Creating the database.
- index.php3.
- Note, if you installed the Apache 1.3.3 RPM, your home pages are stored in /home/httpd/html, not htdocs..
- Next, create a file called index.php3 in this directory.
- echo "Found these entries in the database:<ul>";.
- <p><a href="add.php3">Add new entry</a>.
- 16 add.php3.
- Next, we create add.php3 in the same directory.
- This script does two things, first it will prompt the user for information to add to the database.
- Second, it will add this information to the database.
- echo "<p>$name was added to the database</p>";.
- <p><a href="index.php3">Back to index</a>.
- You should now be able to use your web browser to access what you've just created..
- This should bring up a page that lists all the entries you added to the database earlier.
- Found these entries in the database:.
- Select the Add new entry link, and you should go to a page that allows you to enter data:.
- This time, there are values in the two fields name and phone, so these get added to the database..
- You should see a message telling you something was added to the database.
- We've only scratched the surface, so at this point you should go on to the Apache, PHP, and MySQL homepages to read up on their documentation..
- Developer's Shed (http://www.devshed.com).
- PHP Homepage (http://www.php.net).
- By now, you should have a pretty good understanding of how everything fits together.
- Now you should be able to get a good feel for any other tool you decide to use, because the underlying concepts are pretty much the same.

Xem thử không khả dụng, vui lòng xem tại trang nguồn
hoặc xem Tóm tắt