⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 install-apache-php-mysql.php.htm

📁 complete details about using SQL applications
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<html><head><title>Installing Apache PHP MySQL</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" type="text/css" href="install-apache-php-mysql.php_files/styles.css">
<meta name="keywords" content="install apache php mysql, apache php mysql installer, windows apache mysql php, apache install mysql php, php for windows">
<meta name="description" content="How to easily install PHP, Apache and MySQL in Windows">
<meta name="netinsert" content="0.0.1.3.4.4.1">
<script language="JavaScript1.1" type="text/javascript">
<!-- // hide from old browsers
if (parent.frames.length > 0) top.location.replace(document.location); // Escape from any referring site's frame, but preserve one-click "Back". 
-->
</script><!--body onLoad="if ( top !=self ) { top.location = self.location; }"--></head>


<body>
<!-- google_ad_section_start -->
<table align="center" background="install-apache-php-mysql.php_files/bg1.gif" border="0" cellpadding="0" cellspacing="0" height="22" width="650">
 <tbody><tr>
  <td>&nbsp;</td>
 </tr>
</tbody></table>
<table align="center" border="0" cellspacing="0" width="650">
 <tbody><tr> 
  <td class="maincell" background="install-apache-php-mysql.php_files/bg2.gif">    <h1 align="center">Installing Apache PHP and MySQL</h1>
    <p>&nbsp;</p>
   <p>PHP and MySQL are usually associated with LAMP (Linux, Apache, MySQL, PHP). 
    However, most PHP developer ( including me ) are actually using Windows when 
    developing the PHP application. So this page will only cover the WAMP ( Windows, 
    Apache, MySQL, PHP ). You will learn how to install Apache, PHP, and MySQL 
    under Windows platform. </p>
   <p>
<script type="text/javascript"><!--
google_ad_client = "pub-0502328448303498";
google_alternate_ad_url = "http://www.php-mysql-tutorial.com/library/adsense/google_adsense_script.html";
google_ad_width = 336;
google_ad_height = 280;
google_ad_format = "336x280_as";
google_ad_type = "text";
google_ad_channel ="";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "000080";
google_color_url = "666666";
google_color_text = "000000";
//--></script>
<script type="text/javascript" src="install-apache-php-mysql.php_files/show_ads">
</script><iframe name="google_ads_frame" src="install-apache-php-mysql.php_files/ads.htm" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" frameborder="0" height="280" scrolling="no" width="336"></iframe>   </p>
    <p>The first step is to download the packages :</p>
    <ul>
        <li>Apache : <a href="http://www.apache.org/" target="_blank">www.apache.org</a></li>
        <li>PHP : <a href="http://www.php.net/" target="_blank">www.php.net</a></li>
        <li>MySQL : <a href="http://dev.mysql.com/downloads/" target="_blank">www.mysql.com</a></li>
    </ul>
    
   <p>You should get the latest version of each packages. As for the example in 
    this tutorial i'm using Apache 2.0.50 ( apache_2.0.50-win32-x86-no_ssl.msi 
    ), PHP 4.3.10 ( php-4.3.10-Win32.zip ) and MySQL 4.0.18 ( mysql-4.0.18-win.zip 
    ). </p>
    <p>Now let's start the installation process one by one.</p>
    <ul>
        <li><a href="#apache">Installing Apache</a></li>
        <li><a href="#php">Installing PHP</a></li>
        <li><a href="#apacheconf">Modifying Apache Configuration</a></li>
        <li><a href="#mysql">Installing MySQL</a></li>
        <li><a href="#phpconf">Modifying PHP Configuration File</a></li>
    </ul>
	
	</td>
 </tr>
</tbody></table>
<table align="center" border="0" cellspacing="0" width="650">
 <tbody><tr> 
  <td class="maincell" background="install-apache-php-mysql.php_files/bg2.gif"> <a name="apache">&nbsp;</a> 
    <h2>Installing Apache</h2>
    <p>Installing apache is easy if you download the Microsoft Installer ( .msi 
        ) package. Just double click on the icon to run the installation wizard. 
        Click next until you see the Server Information window. You can enter 
        localhost for both the Network Domain and Server Name. As for the administrator's 
        email address you can enter anything you want. </p>
    <p>I'm using Windows XP and installed Apache as Service so everytime I start 
        Windows Apache is automatically started. </p>
    <p align="center"><img src="install-apache-php-mysql.php_files/install-apache-1.png" alt="Install Apache PHP MySQL - Enter Apache server information" height="380" width="503"></p>
    <p>Click the Next button and choose Typical installation. Click Next one more 
        time and choose where you want to install Apache ( I installed it in the 
        default location <span class="courier">C:\Program Files\Apache Group</span> 
        ). Click the Next button and then the Install button to complete the installation 
        process.</p>
    <p>To see if you Apache installation was successful open up you browser and 
        type <span class="courier">http://localhost</span> in the address bar. 
        You should see something like this :</p>
    
   <p align="center"><img src="install-apache-php-mysql.php_files/install-apache-2.jpg" alt="Install Apache PHP MySQL  - Testing Apache Installation ( thumbnail created using PHP graphics library )" height="369" width="500"></p>
    
   <p>&nbsp;</p>
    <p>By default Apache's <strong>document root </strong>is set to<strong> <span class="courier">htdocs</span></strong><span class="courier"> 
        </span>directory. The document root is where you must put all your PHP 
        or HTML files so it will be process by Apache ( and can be seen through 
        a web browser ). Of course you can change it to point to any directory 
        you want. The configuration file for Apache is stored in <span class="courier">C:\Program 
        Files\Apache Group\Apache2\conf\httpd.conf </span>( assuming you installed 
        Apache in <span class="courier">C:\Program Files\Apache Group</span> ) 
        . It's just a plain text file so you can use Notepad to edit it. </p>
    <p>For example, if you want to put all your PHP or HTML files in <span class="courier">C:\www 
        </span>just find this line in the httpd.conf :</p>
    <p><span class="courier">DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs" 
        </span></p>
    <p>and change it to :</p>
    <p><span class="courier">DocumentRoot "C:/www"</span></p>
    <p>After making changes to the configuration file you have to restart Apache 
        ( <span class="courier">Start &gt; Programs &gt; Apache HTTP Server 2.0.50 
        &gt; Control Apache Server &gt; Restart</span> ) to see the effect.</p>
    <p>Another configuration you may want to change is the <strong>directory index.</strong> 
        This is the file that Apache will show when you request a directory. As 
        an example if you type <a href="http://www.php-mysql-tutorial.com/" target="_blank">http://www.php-mysql-tutorial.com/</a> 
        without specifying any file the <a href="http://www.php-mysql-tutorial.com/index.php" target="_blank">index.php</a> 
        file will be automatically shown.</p>
    <p>Suppose you want apache to use<span class="courier"> index.html, index.php</span> 
        or<span class="courier"> main.php</span> as the directory index you can 
        modify the <span class="courier">DirectoryIndex</span> value like this 
        :</p>
    <p class="courier">DirectoryIndex index.html index.php main.php</p>
    <p>Now whenever you request a directory such as <span class="courier">http://localhost/</span> 
        Apache will try to find the <span class="courier">index.html</span> file 
        or if it's not found Apache will use <span class="courier">index.php</span>. 
        In case <span class="courier">index.php</span> is also not found then 
        <span class="courier">main.php</span> will be used.</p></td>
 </tr>
</tbody></table>
<table align="center" border="0" cellspacing="0" width="650">
 <tbody><tr> 
  <td class="maincell" background="install-apache-php-mysql.php_files/bg2.gif">    <p><a name="php">&nbsp;</a></p>
    <h2>Installing PHP</h2>
    
   <p>First, extract the PHP package ( php-4.3.10-Win32.zip ). I extracted the 
    package in the directory where Apache was installed ( <span class="courier">C:\Program 
    Files\Apache Group\Apache2</span> ). Change the new created directory name 
    to <span class="courier">php</span> ( just to make it shorter ). Then copy 
    the file <span class="courier">php.ini-dist</span> in PHP directory to you 
    windows directory ( C:\Windows or C:\Winnt depends on where you installed 
    Windows ) and rename the file to <span class="courier">php.ini</span>. This 
    is the PHP configuration file and we'll take a look what's in it later on.</p>
    <p> Next, move the php4ts.dll file from the newly created php directory into 
        the sapi subdirectory. Quoting from php installation file you can also 
        place php4ts.dll in other places such as :</p>
    <ul>
        <li> In the directory where apache.exe is start from ( <span class="courier">C:\Program 
            Files\Apache Group\Apache2</span> \bin)</li>
        <li>In your %SYSTEMROOT%\System32, %SYSTEMROOT%\system and %SYSTEMROOT% 
            directory.<br>
            Note: %SYSTEMROOT%\System32 only applies to Windows NT/2000/XP)</li>
        <li>In your whole %PATH%</li>
    </ul>
    <p><strong>Side Note :</strong> Thanks to Shannon Tang for pointing this out</p>
&nbsp;</td>
 </tr>
</tbody></table>
<table align="center" border="0" cellspacing="0" width="650">
 <tbody><tr> 
  <td class="maincell" background="install-apache-php-mysql.php_files/bg2.gif">   <p><a name="apacheconf">&nbsp;</a></p>
    <h2>Modifying Apache Configuration</h2>
    <p>Apache doesn't know that you just install PHP. We need to tell Apache about 
        PHP and where to find it. Open the Apache configuration file in <span class="courier">C:\Program 
        Files\Apache Group\Apache2\conf\httpd.conf and add the following three 
        lines :</span></p>
    <p class="courier">LoadModule php4_module php/sapi/php4apache2.dll<br>
        AddType application/x-httpd-php .php<br>
        AddType application/x-httpd-php-source .phps </p>
    <p>The first line tells Apache where to load the dll required to execute PHP 
        and the second line means that every file that ends with <span class="courier">.php</span> 
        should be processed as a PHP file. You can actually change it to anything 
        you want like <span class="courier">.html </span>or even <span class="courier">.asp</span>! 
        The third line is added so that you can view your php file source code 
        in the browser window. You will see what this mean when you browse this 
        tutorial and click the link to the example's source code like <a href="http://www.php-mysql-tutorial.com/examples/source/php-tutorial/array.phps" target="_blank">this 
        one</a>.</p>
    <p>Now restart Apache for the changes to take effect ( <span class="courier">Start 
        &gt; Programs &gt; Apache HTTP Server 2.0.50 &gt; Control Apache Server 
        &gt; Restart</span> ) . To check if everything is okay create a new file, 
        name it as <span class="courier">test.php</span> and put it in document 
        root directory ( <span class="courier">C:\Program Files\Apache Group\Apache2\htdocs 
        )</span>. The content of this file is shown below.</p>
    <p> 
    </p><div class="codebox">&lt;?php<br>
        phpinfo();<br>
        ?&gt; </div>
    <p><span class="phpcode">phpinfo() </span>is the infamous PHP function which 
        will spit out all kinds of stuff about PHP and your server configuration. 
        Type <span class="courier">http://localhost/test.php</span> on your browser's 
        address bar and if everything works well you should see something like 
        this :</p>
    
   <p align="center"><img src="install-apache-php-mysql.php_files/test-php-installation.gif" height="492" width="605"> 
   </p></td>
 </tr>
</tbody></table>
<table align="center" border="0" cellspacing="0" width="650">
 <tbody><tr> 
  <td class="maincell" background="install-apache-php-mysql.php_files/bg2.gif">
    <p><a name="mysql">&nbsp;</a></p>
    <h2>Installing MySQL</h2>
    <p>First extract the package ( mysql-4.0.18-win.zip ) to a temporary directory, 
        then run <span class="courier">setup.exe. </span>Keep clicking the next 
        button to complete the installation. By default MySQL will be installed 
        in <span class="courier">C:\mysql.</span></p>
    <p>Open a DOS window and go to <span class="courier">C:\mysql\bin </span>and 
        then run <span class="courier">mysqld-nt --console</span> , you should 
        see some messages like these :</p>
    <div class="codebox"><strong>C:\mysql\bin&gt;mysqld-nt --console</strong><br>
        InnoDB: The first specified data file .\ibdata1 did not exist:<br>
        InnoDB: a new database to be created!<br>
        040807 10:54:09 InnoDB: Setting file .\ibdata1 size to 10 MB<br>
        InnoDB: Database physically writes the file full: wait...<br>
        040807 10:54:11 InnoDB: Log file .\ib_logfile0 did not exist: new to be 
        created 
        <p>InnoDB: Setting log file .\ib_logfile0 size to 5 MB<br>
            InnoDB: Database physically writes the file full: wait...<br>
            040807 10:54:12 InnoDB: Log file .\ib_logfile1 did not exist: new 
            to be created</p>
        <p>InnoDB: Setting log file .\ib_logfile1 size to 5 MB<br>
            InnoDB: Database physically writes the file full: wait...<br>
            InnoDB: Doublewrite buffer not found: creating new<br>
            InnoDB: Doublewrite buffer created<br>
            InnoDB: Creating foreign key constraint system tables<br>
            InnoDB: Foreign key constraint system tables created<br>
            040807 10:54:31 InnoDB: Started<br>
            mysqld-nt: ready for connections.<br>
            Version: '4.0.18-nt' socket: '' port: 3306<br>
        </p>
    </div>
    <p>Now open another DOS window and type <span class="courier">C:\mysql\bin\mysql 
        </span></p>
    <p>if your installation is successful you will see the MySQL client running 
        :</p>
    <p> 
    </p><div class="codebox"><strong>C:\mysql\bin&gt;mysql</strong><br>
        Welcome to the MySQL monitor. Commands end with ; or \g.<br>
        Your MySQL connection id is 1 to server version: 4.0.18-nt 
        <p>Type 'help;' or '\h' for help. Type '\c' to clear the buffer.</p>
        <p>mysql&gt;</p>
    </div><p></p>
    Type <span class="courier">exit </span>on the <span class="courier">mysql&gt;</span> 
    prompt to quit the MySQL client. 
    <p>Now let's<strong> install MySQL as a Service.</strong> The process is simple 
        just type <span class="courier">mysqld-nt --install</span> to install 
        the service and <span class="courier">net start mysql</span> to run the 
        service. But make sure to shutdown the server first using <span class="courier">mysqladmin 
        -u root shutdown</span></p>
    <p> 
    </p><div class="codebox"> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -