| Usuario |
Información para un principiante |
Franchi
1 Mensaje(s)
|
| Enviado - 24/4/2003 |
| |
Hola, es la primera vez que voy a realizar un programa con estas herramientas, y m gustaría saber exactamente qué cosas necesito tener instaladas en mi PC bajo Windows para realizar una página Web con acceso a una base de datos utilizando php y MySQL y los pasos que tengo que dar para que todo funcione correctamente una vez que tenga todo programado.
Muchas gracias |
| |
|
Desconocido
|
| Enviado - 28/4/2003 |
| |
este es un tutorial que encontre en la web y te explica como instalar el apache. mysql y php, sigue las instrucciones y veras como funciona....Cualquier cosa mi correo es: [email protected]
Espero que te sirva
Apache Web Server
The Apache server is the world's most popular Web server by a large percentage and is generally considered to be more stable than other servers. It is usually installed on UNIX and Linux systems, but is also available for Microsoft Windows platform. We will download the Windows version. To download the Apache server for Windows, directly go to win32 download page of http://www.apache.org/ at http://www.apache.org/dist/httpd/binaries/win32/ . At this page various packaged downloads are available. Latest release of Apache is available in two options, one is a big file of 5.1MB which contain Windows installer also. For the Windows users who have latest Microsoft Windows Installer version already installed their is a smaller file of 3.2MB. Read the instruction presented on this page and download the file suitable for your Windows setup onto your hard drive in a new directory c:\download\apache\. I selected the file apache_1.3.23-win32-x86-no_src.exe (size 5.1MB) for my installation.
Latest stable release of Apache is version 2. You must download this latest version. I have added installation and configuration comments for Apache 2, wherever necessary. File name for latest Apache 2 with Windows installer is apache_2.0.39-win32-x86-no_ssl.exe (size 6.2 MB). Apache 2 specific comments are identified as APACHE 2 [ Comment added on 1/7/2002 ]
PHP4
PHP4 started as a small project to improve a home page and grew into one of the world's most powerful server-side scripts. The PHP community centered around www.php.net is very active. This is the place from where we will download the PHP4.
To download the PHP4, go directly to www.php.net/downloads.php and under "Windows 32 Binaries" click on PHP 4.1.2 zip package [5,824Kb] or whatever the latest version is. When you are asked to save the file, make a new directory called c:\download\php4 and save it there.
This windows 32 binary has compiled support for MySQL database. Some module files for other popular databases like dbase, MS-access are also included in this download. For other major RDBMS you have to download and install separate module files. For our development environment, we are going to use MySQL database, which support has been compiled in this binary distribution hence we doesn’t need any other module to download.
The PHP 4.1.2 download is in a single compressed file of 5.8MB having .Zip extension. You will need the winzip package or similar tool to uncompress it.
MySQL
MySQL is the database that your PHP4 will access to create dynamic Web sites.
To download the latest MySQL release go to http://www.mysql.com/downloads/mysql-3.23.html . At this page links are available to download MySQL in source as well as binary form for various platforms. Search for Windows downloads and under it click on MySQL 3.23.49 Windows 95/98/NT/2000/XP (12M) link to start downloading.
Save this file to c:\download\mysql on your hard disk. Also note that this download is also compressed in .Zip format and you will require winzip to uncompress it.
Installing, Configuring and Testing Tools
Installing Apache Web Server
Installing the Apache server takes less than a minute. You will see that it uses the nice install interface that we know and love with Windows applications. Installing Apache is probably the easiest of the three components that you will be installing today.
In your Windows Explorer, go to c:\download\apache and double click on the .exe file that was downloaded, e.g. apache_1.3.23-win32-x86-no_src.exe. Keep clicking on the NEXT and YES buttons. After you click on the FINISH button, Apache will be installed.
APACHE 2 For Apache 2, the installation procedure is same as above.
Apache gives you a couple of options during the installation but they are not interesting to us right now, so just accept all the defaults for the installation.
If you are an ASP developer and have Personal Web Server installed on your machine, don't worry, you will be able to run both the Apache and PWS without any conflicts. You will simply have to shut one down while you run the other.
Configure Apache
The Apache server will not work until you configure it. Configuring Apache is very easy: you simply have to change one line in a text file called httpd.conf. You will find this file under c:/Program Files/Apache Group/Apache/Conf. You can edit it with any text editor, e.g. NotePad. You can also access this file by Start > Programs > Apache HTTP Server > Configure Apache Server > Edit the httpd.conf configuration file.
Open the file httpd.conf in a text editor. Then search for the line
#ServerName new.host.name
and replace it with
ServerName localhost
Then save the text file. There is a nice tool available with Apache to check the httpd.conf file proper syntax. Use this tool to check your httpd.conf file. Access the tool from Start > Programs > Apache HTTP Server > Configure Apache Server > Test Configuration.
APACHE 2
To configure properly for Apache 2 add a colon and port number with the ServerName.
Example:
ServerName localhost:80
Testing Apache
To be able to serve pages, a server has to be running, just like any other application before it is used. You will now start the Apache server. Then you will open your browser and see if it displays HTML pages.
To start the Apache server, click on Start > Programs > Apache HTTP Server > Start Apache in Console. You should then see a DOS window that states that Apache is running. This DOS window will always be open for Apache web server. Simply click the minimize icon at the top right corner of this window to minimize it to Windows taskbar.
Now, open up your browser and type in http://localhost. If you should see a screen which reads something like "The Apache server is now installed on this Web site", then you have successfully installed the Apache server!
If it didn't work? There are a couple of things you can check:
Make sure that any other Web server is not running on your PC. If you have the Personal Web Server installed, for instance, then right-click on the icon in the lower-right of the screen and choose "stop".
Make sure you have saved the changes you made in the httpd.conf file by choosing FILE and SAVE in your text editor.
Installing PHP4
Installing PHP4 consists of simply unzipping it. For uncompressing you will need WinZip or a similar program. There is no install interface as with Apache.
Go to c:\download\php4\ or the directory where you have downloaded the PHP file and double click on the .zip file. Extract the files into a new sub-directory called c:\php4win.
After unzipping, to check if you were successful, look in c:\php4win\. There you will find many files & subdirectories containing various files, then you have installed PHP4 successfully!
Configure PHP4
Configuring PHP4 consists of changing a few lines in a text file, renaming it and copying it and another file into the Windows directory.
To configure PHP4, create a sub-directory called c:\phpWeb. This is where your PHP files will reside. Rename the file c:\php4win\php.ini-dist 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: only lines printed in bold text has to be changed.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ‘;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
include_path = ; UNIX: "/
doc_root = "c:\phpWeb" ; the root Web
user_dir =
;upload_tmp_dir =
upload_max_filesize = 2097152
extension_dir = "c:\php4win"
enable_dll = On
Then move the two-file php.ini and php4ts.dll to c:\windows. If you haven't already, make sure you delete the php.ini file from c:\php4win as otherwise it may cause conflicts later.
After you have copied these two files, PHP4 is configured.
Configure Apache for PHP4
Although PHP4 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. To do this, we need to alter Apache's httpd.conf file again, the same file we changed earlier.
Find and open file C:\Program\Apache Group\Apache\conf\httpd.conf in a text editor again. Then search for the DocumentRoot and lines and change them so they read as follows. Here change only bold printed lines only.
# symbolic links and aliases……
#
#DocumentRoot "C:/Programme ……
DocumentRoot "C:/phpWeb"
#this should be changed to
#
## This may also be ………….
APACHE 2 configuration needs one more directive to be changed. Find out the <Directory > directive few lines below the DocumentRoot. You will find specific instructions above this <Directory> directive as "This should be changed to whatever you set DocumentRoot to." Follow this instruction in its spirit and change it as follows:
#
# This should be changed to whatever you set DocumentRoot to.
#
#<Directory "C:/Program Files/Apache Group/Apache2/htdocs">
<Directory "C:/phpweb">
Then under the line AddType application/x-tar .tgz add the lines:
# For example, the PHP3 module (not part of the………
# will typically use:
#
#AddType application/x-httpd-php3 .phtml
#AddType application/x-httpd-php3-source .phps
AddType application/x-tar .tgz
ScriptAlias /php4/ "C:/php4win/"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php4
Action application/x-httpd-php "/php4/php.exe
Check closely for any typing errors, then save your changes.
Notice that in the http.conf file when referring to paths, Apache uses forward slashes ("/") instead of the more standard Window's backslashes ("\").
Notice also that a pound sign ("#") in front of a line comments it out so that it is not interpreted.
Notice also that the text /php4/ in the above code does not refer to a directory c:\php4 (which should not exist) but is a variable which we define to refer to the PHP directory c:\php4win.
In case you need to know later at some point, there are two ways to configure Apache for PHP4, as a CGI module or an Apache module. Here, we have installed the CGI module. You can also configure PHP4 as a Apache module, look for instructions in the install.txt file in the /php4win directory.
Testing PHP4
The changes you made in the http.conf file will not take place until you stop and restart your Apache server.
To stop the Apache server, restore the Apache server DOS window and click on close icon in the top right corner of it. To restart it again with use Start > Programs > Apache HTTP Server > Start Apache in Console .
Then create a one-line test PHP file called "c:\phpWeb\test.php" with the following contents:
Today is <? print strftime("%m/%d/%Y"); ?>
Then open your browser and go to: http://localhost/test.php
If you see the words "Today is" followed by the actual date, then you have successfully installed PHP4! You must remember here that PHP is a very powerful scripting language with its own syntax, commands and rules for developing applications. PHP is widely used for developing database backed Web services by a large number of Web developers. To learn more about PHP language, its syntax and usage, visit the http://www.php.net/.
Installing MySQL
The MySQL package you downloaded is a ZIP file that contains setup files. You will first unzip the ZIP file into its own directory then execute the setup file, which has a nice interface similar to Apache.
In c:\download\mysql, double-click on mysql-3.23.49-win.zip and uncompress it in a separate directory. After uncompressing run the setup.exe. Keep clicking Next and Yes during the installation process until the MySQL is installed.
Starting MySQL
In order for PHP to be able to speak to MySQL, it must be started. This means that each time you turn on your machine and want to work with PHP/MySQL, you will have to start MySQL.
To start MySQL, go to c:\mysql\bin\" and double click on mysqld.exe. If a MS-DOS window opens for a second and then closes, you did it correctly! MySQL has been started.
Testing MySQL
Now comes the big test: can Apache serve PHP files that talk to MySQL databases. To perform this test, you will create a PHP file that creates a MySQL database, then adds a record to it.
Create the file c:\phpWeb\testmysql.php with the following content:
<h3> Press RELOAD to add a record to the MySQL database:</h3>
<?
//establish user connection
mysql_connect("localhost");
//open up database
mysql_create_db("testdatabase");
mysql_select_db("testdatabase");
//create table
mysql_query("CREATE TABLE newone(firstName VARCHAR(25),lastName VARCHAR(25))");
mysql_query ("INSERT INTO newone (firstName, lastName) VALUES ('Amir', 'Khan')");
//display the information
$result = mysql_query ("SELECT * FROM newone");
while($row = mysql_fetch_array($result))
{
print ("Added record: " . $row["firstName"]." ".$row["lastName"]." <br>\n");
}
//close user connection
mysql_close();
?>
Each time you click on the RELOAD button, you will see that another record has been added to the database.
If you saw a name being added to the screen each time you clicked RELOAD, then you have successfully installed Apache, PHP4 and MySQL! Congratulations!
More information
Now that you have the Apache, PHP4 and MySQL installed on your machine, it is just the beginning of learning how to create robust applications with them.
I received many e-mail in connection with the problems faced by readers in installing & configuring the tools discussed here. I read every e-mail but it is not always possible to reply to each. I suggest you to first search the mailing lists archives at http://www.php.net/, http://www.apache.org/ and http://www.mysql.com/ for the solutions for problems with the respective tool. Also submitting your queries to these mailing list will always get attention and replies from a wider group of experienced open-source developers.
A comment section is included at the end of this page. I would like to read your comments and suggestions about this article.
Learning to develop software in a programming language always required some efforts. Although PHP is very easy language to program but developing Web applications are entirely different thing. To master the art of developing effective & purposeful Web applications, you will need to know more about Apache - the most popular, reliable & tested Web server. I like to suggest a very good book edited by Ben Laurie, Peter Laurie and Robert Denn, "Apache: the Definitive Guide" to everyone interested. Another good book, "Programming PHP" co-authored by the creator of PHP, Rasmus Lerdorf, explains the language syntax and programming techniques of PHP 4, in a clear and concise manner. Developing Web applications also required knowledge of relational databases and how to interact it using server-side programming. A nice introductory book, co-authored by Luke Welling and Laura Thomson, "PHP and MySQL Web Development", introduces readers to PHP and MySQL for the purpose of creating dynamic Internet sites.
I recommend the following online resources for you to start learning more on Apache, PHP4 and MySQL.
http://httpd.apache.org/docs/misc/tutorials.html
http://apache-server.com/tutorials/
Ken Coar's Apache Server for Dummies Tutorials
http://bignosebird.com/apache.shtml
BigNoseBird's APACHE Server Reference & Tutorials
http://www.devshed.com/Server_Side/PHP/
This site host many good tutorials for PHP scripting and developing database backed Web site.
http://linuxdocs.org/HOWTOs/PHP-HOWTO.html
PHP HOW-TO by Alavoor Vasudevan. This document tells you how to develop PHP programs and also howto migrate all the Windows 95 GUI applications to powerful PHP + HTML + DHTML + XML + Java applets + Javascript. The information in this document applies to all the operating sytems where PHP is ported that is - Linux, Windows 95/NT, OS/2, all flavors of UNIX like Solaris, HPUX, AIX, SCO, BSD, etc..
http://www.devshed.com/
This site hosts a good number of tutorials for Apache, PHP and MySQL.
If you need more information / tutorials / examples for Apache + PHP + MySQL go to your favorite search engine. All three are very popular open-source technologies and there are thousands of sources for information on them.
--------------------------------------------------------------------------------
[email protected] This article copyright Samdarshi Pali 2000-2002. All rights reserved.
LinSwap If you like this article, please rate it at HotScripts.com
Excellent!Very GoodGoodFairPoor
--------------------------------------------------------------------------------
Standard Disclaimers about my Web site.
Readers' Comments (if you don't see anything below, try clicking here) (made possible by Loquacious)
A nice and well presented instructions. Thanks for it.
Contributed by Anurag Verma ([email protected]) on March 21, 2002.
I had a little trouble at first getting the PHP to work. The problem was, I don't use WinZip, I use another program that automatically unzips files into an extra folder (Ultimate Unzip). I just had an extra folder name in the php4win directory path. After I took it out, the PHP worked just fine.
I never thought I could install all this on my computer, and configure it to work properly, but I did! I've been reading PHP tutorials for a little while now, and wanted somewhere to practice using PHP. I'm definitely not a techie, but I am a fast learner, so I hope to be able to learn how to at least write some simple (and useful) PHP scripts.
Thank you very much for your tutorial! It's things like it, and helpful people like you, that make the web more usable, and interesting for everybody. This is exactly the sort of thing I look for on the web.
Contributed by Susan Roberts ([email protected]) on March 23, 2002.
Thanks for an extraordinarily fine intro to these topics. I can hardly wait to set them up on my PC.
Contributed by Hank Hovemeyer ([email protected]) on June 28, 2002.
Hoi like your instruction about php and mysql but to complete the documentation you could mention the 2 missing files odbc32.dll and odbcint.dll not standard installed in win98system greetings from holland
Johann
Contributed by Jongsma J. (Johann) ([email protected]) on July 3, 2002.
Thanks a lot for the explanations!!!
Your page is wonderful.
Many thanks!!!
Raffaele Arcangeli
Contributed by Raffaele Arcangeli ([email protected]) on July 3, 2002.
Thought I would send you a real big thanks from this old man. I have just spent about two weeks trying to get a small server on my Linux box with no luck. Seems there are a great amount of HOW TO DO THIS STUFF for Linux and all of them really are for much more adept people. Some one at work suggested I try apache for windows since it works well on the windows platform! SO I jumped on the net an looked for the windows version and there was your DATABASE BACKED.... package on the net! Long story cut down what a great feeling of accomplishment here when (a) Your apache, php works just like you said it would!!!!!! Then to have the php install and WORK WOW. I am sure that the SQL will also. Being to old to learn much any more I just wanted a small home page for the family to visit and you have opened up a real neat and boundless, endless way to enjoy the world of FUN. Thanks to you for the great effort, flawless directions and to share with those of us who need lots of help. Thanks again for your time.. (I have shared this site with two others) Gene Snodgrass
Contributed by Gene Snodgrass ([email protected]) on July 9, 2002.
Wow thanks for this simple tutorial i have no idea about PHP or mySQL or apache and i was setting this up for my friend, i didn't have any problems at all with this tutorial , thanks!
Contributed by Steven D***n ([email protected]) on July 20, 2002.
Simple, quick, and effective...
This tutorial can save you from a lot of troubles.
Contributed by Alexandros Cicovic ([email protected]) on July 29, 2002.
Hi, The document was very helpful and nice. I followed line by line and found everything working except MySQL on my WinNT. I fixed the problem (installing service package). For further reading please visit http://www.mysql.com/doc/en/NT_start.html Thanks.
Contributed by Mir Ali ([email protected]) on August 17, 2002.
wow, great page, very clear and simple!
anonymously contributed on August 19, 2002.
Reading through your guide I noticed that you said "If you are an ASP developer and have Personal Web Server installed on your machine, don't worry, you will be able to run both the Apache and PWS without any conflicts. You will simply have to shut one down while you run the other." Whilst this is certainly true it might be worthwhile pointing out that you could also just tell apache to run on a port other than the default 80. This would enable you to run both PWS and Apache at the same time.
Contributed by Rob Wilson ([email protected]) on August 29, 2002.
Hi,
I just finished reading your PHP/mySQL/Apache/Windows article, and I just wanted to say thanks for creating such a great resource! I was up and running in less than 10 minutes, thanks to your excellent work.
Thanks again,
Hossein
Contributed by Hossein Sharifi ([email protected]) on September 4, 2002.
first I want to say thanks for this page and I suggest that for the new users to test a ready setup application that do all the job by only one click , it is found here http://www.phpgeek.com download the free PHPTriad and see how it is very easy and powerfull.
Contributed by A.hammed ([email protected]) on October 6, 2002.
this page for windows is great. but the apache 2 server was not working with php on windows Me .
Contributed by bhavin ([email protected]) on October 27, 2002.
Thanks for that very useful description! I installed the older Apache and PHP on Windows ME and it workes properly. Your manual is very easy to understand, espcially designed for "non- freaks". Great job!
Contributed by Immo ([email protected]_NOSPAM) on November 14, 2002.
Samdarshi, I experienced problems connecting to localhost in mySQL on Windows XP having tried Philip Percivals advice in your document entitled "Database backed Web application development environment for Windows 95/98/ME platform using open-source tools". I have found that if you start mySQL server at the command prompt as follows: C:mysqlin> mysqld-max-nt --standalone there should be no problems. You might want to include this in your document for others. By the way, I found your website extremely useful. Regards, Gavin
Gavin McHugh BE MIEI
Contributed by Gavin McHugh ([email protected]) on November 18, 2002.
I have just finished reading your artical concerning the set up of PHP, Apache and MySQL. That was great and very helpful. I have never used Apache before but NEED to now, and on a Windows 2000 Adv. Server. Where can I go to get, Learn or otherwise understand how to host my website from this box using the above mentioned tools? Again your artical has helped me out in a big way!!
Contributed by Ernest Hall ([email protected]) on November 26, 2002.
One security note, setting the ScriptAlias to /php/ or some such could invite potential abuse from outside the Server. A slow-down work around would be to use a random string like /somejunkgarbagecharacters/ as the ScriptAlias. (*For true security, other measures would also be needed.)
In addition to "the triad" I recommend two other free even for businesses applications: UltimateZip found at ultimatezip.com and Ace FTP Freeware found at freeware.aceftp.com
Contributed by Tagg Maiwald ([email protected]) on December 10, 2002.
I was lucky to find your page. I followed your recipe with 100% success.
Contributed by Gary Copenhaver (uzzy12162CS.COM) on February 5, 2003.
This is by far the best no BS walkthrough i've ever seen on the NET, especially concerning setting up a server!
I only ran into one problem. After installing Apache on my Win2000 machine, the server was not working as it said it would in the tutorial. After pulling half my hair out and cursing the author of this tutorial to many times to count, I relaized I should be cursing myself!
I regularly use ad-blocking software that requires me to use a proxy server to parse webfiles that are read in IE. The moment I unchecked "Use a proxy server" (located in Tools-- > Internet Options--> Connections--> LAN Settings) it worked flawlessly. The only reason I mention this is to let people know that if you are going through this tutorial and you can't get Apache (step 1) to run properly, to make sure any ad-blocking software (or any software that might require you to run a proxy server) is not confilcting.
Thanx for a great resource! You rock!
--melt out
Contributed by mediamelt ([email protected]) on February 8, 2003.
Good work. This is a useful page. Also check out this URL for a nice GUI driven interface to your MySQL engine. It makes creating databases and tables a breeze: http://www.phpwizard.net/projects/phpMyAdmin/
Contributed by Scott Adair ([email protected]) on February 25, 2003.
Hi This tutorial was very helpful. There is just one problem that I found which I think I shlould bring to your notice. In configuring PHP4 part we change the php.ini file. In the last line of the changes shown there is this line enable_dll = On In the latest version on PHP4 this line is enable_dl = On Now I know we dont have to change this line but if anybody does end up changing this last line of code, this shouldnt affect the PHP connection.
Contributed by Sameer Uplenchwar ([email protected]) on March 14, 2003.
Thanks, very helpful :)
Contributed by Chris ([email protected]) on April 24, 2003.
|
| |
|
|
|